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
@@ -7,15 +7,16 @@
7
7
  * @license MIT License
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ObjectDeque = exports.Deque = void 0;
10
+ exports.Deque = void 0;
11
11
  const utils_1 = require("../../utils");
12
+ const base_1 = require("../base");
12
13
  /**
13
14
  * Deque can provide random access with O(1) time complexity
14
15
  * Deque is usually more compact and efficient in memory usage because it does not require additional space to store pointers.
15
16
  * Deque may experience performance jitter, but DoublyLinkedList will not
16
17
  * Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
17
18
  */
18
- class Deque {
19
+ class Deque extends base_1.IterableElementBase {
19
20
  /**
20
21
  * The constructor initializes a data structure with a specified bucket size and populates it with
21
22
  * elements from an iterable.
@@ -26,6 +27,7 @@ class Deque {
26
27
  * stored in each bucket. It determines the size of each bucket in the data structure.
27
28
  */
28
29
  constructor(elements = [], bucketSize = (1 << 12)) {
30
+ super();
29
31
  this._bucketFirst = 0;
30
32
  this._firstInBucket = 0;
31
33
  this._bucketLast = 0;
@@ -109,10 +111,10 @@ class Deque {
109
111
  * Time Complexity: O(1) - Removes the last element.
110
112
  * Space Complexity: O(1) - Operates in-place.
111
113
  *
112
- * The function "popLast" removes and returns the last element of an array.
114
+ * The function "pollLast" removes and returns the last element of an array.
113
115
  * @returns The last element of the array is being returned.
114
116
  */
115
- popLast() {
117
+ pollLast() {
116
118
  return this.pop();
117
119
  }
118
120
  /**
@@ -130,11 +132,11 @@ class Deque {
130
132
  * Time Complexity: O(1) - Removes the first element.
131
133
  * Space Complexity: O(1) - In-place operation.
132
134
  *
133
- * The function "popFirst" removes and returns the first element of an array.
134
- * @returns The method `popFirst()` is returning the first element of the array after removing it
135
+ * The function "pollFirst" removes and returns the first element of an array.
136
+ * @returns The method `pollFirst()` is returning the first element of the array after removing it
135
137
  * from the beginning. If the array is empty, it will return `undefined`.
136
138
  */
137
- popFirst() {
139
+ pollFirst() {
138
140
  return this.shift();
139
141
  }
140
142
  /**
@@ -651,42 +653,6 @@ class Deque {
651
653
  }
652
654
  return arr;
653
655
  }
654
- /**
655
- * Time Complexity: O(n)
656
- * Space Complexity: O(1)
657
- */
658
- /**
659
- * Time Complexity: O(n)
660
- * Space Complexity: O(1)
661
- *
662
- * The above function is an implementation of the iterator protocol in TypeScript, allowing the
663
- * object to be iterated over using a for...of loop.
664
- */
665
- *[Symbol.iterator]() {
666
- for (let i = 0; i < this.size; ++i) {
667
- yield this.getAt(i);
668
- }
669
- }
670
- /**
671
- * Time Complexity: O(n)
672
- * Space Complexity: O(1)
673
- */
674
- /**
675
- * Time Complexity: O(n)
676
- * Space Complexity: O(1)
677
- *
678
- * The `forEach` function iterates over each element in a deque and applies a callback function to
679
- * each element.
680
- * @param callback - The callback parameter is a function that will be called for each element in the
681
- * deque. It takes three parameters:
682
- */
683
- forEach(callback) {
684
- let index = 0;
685
- for (const el of this) {
686
- callback(el, index, this);
687
- index++;
688
- }
689
- }
690
656
  /**
691
657
  * Time Complexity: O(n)
692
658
  * Space Complexity: O(n)
@@ -695,18 +661,23 @@ class Deque {
695
661
  * Time Complexity: O(n)
696
662
  * Space Complexity: O(n)
697
663
  *
698
- * The `filter` function creates a new deque containing only the elements that satisfy the given
699
- * predicate function.
700
- * @param predicate - The `predicate` parameter is a function that takes three arguments: `element`,
701
- * `index`, and `deque`.
702
- * @returns The `filter` method is returning a new `Deque` object that contains only the elements
703
- * that satisfy the given `predicate` function.
704
- */
705
- filter(predicate) {
664
+ * The `filter` function creates a new deque containing elements from the original deque that satisfy
665
+ * a given predicate function.
666
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
667
+ * the current element being iterated over, the index of the current element, and the deque itself.
668
+ * It should return a boolean value indicating whether the element should be included in the filtered
669
+ * deque or not.
670
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
671
+ * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
672
+ * passed as the `this` value to the `predicate` function. If `thisArg` is
673
+ * @returns The `filter` method is returning a new `Deque` object that contains the elements that
674
+ * satisfy the given predicate function.
675
+ */
676
+ filter(predicate, thisArg) {
706
677
  const newDeque = new Deque([], this._bucketSize);
707
678
  let index = 0;
708
679
  for (const el of this) {
709
- if (predicate(el, index, this)) {
680
+ if (predicate.call(thisArg, el, index, this)) {
710
681
  newDeque.push(el);
711
682
  }
712
683
  index++;
@@ -721,48 +692,42 @@ class Deque {
721
692
  * Time Complexity: O(n)
722
693
  * Space Complexity: O(n)
723
694
  *
724
- * The `map` function takes a callback function and applies it to each element in the deque,
725
- * returning a new deque with the results.
726
- * @param callback - The `callback` parameter is a function that takes three arguments:
727
- * @returns The `map` method is returning a new `Deque` object with the transformed elements.
695
+ * The `map` function creates a new Deque by applying a callback function to each element of the
696
+ * original Deque.
697
+ * @param callback - The `callback` parameter is a function that will be called for each element in
698
+ * the deque. It takes three arguments:
699
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
700
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
701
+ * passed as the `this` value to the `callback` function. If `thisArg` is
702
+ * @returns a new Deque object with the mapped values.
728
703
  */
729
- map(callback) {
704
+ map(callback, thisArg) {
730
705
  const newDeque = new Deque([], this._bucketSize);
731
706
  let index = 0;
732
707
  for (const el of this) {
733
- newDeque.push(callback(el, index, this));
708
+ newDeque.push(callback.call(thisArg, el, index, this));
734
709
  index++;
735
710
  }
736
711
  return newDeque;
737
712
  }
738
713
  /**
739
714
  * Time Complexity: O(n)
740
- * Space Complexity: O(1)
715
+ * Space Complexity: O(n)
741
716
  */
717
+ print() {
718
+ console.log([...this]);
719
+ }
742
720
  /**
743
721
  * Time Complexity: O(n)
744
722
  * Space Complexity: O(1)
745
723
  *
746
- * The `reduce` function iterates over the elements of a deque and applies a callback function to
747
- * each element, accumulating a single value.
748
- * @param callback - The `callback` parameter is a function that takes four arguments:
749
- * @param {T} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
750
- * is the value that will be passed as the first argument to the `callback` function when reducing
751
- * the elements of the deque.
752
- * @returns the final value of the accumulator after iterating over all elements in the deque and
753
- * applying the callback function to each element.
754
- */
755
- reduce(callback, initialValue) {
756
- let accumulator = initialValue;
757
- let index = 0;
758
- for (const el of this) {
759
- accumulator = callback(accumulator, el, index, this);
760
- index++;
724
+ * The above function is an implementation of the iterator protocol in TypeScript, allowing the
725
+ * object to be iterated over using a for...of loop.
726
+ */
727
+ *_getIterator() {
728
+ for (let i = 0; i < this.size; ++i) {
729
+ yield this.getAt(i);
761
730
  }
762
- return accumulator;
763
- }
764
- print() {
765
- console.log([...this]);
766
731
  }
767
732
  /**
768
733
  * Time Complexity: O(n)
@@ -827,174 +792,3 @@ class Deque {
827
792
  }
828
793
  }
829
794
  exports.Deque = Deque;
830
- // O(1) time complexity of obtaining the element
831
- // O(n) time complexity of adding at the beginning and the end
832
- // todo tested slowest one
833
- class ObjectDeque {
834
- constructor(capacity) {
835
- this._nodes = {};
836
- this._capacity = Number.MAX_SAFE_INTEGER;
837
- this._first = -1;
838
- this._last = -1;
839
- this._size = 0;
840
- if (capacity !== undefined)
841
- this._capacity = capacity;
842
- }
843
- get nodes() {
844
- return this._nodes;
845
- }
846
- get capacity() {
847
- return this._capacity;
848
- }
849
- get first() {
850
- return this._first;
851
- }
852
- get last() {
853
- return this._last;
854
- }
855
- get size() {
856
- return this._size;
857
- }
858
- /**
859
- * Time Complexity: O(1)
860
- * Space Complexity: O(1)
861
- */
862
- /**
863
- * Time Complexity: O(1)
864
- * Space Complexity: O(1)
865
- *
866
- * The "addFirst" function adds an element to the beginning of an array-like data structure.
867
- * @param {E} element - The `element` parameter represents the element that you want to add to the beginning of the data
868
- * structure.
869
- */
870
- addFirst(element) {
871
- if (this.size === 0) {
872
- const mid = Math.floor(this.capacity / 2);
873
- this._first = mid;
874
- this._last = mid;
875
- }
876
- else {
877
- this._first--;
878
- }
879
- this.nodes[this.first] = element;
880
- this._size++;
881
- }
882
- /**
883
- * Time Complexity: O(1)
884
- * Space Complexity: O(1)
885
- */
886
- /**
887
- * Time Complexity: O(1)
888
- * Space Complexity: O(1)
889
- *
890
- * The addLast function adds an element to the end of an array-like data structure.
891
- * @param {E} element - The `element` parameter represents the element that you want to add to the end of the data structure.
892
- */
893
- addLast(element) {
894
- if (this.size === 0) {
895
- const mid = Math.floor(this.capacity / 2);
896
- this._first = mid;
897
- this._last = mid;
898
- }
899
- else {
900
- this._last++;
901
- }
902
- this.nodes[this.last] = element;
903
- this._size++;
904
- }
905
- /**
906
- * Time Complexity: O(1)
907
- * Space Complexity: O(1)
908
- */
909
- /**
910
- * Time Complexity: O(1)
911
- * Space Complexity: O(1)
912
- *
913
- * The function `popFirst()` removes and returns the first element in a data structure.
914
- * @returns The element of the first element in the data structure.
915
- */
916
- popFirst() {
917
- if (!this.size)
918
- return;
919
- const element = this.getFirst();
920
- delete this.nodes[this.first];
921
- this._first++;
922
- this._size--;
923
- return element;
924
- }
925
- /**
926
- * Time Complexity: O(1)
927
- * Space Complexity: O(1)
928
- */
929
- /**
930
- * Time Complexity: O(1)
931
- * Space Complexity: O(1)
932
- *
933
- * The `getFirst` function returns the first element in an array-like data structure if it exists.
934
- * @returns The element at the first position of the `_nodes` array.
935
- */
936
- getFirst() {
937
- if (this.size)
938
- return this.nodes[this.first];
939
- }
940
- /**
941
- * Time Complexity: O(1)
942
- * Space Complexity: O(1)
943
- */
944
- /**
945
- * Time Complexity: O(1)
946
- * Space Complexity: O(1)
947
- *
948
- * The `popLast()` function removes and returns the last element in a data structure.
949
- * @returns The element that was removed from the data structure.
950
- */
951
- popLast() {
952
- if (!this.size)
953
- return;
954
- const element = this.getLast();
955
- delete this.nodes[this.last];
956
- this._last--;
957
- this._size--;
958
- return element;
959
- }
960
- /**
961
- * Time Complexity: O(1)
962
- * Space Complexity: O(1)
963
- */
964
- /**
965
- * Time Complexity: O(1)
966
- * Space Complexity: O(1)
967
- *
968
- * The `getLast()` function returns the last element in an array-like data structure.
969
- * @returns The last element in the array "_nodes" is being returned.
970
- */
971
- getLast() {
972
- if (this.size)
973
- return this.nodes[this.last];
974
- }
975
- /**
976
- * Time Complexity: O(1)
977
- * Space Complexity: O(1)
978
- */
979
- /**
980
- * Time Complexity: O(1)
981
- * Space Complexity: O(1)
982
- *
983
- * The get function returns the element at the specified index in an array-like data structure.
984
- * @param {number} index - The index parameter is a number that represents the position of the element you want to
985
- * retrieve from the array.
986
- * @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that
987
- * index, `undefined` is returned.
988
- */
989
- get(index) {
990
- return this.nodes[this.first + index] || undefined;
991
- }
992
- /**
993
- * The function checks if the size of a data structure is less than or equal to zero.
994
- * @returns The method is returning a boolean element indicating whether the size of the object is less than or equal to 0.
995
- */
996
- isEmpty() {
997
- return this.size <= 0;
998
- }
999
- }
1000
- exports.ObjectDeque = ObjectDeque;
@@ -4,29 +4,9 @@
4
4
  * @class
5
5
  */
6
6
  import { SinglyLinkedList } from '../linked-list';
7
- export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
8
- /**
9
- * The enqueue function adds a value to the end of an array.
10
- * @param {E} value - The value parameter represents the value that you want to add to the queue.
11
- */
12
- enqueue(value: E): void;
13
- /**
14
- * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
15
- * @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
16
- */
17
- dequeue(): E | undefined;
18
- /**
19
- * The `getFirst` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
20
- * @returns The `getFirst()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
21
- */
22
- getFirst(): E | undefined;
23
- /**
24
- * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
25
- * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
26
- */
27
- peek(): E | undefined;
28
- }
29
- export declare class Queue<E = any> {
7
+ import { IterableElementBase } from "../base";
8
+ import { ElementCallback } from "../../types";
9
+ export declare class Queue<E = any> extends IterableElementBase<E> {
30
10
  /**
31
11
  * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
32
12
  * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
@@ -206,21 +186,27 @@ export declare class Queue<E = any> {
206
186
  */
207
187
  clone(): Queue<E>;
208
188
  print(): void;
209
- [Symbol.iterator](): Generator<E, void, unknown>;
210
189
  /**
211
190
  * Time Complexity: O(n)
212
- * Space Complexity: O(1)
191
+ * Space Complexity: O(n)
213
192
  */
214
193
  /**
215
194
  * Time Complexity: O(n)
216
- * Space Complexity: O(1)
195
+ * Space Complexity: O(n)
217
196
  *
218
- * The `forEach` function iterates over each element in a deque and applies a callback function to
219
- * each element.
220
- * @param callback - The callback parameter is a function that will be called for each element in the
221
- * deque. It takes three parameters:
222
- */
223
- forEach(callback: (element: E, index: number, queue: this) => void): void;
197
+ * The `filter` function creates a new `Queue` object containing elements from the original `Queue`
198
+ * that satisfy a given predicate function.
199
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
200
+ * the current element being iterated over, the index of the current element, and the queue itself.
201
+ * It should return a boolean value indicating whether the element should be included in the filtered
202
+ * queue or not.
203
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
204
+ * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
205
+ * passed as the `this` value to the `predicate` function. If `thisArg` is
206
+ * @returns The `filter` method is returning a new `Queue` object that contains the elements that
207
+ * satisfy the given predicate function.
208
+ */
209
+ filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Queue<E>;
224
210
  /**
225
211
  * Time Complexity: O(n)
226
212
  * Space Complexity: O(n)
@@ -229,27 +215,42 @@ export declare class Queue<E = any> {
229
215
  * Time Complexity: O(n)
230
216
  * Space Complexity: O(n)
231
217
  *
232
- * The `filter` function creates a new deque containing only the elements that satisfy the given
233
- * predicate function.
234
- * @param predicate - The `predicate` parameter is a function that takes three arguments: `element`,
235
- * `index`, and `deque`.
236
- * @returns The `filter` method is returning a new `Queue` object that contains only the elements
237
- * that satisfy the given `predicate` function.
218
+ * The `map` function takes a callback function and applies it to each element in the queue,
219
+ * returning a new queue with the results.
220
+ * @param callback - The callback parameter is a function that will be called for each element in the
221
+ * queue. It takes three arguments: the current element, the index of the current element, and the
222
+ * queue itself. The callback function should return a new value that will be added to the new queue.
223
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
224
+ * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
225
+ * passed as the `this` value to the `callback` function. If `thisArg` is
226
+ * @returns The `map` function is returning a new `Queue` object with the transformed elements.
238
227
  */
239
- filter(predicate: (element: E, index: number, queue: this) => boolean): Queue<E>;
228
+ map<T>(callback: ElementCallback<E, T>, thisArg?: any): Queue<T>;
240
229
  /**
241
230
  * Time Complexity: O(n)
242
231
  * Space Complexity: O(n)
243
232
  */
233
+ protected _getIterator(): Generator<E, void, unknown>;
234
+ }
235
+ export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
244
236
  /**
245
- * Time Complexity: O(n)
246
- * Space Complexity: O(n)
247
- *
248
- * The `map` function takes a callback function and applies it to each element in the deque,
249
- * returning a new deque with the results.
250
- * @param callback - The `callback` parameter is a function that takes three arguments:
251
- * @returns The `map` method is returning a new `Queue` object with the transformed elements.
237
+ * The enqueue function adds a value to the end of an array.
238
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
252
239
  */
253
- map<T>(callback: (element: E, index: number, queue: this) => T): Queue<T>;
254
- reduce<T>(callback: (accumulator: T, element: E, index: number, queue: this) => T, initialValue: T): T;
240
+ enqueue(value: E): void;
241
+ /**
242
+ * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
243
+ * @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
244
+ */
245
+ dequeue(): E | undefined;
246
+ /**
247
+ * The `getFirst` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
248
+ * @returns The `getFirst()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
249
+ */
250
+ getFirst(): E | undefined;
251
+ /**
252
+ * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
253
+ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
254
+ */
255
+ peek(): E | undefined;
255
256
  }