directed-graph-typed 1.48.0 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/data-structures/base/index.d.ts +1 -0
  2. package/dist/data-structures/base/index.js +17 -0
  3. package/dist/data-structures/base/iterable-base.d.ts +232 -0
  4. package/dist/data-structures/base/iterable-base.js +312 -0
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +28 -19
  6. package/dist/data-structures/binary-tree/avl-tree.js +22 -11
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +158 -152
  8. package/dist/data-structures/binary-tree/binary-tree.js +241 -215
  9. package/dist/data-structures/binary-tree/bst.d.ts +64 -48
  10. package/dist/data-structures/binary-tree/bst.js +94 -65
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +39 -39
  12. package/dist/data-structures/binary-tree/rb-tree.js +42 -49
  13. package/dist/data-structures/binary-tree/tree-multimap.d.ts +60 -34
  14. package/dist/data-structures/binary-tree/tree-multimap.js +59 -27
  15. package/dist/data-structures/graph/abstract-graph.d.ts +92 -53
  16. package/dist/data-structures/graph/abstract-graph.js +130 -103
  17. package/dist/data-structures/graph/directed-graph.d.ts +70 -52
  18. package/dist/data-structures/graph/directed-graph.js +111 -65
  19. package/dist/data-structures/graph/map-graph.d.ts +5 -5
  20. package/dist/data-structures/graph/map-graph.js +8 -8
  21. package/dist/data-structures/graph/undirected-graph.d.ts +51 -32
  22. package/dist/data-structures/graph/undirected-graph.js +117 -54
  23. package/dist/data-structures/hash/hash-map.d.ts +160 -44
  24. package/dist/data-structures/hash/hash-map.js +314 -82
  25. package/dist/data-structures/heap/heap.d.ts +50 -7
  26. package/dist/data-structures/heap/heap.js +60 -30
  27. package/dist/data-structures/index.d.ts +1 -0
  28. package/dist/data-structures/index.js +1 -0
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +42 -55
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +50 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +36 -55
  32. package/dist/data-structures/linked-list/singly-linked-list.js +44 -77
  33. package/dist/data-structures/queue/deque.d.ts +35 -167
  34. package/dist/data-structures/queue/deque.js +43 -249
  35. package/dist/data-structures/queue/queue.d.ts +49 -48
  36. package/dist/data-structures/queue/queue.js +69 -82
  37. package/dist/data-structures/stack/stack.d.ts +43 -10
  38. package/dist/data-structures/stack/stack.js +50 -31
  39. package/dist/data-structures/trie/trie.d.ts +41 -6
  40. package/dist/data-structures/trie/trie.js +53 -32
  41. package/dist/interfaces/binary-tree.d.ts +6 -6
  42. package/dist/types/common.d.ts +11 -8
  43. package/dist/types/common.js +6 -1
  44. package/dist/types/data-structures/base/base.d.ts +5 -0
  45. package/dist/types/data-structures/base/base.js +2 -0
  46. package/dist/types/data-structures/base/index.d.ts +1 -0
  47. package/dist/types/data-structures/base/index.js +17 -0
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  49. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  50. package/dist/types/data-structures/binary-tree/bst.d.ts +6 -6
  51. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  52. package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  53. package/dist/types/data-structures/hash/hash-map.d.ts +4 -0
  54. package/dist/types/data-structures/index.d.ts +1 -0
  55. package/dist/types/data-structures/index.js +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/index.ts +1 -0
  58. package/src/data-structures/base/iterable-base.ts +329 -0
  59. package/src/data-structures/binary-tree/avl-tree.ts +37 -25
  60. package/src/data-structures/binary-tree/binary-tree.ts +336 -296
  61. package/src/data-structures/binary-tree/bst.ts +135 -89
  62. package/src/data-structures/binary-tree/rb-tree.ts +60 -69
  63. package/src/data-structures/binary-tree/tree-multimap.ts +86 -49
  64. package/src/data-structures/graph/abstract-graph.ts +136 -104
  65. package/src/data-structures/graph/directed-graph.ts +114 -65
  66. package/src/data-structures/graph/map-graph.ts +8 -8
  67. package/src/data-structures/graph/undirected-graph.ts +124 -56
  68. package/src/data-structures/hash/hash-map.ts +335 -84
  69. package/src/data-structures/heap/heap.ts +63 -36
  70. package/src/data-structures/index.ts +1 -0
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +54 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +49 -84
  73. package/src/data-structures/queue/deque.ts +43 -275
  74. package/src/data-structures/queue/queue.ts +71 -86
  75. package/src/data-structures/stack/stack.ts +53 -34
  76. package/src/data-structures/trie/trie.ts +58 -35
  77. package/src/interfaces/binary-tree.ts +5 -6
  78. package/src/types/common.ts +11 -8
  79. package/src/types/data-structures/base/base.ts +6 -0
  80. package/src/types/data-structures/base/index.ts +1 -0
  81. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
  82. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
  83. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  84. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
  85. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
  86. package/src/types/data-structures/hash/hash-map.ts +2 -0
  87. package/src/types/data-structures/heap/heap.ts +1 -1
  88. package/src/types/data-structures/index.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
@@ -1,3 +1,6 @@
1
+ import { IterableElementBase } from "../base";
2
+ import { ElementCallback } from "../../types";
3
+
1
4
  /**
2
5
  * data-structure-typed
3
6
  *
@@ -22,11 +25,12 @@ export class DoublyLinkedListNode<E = any> {
22
25
  }
23
26
  }
24
27
 
25
- export class DoublyLinkedList<E = any> {
28
+ export class DoublyLinkedList<E = any> extends IterableElementBase<E> {
26
29
  /**
27
30
  * The constructor initializes the linked list with an empty head, tail, and length.
28
31
  */
29
32
  constructor(elements?: Iterable<E>) {
33
+ super();
30
34
  this._head = undefined;
31
35
  this._tail = undefined;
32
36
  this._length = 0;
@@ -158,11 +162,11 @@ export class DoublyLinkedList<E = any> {
158
162
  * Time Complexity: O(1)
159
163
  * Space Complexity: O(1)
160
164
  *
161
- * The `popLast()` function removes and returns the value of the last node in a doubly linked list.
165
+ * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
162
166
  * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
163
167
  * list is empty, it returns undefined.
164
168
  */
165
- popLast(): E | undefined {
169
+ pollLast(): E | undefined {
166
170
  return this.pop();
167
171
  }
168
172
 
@@ -202,11 +206,11 @@ export class DoublyLinkedList<E = any> {
202
206
  * Time Complexity: O(1)
203
207
  * Space Complexity: O(1)
204
208
  *
205
- * The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
209
+ * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
206
210
  * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
207
211
  * list.
208
212
  */
209
- popFirst(): E | undefined {
213
+ pollFirst(): E | undefined {
210
214
  return this.shift();
211
215
  }
212
216
 
@@ -724,59 +728,32 @@ export class DoublyLinkedList<E = any> {
724
728
  }
725
729
 
726
730
  /**
727
- * The function returns an iterator that iterates over the values of a linked list.
728
- */
729
- * [Symbol.iterator]() {
730
- let current = this.head;
731
-
732
- while (current) {
733
- yield current.value;
734
- current = current.next;
735
- }
736
- }
737
-
738
- /**
739
- * Time Complexity: O(n), where n is the number of elements in the linked list.
740
- * Space Complexity: O(1)
741
- */
742
-
743
- /**
744
- * Time Complexity: O(n), where n is the number of elements in the linked list.
745
- * Space Complexity: O(1)
746
- *
747
- * The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
748
- * @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
749
- * represents the value of the current node in the linked list, and the index argument represents the index of the
750
- * current node in the linked list.
751
- */
752
- forEach(callback: (value: E, index: number, list: DoublyLinkedList<E>) => void): void {
753
- let index = 0;
754
- for (const el of this) {
755
- callback(el, index, this);
756
- index++;
757
- }
758
- }
759
-
760
- /**
761
- * Time Complexity: O(n), where n is the number of elements in the linked list.
731
+ * Time Complexity: O(n)
762
732
  * Space Complexity: O(n)
763
733
  */
764
734
 
765
735
  /**
766
- * Time Complexity: O(n), where n is the number of elements in the linked list.
736
+ * Time Complexity: O(n)
767
737
  * Space Complexity: O(n)
768
738
  *
769
- * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
770
- * elements that satisfy the given callback function.
771
- * @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
772
- * It is used to determine whether a value should be included in the filtered list or not.
773
- * @returns The filtered list, which is an instance of the DoublyLinkedList class.
774
- */
775
- filter(callback: (value: E, index: number, list: DoublyLinkedList<E>) => boolean): DoublyLinkedList<E> {
739
+ * The `filter` function creates a new DoublyLinkedList by iterating over the elements of the current
740
+ * list and applying a callback function to each element, returning only the elements for which the
741
+ * callback function returns true.
742
+ * @param callback - The `callback` parameter is a function that will be called for each element in
743
+ * the DoublyLinkedList. It takes three arguments: the current element, the index of the current
744
+ * element, and the DoublyLinkedList itself. The callback function should return a boolean value
745
+ * indicating whether the current element should be included
746
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
747
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
748
+ * passed as the `this` value to the `callback` function. If `thisArg` is
749
+ * @returns The `filter` method is returning a new `DoublyLinkedList` object that contains the
750
+ * elements that pass the filter condition specified by the `callback` function.
751
+ */
752
+ filter(callback: ElementCallback<E, boolean>, thisArg?: any): DoublyLinkedList<E> {
776
753
  const filteredList = new DoublyLinkedList<E>();
777
754
  let index = 0;
778
755
  for (const current of this) {
779
- if (callback(current, index, this)) {
756
+ if (callback.call(thisArg, current, index, this)) {
780
757
  filteredList.push(current);
781
758
  }
782
759
  index++;
@@ -790,21 +767,27 @@ export class DoublyLinkedList<E = any> {
790
767
  */
791
768
 
792
769
  /**
793
- * Time Complexity: O(n), where n is the number of elements in the linked list.
770
+ * Time Complexity: O(n)
794
771
  * Space Complexity: O(n)
795
772
  *
796
- * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
797
- * DoublyLinkedList with the transformed values.
798
- * @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
799
- * the original DoublyLinkedList) and returns a value of type T (the type of values that will be stored in the mapped
800
- * DoublyLinkedList).
801
- * @returns The `map` function is returning a new instance of `DoublyLinkedList<T>` that contains the mapped values.
802
- */
803
- map<T>(callback: (value: E, index: number, list: DoublyLinkedList<E>) => T): DoublyLinkedList<T> {
773
+ * The `map` function creates a new DoublyLinkedList by applying a callback function to each element
774
+ * in the original list.
775
+ * @param callback - The callback parameter is a function that will be called for each element in the
776
+ * DoublyLinkedList. It takes three arguments: the current element, the index of the current element,
777
+ * and the DoublyLinkedList itself. The callback function should return a value that will be added to
778
+ * the new DoublyLinkedList that
779
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
780
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
781
+ * passed as the `this` value to the `callback` function. If `thisArg` is
782
+ * @returns The `map` function is returning a new `DoublyLinkedList` object that contains the results
783
+ * of applying the provided `callback` function to each element in the original `DoublyLinkedList`
784
+ * object.
785
+ */
786
+ map<T>(callback: ElementCallback<E, T>, thisArg?: any): DoublyLinkedList<T> {
804
787
  const mappedList = new DoublyLinkedList<T>();
805
788
  let index = 0;
806
789
  for (const current of this) {
807
- mappedList.push(callback(current, index, this));
790
+ mappedList.push(callback.call(thisArg, current, index, this));
808
791
  index++;
809
792
  }
810
793
 
@@ -816,31 +799,19 @@ export class DoublyLinkedList<E = any> {
816
799
  * Space Complexity: O(n)
817
800
  */
818
801
 
819
- /**
820
- * Time Complexity: O(n), where n is the number of elements in the linked list.
821
- * Space Complexity: O(n)
822
- *
823
- * The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
824
- * single value.
825
- * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
826
- * used to perform a specific operation on each element of the linked list.
827
- * @param {T} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
828
- * point for the reduction operation.
829
- * @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
830
- * elements in the linked list.
831
- */
832
- reduce<T>(callback: (accumulator: T, value: E, index: number, list: DoublyLinkedList<E>) => T, initialValue: T): T {
833
- let accumulator = initialValue;
834
- let index = 0;
835
- for (const current of this) {
836
- accumulator = callback(accumulator, current, index, this);
837
- index++;
838
- }
839
-
840
- return accumulator;
841
- }
842
-
843
802
  print(): void {
844
803
  console.log([...this]);
845
804
  }
805
+
806
+ /**
807
+ * The function returns an iterator that iterates over the values of a linked list.
808
+ */
809
+ protected* _getIterator(): IterableIterator<E> {
810
+ let current = this.head;
811
+
812
+ while (current) {
813
+ yield current.value;
814
+ current = current.next;
815
+ }
816
+ }
846
817
  }
@@ -1,3 +1,6 @@
1
+ import { IterableElementBase } from "../base";
2
+ import { ElementCallback } from "../../types";
3
+
1
4
  /**
2
5
  * data-structure-typed
3
6
  *
@@ -20,11 +23,12 @@ export class SinglyLinkedListNode<E = any> {
20
23
  }
21
24
  }
22
25
 
23
- export class SinglyLinkedList<E = any> {
26
+ export class SinglyLinkedList<E = any> extends IterableElementBase<E> {
24
27
  /**
25
28
  * The constructor initializes the linked list with an empty head, tail, and length.
26
29
  */
27
30
  constructor(elements?: Iterable<E>) {
31
+ super();
28
32
  this._head = undefined;
29
33
  this._tail = undefined;
30
34
  this._length = 0;
@@ -160,12 +164,12 @@ export class SinglyLinkedList<E = any> {
160
164
  * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
161
165
  * Space Complexity: O(1) - Constant space.
162
166
  *
163
- * The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
167
+ * The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
164
168
  * pointers accordingly.
165
169
  * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
166
170
  * the linked list is empty, it returns `undefined`.
167
171
  */
168
- popLast(): E | undefined {
172
+ pollLast(): E | undefined {
169
173
  return this.pop();
170
174
  }
171
175
 
@@ -198,10 +202,10 @@ export class SinglyLinkedList<E = any> {
198
202
  * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
199
203
  * Space Complexity: O(1) - Constant space.
200
204
  *
201
- * The `popFirst()` function removes and returns the value of the first node in a linked list.
205
+ * The `pollFirst()` function removes and returns the value of the first node in a linked list.
202
206
  * @returns The value of the node that is being removed from the beginning of the linked list.
203
207
  */
204
- popFirst(): E | undefined {
208
+ pollFirst(): E | undefined {
205
209
  return this.shift();
206
210
  }
207
211
 
@@ -670,59 +674,32 @@ export class SinglyLinkedList<E = any> {
670
674
  }
671
675
 
672
676
  /**
673
- * The function returns an iterator that iterates over the values of a linked list.
674
- */
675
- * [Symbol.iterator]() {
676
- let current = this.head;
677
-
678
- while (current) {
679
- yield current.value;
680
- current = current.next;
681
- }
682
- }
683
-
684
- /**
685
- * Time Complexity: O(n), where n is the number of elements in the linked list.
686
- * Space Complexity: O(1)
687
- */
688
-
689
- /**
690
- * Time Complexity: O(n), where n is the number of elements in the linked list.
691
- * Space Complexity: O(1)
692
- *
693
- * The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
694
- * @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
695
- * represents the value of the current node in the linked list, and the index argument represents the index of the
696
- * current node in the linked list.
697
- */
698
- forEach(callback: (value: E, index: number, list: SinglyLinkedList<E>) => void): void {
699
- let index = 0;
700
- for (const el of this) {
701
- callback(el, index, this);
702
- index++;
703
- }
704
- }
705
-
706
- /**
707
- * Time Complexity: O(n), where n is the number of elements in the linked list.
677
+ * Time Complexity: O(n)
708
678
  * Space Complexity: O(n)
709
679
  */
710
680
 
711
681
  /**
712
- * Time Complexity: O(n), where n is the number of elements in the linked list.
682
+ * Time Complexity: O(n)
713
683
  * Space Complexity: O(n)
714
684
  *
715
- * The `filter` function iterates through a SinglyLinkedList and returns a new SinglyLinkedList containing only the
716
- * elements that satisfy the given callback function.
717
- * @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
718
- * It is used to determine whether a value should be included in the filtered list or not.
719
- * @returns The filtered list, which is an instance of the SinglyLinkedList class.
720
- */
721
- filter(callback: (value: E, index: number, list: SinglyLinkedList<E>) => boolean): SinglyLinkedList<E> {
685
+ * The `filter` function creates a new SinglyLinkedList by iterating over the elements of the current
686
+ * list and applying a callback function to each element to determine if it should be included in the
687
+ * filtered list.
688
+ * @param callback - The callback parameter is a function that will be called for each element in the
689
+ * list. It takes three arguments: the current element, the index of the current element, and the
690
+ * list itself. The callback function should return a boolean value indicating whether the current
691
+ * element should be included in the filtered list or not
692
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
693
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
694
+ * passed as the `this` value to the `callback` function. If `thisArg` is
695
+ * @returns The `filter` method is returning a new `SinglyLinkedList` object that contains the
696
+ * elements that pass the filter condition specified by the `callback` function.
697
+ */
698
+ filter(callback: ElementCallback<E, boolean>, thisArg?: any): SinglyLinkedList<E> {
722
699
  const filteredList = new SinglyLinkedList<E>();
723
700
  let index = 0;
724
701
  for (const current of this) {
725
- if (callback(current, index, this)) {
702
+ if (callback.call(thisArg, current, index, this)) {
726
703
  filteredList.push(current);
727
704
  }
728
705
  index++;
@@ -730,27 +707,30 @@ export class SinglyLinkedList<E = any> {
730
707
  return filteredList;
731
708
  }
732
709
 
710
+
733
711
  /**
734
712
  * Time Complexity: O(n), where n is the number of elements in the linked list.
735
713
  * Space Complexity: O(n)
736
714
  */
737
-
738
715
  /**
739
- * Time Complexity: O(n), where n is the number of elements in the linked list.
716
+ * Time Complexity: O(n)
740
717
  * Space Complexity: O(n)
741
718
  *
742
- * The `map` function takes a callback function and applies it to each element in the SinglyLinkedList, returning a new
743
- * SinglyLinkedList with the transformed values.
744
- * @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
745
- * the original SinglyLinkedList) and returns a value of type T (the type of values that will be stored in the mapped
746
- * SinglyLinkedList).
747
- * @returns The `map` function is returning a new instance of `SinglyLinkedList<T>` that contains the mapped values.
748
- */
749
- map<T>(callback: (value: E, index: number, list: SinglyLinkedList<E>) => T): SinglyLinkedList<T> {
719
+ * The `map` function creates a new SinglyLinkedList by applying a callback function to each element
720
+ * of the original list.
721
+ * @param callback - The `callback` parameter is a function that will be called for each element in
722
+ * the linked list. It takes three arguments:
723
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
724
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
725
+ * passed as the `this` value to the `callback` function. If `thisArg` is
726
+ * @returns The `map` function is returning a new `SinglyLinkedList` object that contains the results
727
+ * of applying the provided `callback` function to each element in the original list.
728
+ */
729
+ map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T> {
750
730
  const mappedList = new SinglyLinkedList<T>();
751
731
  let index = 0;
752
732
  for (const current of this) {
753
- mappedList.push(callback(current, index, this));
733
+ mappedList.push(callback.call(thisArg, current, index, this));
754
734
  index++;
755
735
  }
756
736
 
@@ -762,31 +742,16 @@ export class SinglyLinkedList<E = any> {
762
742
  * Space Complexity: O(n)
763
743
  */
764
744
 
765
- /**
766
- * Time Complexity: O(n), where n is the number of elements in the linked list.
767
- * Space Complexity: O(n)
768
- *
769
- * The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
770
- * single value.
771
- * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
772
- * used to perform a specific operation on each element of the linked list.
773
- * @param {T} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
774
- * point for the reduction operation.
775
- * @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
776
- * elements in the linked list.
777
- */
778
- reduce<T>(callback: (accumulator: T, value: E, index: number, list: SinglyLinkedList<E>) => T, initialValue: T): T {
779
- let accumulator = initialValue;
780
- let index = 0;
781
- for (const current of this) {
782
- accumulator = callback(accumulator, current, index, this);
783
- index++;
784
- }
785
-
786
- return accumulator;
787
- }
788
-
789
745
  print(): void {
790
746
  console.log([...this]);
791
747
  }
748
+
749
+ protected* _getIterator(): IterableIterator<E> {
750
+ let current = this.head;
751
+
752
+ while (current) {
753
+ yield current.value;
754
+ current = current.next;
755
+ }
756
+ }
792
757
  }