queue-typed 1.47.3 → 1.47.5

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 (29) hide show
  1. package/README.md +410 -353
  2. package/dist/data-structures/hash/hash-map.d.ts +3 -3
  3. package/dist/data-structures/hash/hash-map.js +10 -4
  4. package/dist/data-structures/hash/hash-table.d.ts +9 -4
  5. package/dist/data-structures/hash/hash-table.js +50 -5
  6. package/dist/data-structures/heap/heap.d.ts +6 -1
  7. package/dist/data-structures/heap/heap.js +51 -9
  8. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +56 -56
  9. package/dist/data-structures/linked-list/doubly-linked-list.js +117 -119
  10. package/dist/data-structures/linked-list/singly-linked-list.d.ts +36 -36
  11. package/dist/data-structures/linked-list/singly-linked-list.js +58 -60
  12. package/dist/data-structures/queue/deque.d.ts +49 -49
  13. package/dist/data-structures/queue/deque.js +79 -72
  14. package/dist/data-structures/queue/queue.d.ts +45 -0
  15. package/dist/data-structures/queue/queue.js +77 -0
  16. package/dist/data-structures/stack/stack.d.ts +18 -5
  17. package/dist/data-structures/stack/stack.js +56 -7
  18. package/dist/data-structures/trie/trie.d.ts +5 -0
  19. package/dist/data-structures/trie/trie.js +47 -0
  20. package/package.json +2 -2
  21. package/src/data-structures/hash/hash-map.ts +13 -7
  22. package/src/data-structures/hash/hash-table.ts +59 -9
  23. package/src/data-structures/heap/heap.ts +60 -9
  24. package/src/data-structures/linked-list/doubly-linked-list.ts +129 -129
  25. package/src/data-structures/linked-list/singly-linked-list.ts +65 -65
  26. package/src/data-structures/queue/deque.ts +84 -77
  27. package/src/data-structures/queue/queue.ts +84 -0
  28. package/src/data-structures/stack/stack.ts +64 -8
  29. package/src/data-structures/trie/trie.ts +53 -0
@@ -143,7 +143,7 @@ export declare class HashMap<K = any, V = any> {
143
143
  * @returns a new HashMap object that contains the key-value pairs from the original HashMap that
144
144
  * satisfy the given predicate function.
145
145
  */
146
- filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V>;
146
+ filter(predicate: (element: [K, V], index: number, map: HashMap<K, V>) => boolean): HashMap<K, V>;
147
147
  /**
148
148
  * The `map` function takes a callback function and returns a new HashMap with the values transformed
149
149
  * by the callback.
@@ -151,7 +151,7 @@ export declare class HashMap<K = any, V = any> {
151
151
  * `map`.
152
152
  * @returns a new HashMap object with the values mapped according to the provided callback function.
153
153
  */
154
- map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV>;
154
+ map<NV>(callback: (element: [K, V], index: number, map: HashMap<K, V>) => NV): HashMap<K, NV>;
155
155
  /**
156
156
  * The `reduce` function iterates over the elements of a HashMap and applies a callback function to
157
157
  * each element, accumulating a single value.
@@ -164,7 +164,7 @@ export declare class HashMap<K = any, V = any> {
164
164
  * @returns The `reduce` function is returning the final value of the accumulator after iterating
165
165
  * over all the elements in the HashMap and applying the callback function to each element.
166
166
  */
167
- reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A;
167
+ reduce<A>(callback: (accumulator: A, element: [K, V], index: number, map: HashMap<K, V>) => A, initialValue: A): A;
168
168
  /**
169
169
  * Time Complexity: O(n), where n is the number of elements in the HashMap.
170
170
  * Space Complexity: O(1)
@@ -287,10 +287,12 @@ class HashMap {
287
287
  */
288
288
  filter(predicate) {
289
289
  const filteredMap = new HashMap();
290
+ let index = 0;
290
291
  for (const [key, value] of this) {
291
- if (predicate([key, value], this)) {
292
+ if (predicate([key, value], index, this)) {
292
293
  filteredMap.set(key, value);
293
294
  }
295
+ index++;
294
296
  }
295
297
  return filteredMap;
296
298
  }
@@ -303,9 +305,11 @@ class HashMap {
303
305
  */
304
306
  map(callback) {
305
307
  const mappedMap = new HashMap();
308
+ let index = 0;
306
309
  for (const [key, value] of this) {
307
- const newValue = callback([key, value], this);
310
+ const newValue = callback([key, value], index, this);
308
311
  mappedMap.set(key, newValue);
312
+ index++;
309
313
  }
310
314
  return mappedMap;
311
315
  }
@@ -323,8 +327,10 @@ class HashMap {
323
327
  */
324
328
  reduce(callback, initialValue) {
325
329
  let accumulator = initialValue;
326
- for (const element of this) {
327
- accumulator = callback(accumulator, element, this);
330
+ let index = 0;
331
+ for (const entry of this) {
332
+ accumulator = callback(accumulator, entry, index, this);
333
+ index++;
328
334
  }
329
335
  return accumulator;
330
336
  }
@@ -8,11 +8,11 @@
8
8
  export declare class HashTableNode<K, V> {
9
9
  key: K;
10
10
  value: V;
11
- next: HashTableNode<K, V> | null;
11
+ next: HashTableNode<K, V> | undefined;
12
12
  constructor(key: K, value: V);
13
13
  }
14
14
  import { HashFunction } from '../../types';
15
- export declare class HashTable<K, V> {
15
+ export declare class HashTable<K = any, V = any> {
16
16
  protected static readonly DEFAULT_CAPACITY = 16;
17
17
  protected static readonly LOAD_FACTOR = 0.75;
18
18
  constructor(capacity?: number, hashFn?: HashFunction<K>);
@@ -20,8 +20,8 @@ export declare class HashTable<K, V> {
20
20
  get capacity(): number;
21
21
  protected _size: number;
22
22
  get size(): number;
23
- protected _buckets: Array<HashTableNode<K, V> | null>;
24
- get buckets(): Array<HashTableNode<K, V> | null>;
23
+ protected _buckets: Array<HashTableNode<K, V> | undefined>;
24
+ get buckets(): Array<HashTableNode<K, V> | undefined>;
25
25
  protected _hashFn: HashFunction<K>;
26
26
  get hashFn(): HashFunction<K>;
27
27
  /**
@@ -50,6 +50,11 @@ export declare class HashTable<K, V> {
50
50
  * any value.
51
51
  */
52
52
  delete(key: K): void;
53
+ [Symbol.iterator](): Generator<[K, V], void, undefined>;
54
+ forEach(callback: (entry: [K, V], index: number, table: HashTable<K, V>) => void): void;
55
+ filter(predicate: (entry: [K, V], index: number, table: HashTable<K, V>) => boolean): HashTable<K, V>;
56
+ map<T>(callback: (entry: [K, V], index: number, table: HashTable<K, V>) => T): HashTable<K, T>;
57
+ reduce<T>(callback: (accumulator: T, entry: [K, V], index: number, table: HashTable<K, V>) => T, initialValue: T): T;
53
58
  /**
54
59
  * The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
55
60
  * capacity of the data structure.
@@ -12,7 +12,7 @@ class HashTableNode {
12
12
  constructor(key, value) {
13
13
  this.key = key;
14
14
  this.value = value;
15
- this.next = null;
15
+ this.next = undefined;
16
16
  }
17
17
  }
18
18
  exports.HashTableNode = HashTableNode;
@@ -21,7 +21,7 @@ class HashTable {
21
21
  this._hashFn = hashFn || this._defaultHashFn;
22
22
  this._capacity = Math.max(capacity, HashTable.DEFAULT_CAPACITY);
23
23
  this._size = 0;
24
- this._buckets = new Array(this._capacity).fill(null);
24
+ this._buckets = new Array(this._capacity).fill(undefined);
25
25
  }
26
26
  get capacity() {
27
27
  return this._capacity;
@@ -101,7 +101,7 @@ class HashTable {
101
101
  delete(key) {
102
102
  const index = this._hash(key);
103
103
  let currentNode = this._buckets[index];
104
- let prevNode = null;
104
+ let prevNode = undefined;
105
105
  while (currentNode) {
106
106
  if (currentNode.key === key) {
107
107
  if (prevNode) {
@@ -111,13 +111,58 @@ class HashTable {
111
111
  this._buckets[index] = currentNode.next;
112
112
  }
113
113
  this._size--;
114
- currentNode.next = null; // Release memory
114
+ currentNode.next = undefined; // Release memory
115
115
  return;
116
116
  }
117
117
  prevNode = currentNode;
118
118
  currentNode = currentNode.next;
119
119
  }
120
120
  }
121
+ *[Symbol.iterator]() {
122
+ for (const bucket of this._buckets) {
123
+ let currentNode = bucket;
124
+ while (currentNode) {
125
+ yield [currentNode.key, currentNode.value];
126
+ currentNode = currentNode.next;
127
+ }
128
+ }
129
+ }
130
+ forEach(callback) {
131
+ let index = 0;
132
+ for (const entry of this) {
133
+ callback(entry, index, this);
134
+ index++;
135
+ }
136
+ }
137
+ filter(predicate) {
138
+ const newTable = new HashTable();
139
+ let index = 0;
140
+ for (const [key, value] of this) {
141
+ if (predicate([key, value], index, this)) {
142
+ newTable.set(key, value);
143
+ }
144
+ index++;
145
+ }
146
+ return newTable;
147
+ }
148
+ map(callback) {
149
+ const newTable = new HashTable();
150
+ let index = 0;
151
+ for (const [key, value] of this) {
152
+ newTable.set(key, callback([key, value], index, this));
153
+ index++;
154
+ }
155
+ return newTable;
156
+ }
157
+ reduce(callback, initialValue) {
158
+ let accumulator = initialValue;
159
+ let index = 0;
160
+ for (const entry of this) {
161
+ accumulator = callback(accumulator, entry, index, this);
162
+ index++;
163
+ }
164
+ return accumulator;
165
+ }
121
166
  /**
122
167
  * The function `_defaultHashFn` calculates the hash value of a given key and returns the remainder when divided by the
123
168
  * capacity of the data structure.
@@ -208,7 +253,7 @@ class HashTable {
208
253
  */
209
254
  _expand() {
210
255
  const newCapacity = this._capacity * 2;
211
- const newBuckets = new Array(newCapacity).fill(null);
256
+ const newBuckets = new Array(newCapacity).fill(undefined);
212
257
  for (const bucket of this._buckets) {
213
258
  let currentNode = bucket;
214
259
  while (currentNode) {
@@ -147,7 +147,7 @@ export declare class Heap<E = any> {
147
147
  * @param order - Traverse order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
148
148
  * @returns An array containing elements traversed in the specified order.
149
149
  */
150
- dfs(order: DFSOrderPattern): E[];
150
+ dfs(order?: DFSOrderPattern): E[];
151
151
  /**
152
152
  * Time Complexity: O(n)
153
153
  * Space Complexity: O(n)
@@ -195,6 +195,11 @@ export declare class Heap<E = any> {
195
195
  * Fix the entire heap to maintain heap properties.
196
196
  */
197
197
  fix(): void;
198
+ [Symbol.iterator](): Generator<E, void, unknown>;
199
+ forEach(callback: (element: E, index: number, heap: this) => void): void;
200
+ filter(predicate: (element: E, index: number, heap: Heap<E>) => boolean): Heap<E>;
201
+ map<T>(callback: (element: E, index: number, heap: Heap<E>) => T, comparator: Comparator<T>): Heap<T>;
202
+ reduce<T>(callback: (accumulator: T, currentValue: E, currentIndex: number, heap: Heap<E>) => T, initialValue: T): T;
198
203
  /**
199
204
  * Time Complexity: O(log n)
200
205
  * Space Complexity: O(1)
@@ -204,29 +204,30 @@ class Heap {
204
204
  * @param order - Traverse order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
205
205
  * @returns An array containing elements traversed in the specified order.
206
206
  */
207
- dfs(order) {
207
+ dfs(order = 'pre') {
208
208
  const result = [];
209
209
  // Auxiliary recursive function, traverses the binary heap according to the traversal order
210
- const dfsHelper = (index) => {
210
+ const _dfs = (index) => {
211
+ const left = 2 * index + 1, right = left + 1;
211
212
  if (index < this.size) {
212
213
  if (order === 'in') {
213
- dfsHelper(2 * index + 1);
214
+ _dfs(left);
214
215
  result.push(this.elements[index]);
215
- dfsHelper(2 * index + 2);
216
+ _dfs(right);
216
217
  }
217
218
  else if (order === 'pre') {
218
219
  result.push(this.elements[index]);
219
- dfsHelper(2 * index + 1);
220
- dfsHelper(2 * index + 2);
220
+ _dfs(left);
221
+ _dfs(right);
221
222
  }
222
223
  else if (order === 'post') {
223
- dfsHelper(2 * index + 1);
224
- dfsHelper(2 * index + 2);
224
+ _dfs(left);
225
+ _dfs(right);
225
226
  result.push(this.elements[index]);
226
227
  }
227
228
  }
228
229
  };
229
- dfsHelper(0); // Traverse starting from the root node
230
+ _dfs(0); // Traverse starting from the root node
230
231
  return result;
231
232
  }
232
233
  /**
@@ -294,6 +295,47 @@ class Heap {
294
295
  for (let i = Math.floor(this.size / 2); i >= 0; i--)
295
296
  this._sinkDown(i, this.elements.length >> 1);
296
297
  }
298
+ *[Symbol.iterator]() {
299
+ for (const element of this.elements) {
300
+ yield element;
301
+ }
302
+ }
303
+ forEach(callback) {
304
+ let index = 0;
305
+ for (const el of this) {
306
+ callback(el, index, this);
307
+ index++;
308
+ }
309
+ }
310
+ filter(predicate) {
311
+ const filteredHeap = new Heap({ comparator: this.comparator });
312
+ let index = 0;
313
+ for (const el of this) {
314
+ if (predicate(el, index, this)) {
315
+ filteredHeap.push(el);
316
+ }
317
+ index++;
318
+ }
319
+ return filteredHeap;
320
+ }
321
+ map(callback, comparator) {
322
+ const mappedHeap = new Heap({ comparator: comparator });
323
+ let index = 0;
324
+ for (const el of this) {
325
+ mappedHeap.add(callback(el, index, this));
326
+ index++;
327
+ }
328
+ return mappedHeap;
329
+ }
330
+ reduce(callback, initialValue) {
331
+ let accumulator = initialValue;
332
+ let index = 0;
333
+ for (const el of this) {
334
+ accumulator = callback(accumulator, el, index, this);
335
+ index++;
336
+ }
337
+ return accumulator;
338
+ }
297
339
  /**
298
340
  * Time Complexity: O(log n)
299
341
  * Space Complexity: O(1)
@@ -249,6 +249,23 @@ export declare class DoublyLinkedList<E = any> {
249
249
  * insertion fails.
250
250
  */
251
251
  insertBefore(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
252
+ /**
253
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
254
+ * Space Complexity: O(1)
255
+ */
256
+ /**
257
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
258
+ * Space Complexity: O(1)
259
+ *
260
+ * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
261
+ * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
262
+ * after which the new value will be inserted. It can be either the value of the existing node or the existing node
263
+ * itself.
264
+ * @param {E} newValue - The value that you want to insert into the doubly linked list.
265
+ * @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
266
+ * existing value or node is not found in the doubly linked list.
267
+ */
268
+ insertAfter(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
252
269
  /**
253
270
  * Time Complexity: O(n), where n is the number of elements in the linked list.
254
271
  * Space Complexity: O(1)
@@ -279,18 +296,6 @@ export declare class DoublyLinkedList<E = any> {
279
296
  * deleted from the doubly linked list, and `false` if the value or node was not found in the list.
280
297
  */
281
298
  delete(valOrNode: E | DoublyLinkedListNode<E> | null): boolean;
282
- /**
283
- * Time Complexity: O(n), where n is the number of elements in the linked list.
284
- * Space Complexity: O(n)
285
- */
286
- /**
287
- * Time Complexity: O(n), where n is the number of elements in the linked list.
288
- * Space Complexity: O(n)
289
- *
290
- * The `toArray` function converts a linked list into an array.
291
- * @returns The `toArray()` method is returning an array of type `E[]`.
292
- */
293
- toArray(): E[];
294
299
  /**
295
300
  * The function checks if a variable has a length greater than zero and returns a boolean value.
296
301
  * @returns A boolean value is being returned.
@@ -346,6 +351,17 @@ export declare class DoublyLinkedList<E = any> {
346
351
  * the callback function. If no value satisfies the condition, it returns `null`.
347
352
  */
348
353
  findBackward(callback: (value: E) => boolean): E | null;
354
+ /**
355
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
356
+ * Space Complexity: O(1)
357
+ */
358
+ /**
359
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
360
+ * Space Complexity: O(1)
361
+ *
362
+ * The `reverse` function reverses the order of the elements in a doubly linked list.
363
+ */
364
+ reverse(): void;
349
365
  /**
350
366
  * Time Complexity: O(n), where n is the number of elements in the linked list.
351
367
  * Space Complexity: O(n)
@@ -354,21 +370,26 @@ export declare class DoublyLinkedList<E = any> {
354
370
  * Time Complexity: O(n), where n is the number of elements in the linked list.
355
371
  * Space Complexity: O(n)
356
372
  *
357
- * The `toArrayBackward` function converts a doubly linked list into an array in reverse order.
358
- * @returns The `toArrayBackward()` function returns an array of type `E[]`.
373
+ * The `toArray` function converts a linked list into an array.
374
+ * @returns The `toArray()` method is returning an array of type `E[]`.
359
375
  */
360
- toArrayBackward(): E[];
376
+ toArray(): E[];
361
377
  /**
362
378
  * Time Complexity: O(n), where n is the number of elements in the linked list.
363
- * Space Complexity: O(1)
379
+ * Space Complexity: O(n)
364
380
  */
365
381
  /**
366
382
  * Time Complexity: O(n), where n is the number of elements in the linked list.
367
- * Space Complexity: O(1)
383
+ * Space Complexity: O(n)
368
384
  *
369
- * The `reverse` function reverses the order of the elements in a doubly linked list.
385
+ * The `toReversedArray` function converts a doubly linked list into an array in reverse order.
386
+ * @returns The `toReversedArray()` function returns an array of type `E[]`.
370
387
  */
371
- reverse(): void;
388
+ toReversedArray(): E[];
389
+ /**
390
+ * The function returns an iterator that iterates over the values of a linked list.
391
+ */
392
+ [Symbol.iterator](): Generator<E, void, unknown>;
372
393
  /**
373
394
  * Time Complexity: O(n), where n is the number of elements in the linked list.
374
395
  * Space Complexity: O(1)
@@ -382,7 +403,7 @@ export declare class DoublyLinkedList<E = any> {
382
403
  * represents the value of the current node in the linked list, and the index argument represents the index of the
383
404
  * current node in the linked list.
384
405
  */
385
- forEach(callback: (value: E, index: number) => void): void;
406
+ forEach(callback: (value: E, index: number, list: DoublyLinkedList<E>) => void): void;
386
407
  /**
387
408
  * Time Complexity: O(n), where n is the number of elements in the linked list.
388
409
  * Space Complexity: O(n)
@@ -391,14 +412,13 @@ export declare class DoublyLinkedList<E = any> {
391
412
  * Time Complexity: O(n), where n is the number of elements in the linked list.
392
413
  * Space Complexity: O(n)
393
414
  *
394
- * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
395
- * DoublyLinkedList with the transformed values.
396
- * @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
397
- * the original DoublyLinkedList) and returns a value of type U (the type of values that will be stored in the mapped
398
- * DoublyLinkedList).
399
- * @returns The `map` function is returning a new instance of `DoublyLinkedList<U>` that contains the mapped values.
415
+ * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
416
+ * elements that satisfy the given callback function.
417
+ * @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
418
+ * It is used to determine whether a value should be included in the filtered list or not.
419
+ * @returns The filtered list, which is an instance of the DoublyLinkedList class.
400
420
  */
401
- map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
421
+ filter(callback: (value: E, index: number, list: DoublyLinkedList<E>) => boolean): DoublyLinkedList<E>;
402
422
  /**
403
423
  * Time Complexity: O(n), where n is the number of elements in the linked list.
404
424
  * Space Complexity: O(n)
@@ -407,13 +427,14 @@ export declare class DoublyLinkedList<E = any> {
407
427
  * Time Complexity: O(n), where n is the number of elements in the linked list.
408
428
  * Space Complexity: O(n)
409
429
  *
410
- * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
411
- * elements that satisfy the given callback function.
412
- * @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
413
- * It is used to determine whether a value should be included in the filtered list or not.
414
- * @returns The filtered list, which is an instance of the DoublyLinkedList class.
430
+ * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
431
+ * DoublyLinkedList with the transformed values.
432
+ * @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
433
+ * the original DoublyLinkedList) and returns a value of type T (the type of values that will be stored in the mapped
434
+ * DoublyLinkedList).
435
+ * @returns The `map` function is returning a new instance of `DoublyLinkedList<T>` that contains the mapped values.
415
436
  */
416
- filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
437
+ map<T>(callback: (value: E, index: number, list: DoublyLinkedList<E>) => T): DoublyLinkedList<T>;
417
438
  /**
418
439
  * Time Complexity: O(n), where n is the number of elements in the linked list.
419
440
  * Space Complexity: O(n)
@@ -426,31 +447,10 @@ export declare class DoublyLinkedList<E = any> {
426
447
  * single value.
427
448
  * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
428
449
  * used to perform a specific operation on each element of the linked list.
429
- * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
450
+ * @param {T} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
430
451
  * point for the reduction operation.
431
452
  * @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
432
453
  * elements in the linked list.
433
454
  */
434
- reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
435
- /**
436
- * Time Complexity: O(n), where n is the number of elements in the linked list.
437
- * Space Complexity: O(1)
438
- */
439
- /**
440
- * Time Complexity: O(n), where n is the number of elements in the linked list.
441
- * Space Complexity: O(1)
442
- *
443
- * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
444
- * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
445
- * after which the new value will be inserted. It can be either the value of the existing node or the existing node
446
- * itself.
447
- * @param {E} newValue - The value that you want to insert into the doubly linked list.
448
- * @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
449
- * existing value or node is not found in the doubly linked list.
450
- */
451
- insertAfter(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
452
- /**
453
- * The function returns an iterator that iterates over the values of a linked list.
454
- */
455
- [Symbol.iterator](): Generator<E, void, unknown>;
455
+ reduce<T>(callback: (accumulator: T, value: E, index: number, list: DoublyLinkedList<E>) => T, initialValue: T): T;
456
456
  }