File tree 2 files changed +6
-5
lines changed
src/data-structures/circular-doubly-linked-list 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -617,14 +617,15 @@ class CircularDoublyLinkedList {
617
617
* allows execution to stop and not pick up again until the iterator's
618
618
* `next()` method is called again.
619
619
*
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`.
623
624
*/
624
625
do {
625
626
yield current . data ;
626
627
current = current . next ;
627
- } while ( current !== null ) ;
628
+ } while ( true ) ;
628
629
}
629
630
630
631
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @humanwhocodes/circular-doubly-linked-list" ,
3
- "version" : " 2.0.1 " ,
3
+ "version" : " 2.0.2 " ,
4
4
"description" : " A circular doubly linked list implementation in JavaScript" ,
5
5
"main" : " circular-doubly-linked-list.js" ,
6
6
"scripts" : {
You can’t perform that action at this time.
0 commit comments