Skip to content

Commit 727acec

Browse files
committed
Fix: circularValues() method
1 parent b922f2d commit 727acec

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/data-structures/circular-doubly-linked-list/circular-doubly-linked-list.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,14 +617,15 @@ class CircularDoublyLinkedList {
617617
* allows execution to stop and not pick up again until the iterator's
618618
* `next()` method is called again.
619619
*
620-
* It's possible for this loop to exit if the list is emptied
621-
* in between calls to the iterator's `next()` method. That will
622-
* cause `current` to be `null` and the iterator will close.
620+
* It's not possible for this loop to exit. Even removing all nodes
621+
* from the list using `remove()` or `clear()` will not cause the
622+
* loop to stop yield values. That's because `current.next` always
623+
* has a value, even if it just points back to `current`.
623624
*/
624625
do {
625626
yield current.data;
626627
current = current.next;
627-
} while (current !== null);
628+
} while (true);
628629
}
629630

630631
}

src/data-structures/circular-doubly-linked-list/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@humanwhocodes/circular-doubly-linked-list",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A circular doubly linked list implementation in JavaScript",
55
"main": "circular-doubly-linked-list.js",
66
"scripts": {

0 commit comments

Comments
 (0)