min-heap-typed 1.53.7 → 1.53.9

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 (68) hide show
  1. package/dist/common/index.js +5 -0
  2. package/dist/data-structures/base/iterable-entry-base.js +4 -4
  3. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  4. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +65 -36
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +12 -8
  6. package/dist/data-structures/binary-tree/avl-tree.js +19 -6
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +53 -40
  8. package/dist/data-structures/binary-tree/binary-tree.js +76 -72
  9. package/dist/data-structures/binary-tree/bst.d.ts +87 -52
  10. package/dist/data-structures/binary-tree/bst.js +111 -63
  11. package/dist/data-structures/binary-tree/index.d.ts +1 -1
  12. package/dist/data-structures/binary-tree/index.js +1 -1
  13. package/dist/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +83 -10
  14. package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +91 -44
  15. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +34 -18
  16. package/dist/data-structures/binary-tree/tree-multi-map.js +66 -40
  17. package/dist/data-structures/graph/abstract-graph.js +2 -2
  18. package/dist/data-structures/hash/hash-map.d.ts +31 -1
  19. package/dist/data-structures/hash/hash-map.js +35 -5
  20. package/dist/data-structures/heap/heap.d.ts +20 -3
  21. package/dist/data-structures/heap/heap.js +31 -11
  22. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  23. package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
  24. package/dist/data-structures/linked-list/singly-linked-list.d.ts +44 -11
  25. package/dist/data-structures/linked-list/singly-linked-list.js +70 -26
  26. package/dist/data-structures/queue/deque.d.ts +37 -8
  27. package/dist/data-structures/queue/deque.js +73 -29
  28. package/dist/data-structures/queue/queue.d.ts +41 -1
  29. package/dist/data-structures/queue/queue.js +51 -9
  30. package/dist/data-structures/stack/stack.d.ts +27 -10
  31. package/dist/data-structures/stack/stack.js +39 -20
  32. package/dist/data-structures/trie/trie.d.ts +8 -3
  33. package/dist/data-structures/trie/trie.js +8 -3
  34. package/dist/interfaces/binary-tree.d.ts +3 -4
  35. package/dist/types/data-structures/base/base.d.ts +1 -1
  36. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  37. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  38. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  39. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -4
  40. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  41. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  42. package/package.json +2 -2
  43. package/src/common/index.ts +7 -1
  44. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  45. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +82 -55
  46. package/src/data-structures/binary-tree/avl-tree.ts +32 -15
  47. package/src/data-structures/binary-tree/binary-tree.ts +89 -84
  48. package/src/data-structures/binary-tree/bst.ts +149 -97
  49. package/src/data-structures/binary-tree/index.ts +1 -1
  50. package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +105 -55
  51. package/src/data-structures/binary-tree/tree-multi-map.ts +81 -51
  52. package/src/data-structures/graph/abstract-graph.ts +2 -2
  53. package/src/data-structures/hash/hash-map.ts +37 -7
  54. package/src/data-structures/heap/heap.ts +33 -10
  55. package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
  56. package/src/data-structures/linked-list/singly-linked-list.ts +77 -27
  57. package/src/data-structures/queue/deque.ts +72 -28
  58. package/src/data-structures/queue/queue.ts +50 -7
  59. package/src/data-structures/stack/stack.ts +39 -20
  60. package/src/data-structures/trie/trie.ts +8 -3
  61. package/src/interfaces/binary-tree.ts +3 -13
  62. package/src/types/data-structures/base/base.ts +1 -1
  63. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -4
  64. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -4
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  66. package/src/types/data-structures/binary-tree/bst.ts +3 -5
  67. package/src/types/data-structures/binary-tree/rb-tree.ts +4 -6
  68. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -6
@@ -60,17 +60,12 @@ export class SinglyLinkedListNode<E = any> {
60
60
  }
61
61
 
62
62
  export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R, SinglyLinkedList<E, R>> {
63
- constructor(elements: Iterable<E> | Iterable<R> = [], options?: SinglyLinkedListOptions<E, R>) {
63
+ constructor(
64
+ elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>> = [],
65
+ options?: SinglyLinkedListOptions<E, R>
66
+ ) {
64
67
  super(options);
65
- if (elements) {
66
- for (const el of elements) {
67
- if (this.toElementFn) {
68
- this.push(this.toElementFn(el as R));
69
- } else {
70
- this.push(el as E);
71
- }
72
- }
73
- }
68
+ this.pushMany(elements);
74
69
  }
75
70
 
76
71
  protected _head: SinglyLinkedListNode<E> | undefined;
@@ -121,6 +116,23 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
121
116
  return this._size;
122
117
  }
123
118
 
119
+ /**
120
+ * Time Complexity: O(n)
121
+ * Space Complexity: O(n)
122
+ *
123
+ * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
124
+ * array.
125
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
126
+ * @returns The `fromArray` function returns a `SinglyLinkedList` object.
127
+ */
128
+ static fromArray<E>(data: E[]) {
129
+ const singlyLinkedList = new SinglyLinkedList<E>();
130
+ for (const item of data) {
131
+ singlyLinkedList.push(item);
132
+ }
133
+ return singlyLinkedList;
134
+ }
135
+
124
136
  /**
125
137
  * Time Complexity: O(1)
126
138
  * Space Complexity: O(1)
@@ -211,6 +223,55 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
211
223
  return true;
212
224
  }
213
225
 
226
+ /**
227
+ * Time Complexity: O(k)
228
+ * Space Complexity: O(k)
229
+ *
230
+ * The function `pushMany` iterates over elements and pushes them into a data structure, applying a
231
+ * transformation function if provided.
232
+ * @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
233
+ * parameter in the `pushMany` function can accept an iterable containing elements of type `E`, `R`,
234
+ * or `SinglyLinkedListNode<E>`.
235
+ * @returns The `pushMany` function returns an array of boolean values indicating whether each
236
+ * element was successfully pushed into the data structure.
237
+ */
238
+ pushMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>) {
239
+ const ans: boolean[] = [];
240
+ for (const el of elements) {
241
+ if (this.toElementFn) {
242
+ ans.push(this.push(this.toElementFn(el as R)));
243
+ continue;
244
+ }
245
+ ans.push(this.push(el as E | SinglyLinkedListNode<E>));
246
+ }
247
+ return ans;
248
+ }
249
+
250
+ /**
251
+ * Time Complexity: O(k)
252
+ * Space Complexity: O(k)
253
+ *
254
+ * The function `unshiftMany` iterates over elements and adds them to a data structure, optionally
255
+ * converting them using a provided function.
256
+ * @param {Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>} elements - The `elements`
257
+ * parameter in the `unshiftMany` function can accept an iterable containing elements of type `E`,
258
+ * `R`, or `SinglyLinkedListNode<E>`. The function iterates over each element in the iterable and
259
+ * performs an `unshift` operation on the linked list for each
260
+ * @returns The `unshiftMany` function is returning an array of boolean values, where each value
261
+ * represents the result of calling the `unshift` method on the current instance of the class.
262
+ */
263
+ unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>) {
264
+ const ans: boolean[] = [];
265
+ for (const el of elements) {
266
+ if (this.toElementFn) {
267
+ ans.push(this.unshift(this.toElementFn(el as R)));
268
+ continue;
269
+ }
270
+ ans.push(this.unshift(el as E | SinglyLinkedListNode<E>));
271
+ }
272
+ return ans;
273
+ }
274
+
214
275
  /**
215
276
  * Time Complexity: O(n)
216
277
  * Space Complexity: O(1)
@@ -399,6 +460,9 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
399
460
  }
400
461
 
401
462
  /**
463
+ * Time Complexity: O(1)
464
+ * Space Complexity: O(1)
465
+ *
402
466
  * The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
403
467
  * whether it is empty or not.
404
468
  * @returns A boolean value indicating whether the length of the object is equal to 0.
@@ -408,6 +472,9 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
408
472
  }
409
473
 
410
474
  /**
475
+ * Time Complexity: O(1)
476
+ * Space Complexity: O(1)
477
+ *
411
478
  * The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
412
479
  */
413
480
  clear(): void {
@@ -713,23 +780,6 @@ export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R
713
780
  }
714
781
  }
715
782
 
716
- /**
717
- * Time Complexity: O(n)
718
- * Space Complexity: O(n)
719
- *
720
- * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
721
- * array.
722
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
723
- * @returns The `fromArray` function returns a `SinglyLinkedList` object.
724
- */
725
- static fromArray<E>(data: E[]) {
726
- const singlyLinkedList = new SinglyLinkedList<E>();
727
- for (const item of data) {
728
- singlyLinkedList.push(item);
729
- }
730
- return singlyLinkedList;
731
- }
732
-
733
783
  /**
734
784
  * The _isPredicate function in TypeScript checks if the input is a function that takes a
735
785
  * SinglyLinkedListNode as an argument and returns a boolean.
@@ -53,14 +53,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
53
53
  const needBucketNum = calcMinUnitsRequired(_size, this._bucketSize);
54
54
  this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);
55
55
  this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;
56
-
57
- for (const el of elements) {
58
- if (this.toElementFn) {
59
- this.push(this.toElementFn(el as R));
60
- } else {
61
- this.push(el as E);
62
- }
63
- }
56
+ this.pushMany(elements);
64
57
  }
65
58
 
66
59
  protected _bucketSize: number = 1 << 12;
@@ -230,6 +223,33 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
230
223
  return element;
231
224
  }
232
225
 
226
+ /**
227
+ * Time Complexity: O(1)
228
+ * Space Complexity: O(1)
229
+ *
230
+ * The `shift()` function removes and returns the first element from a data structure, updating the
231
+ * internal state variables accordingly.
232
+ * @returns The element that is being removed from the beginning of the data structure is being
233
+ * returned.
234
+ */
235
+ shift(): E | undefined {
236
+ if (this._size === 0) return;
237
+ const element = this._buckets[this._bucketFirst][this._firstInBucket];
238
+ if (this._size !== 1) {
239
+ if (this._firstInBucket < this._bucketSize - 1) {
240
+ this._firstInBucket += 1;
241
+ } else if (this._bucketFirst < this._bucketCount - 1) {
242
+ this._bucketFirst += 1;
243
+ this._firstInBucket = 0;
244
+ } else {
245
+ this._bucketFirst = 0;
246
+ this._firstInBucket = 0;
247
+ }
248
+ }
249
+ this._size -= 1;
250
+ return element;
251
+ }
252
+
233
253
  /**
234
254
  * Time Complexity: Amortized O(1)
235
255
  * Space Complexity: O(n)
@@ -260,30 +280,54 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
260
280
  }
261
281
 
262
282
  /**
263
- * Time Complexity: O(1)
264
- * Space Complexity: O(1)
283
+ * Time Complexity: O(k)
284
+ * Space Complexity: O(k)
265
285
  *
266
- * The `shift()` function removes and returns the first element from a data structure, updating the
267
- * internal state variables accordingly.
268
- * @returns The element that is being removed from the beginning of the data structure is being
269
- * returned.
270
- */
271
- shift(): E | undefined {
272
- if (this._size === 0) return;
273
- const element = this._buckets[this._bucketFirst][this._firstInBucket];
274
- if (this._size !== 1) {
275
- if (this._firstInBucket < this._bucketSize - 1) {
276
- this._firstInBucket += 1;
277
- } else if (this._bucketFirst < this._bucketCount - 1) {
278
- this._bucketFirst += 1;
279
- this._firstInBucket = 0;
286
+ * The function `pushMany` iterates over elements and pushes them into an array after applying a
287
+ * transformation function if provided.
288
+ * @param {IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>} elements - The `elements`
289
+ * parameter in the `pushMany` function is expected to be an iterable containing elements of type `E`
290
+ * or `R`. It can be either an `IterableWithSizeOrLength<E>` or an `IterableWithSizeOrLength<R>`. The
291
+ * function iterates over each element
292
+ * @returns The `pushMany` function is returning an array of boolean values, where each value
293
+ * represents the result of calling the `push` method on the current object instance with the
294
+ * corresponding element from the input `elements` iterable.
295
+ */
296
+ pushMany(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>) {
297
+ const ans: boolean[] = [];
298
+ for (const el of elements) {
299
+ if (this.toElementFn) {
300
+ ans.push(this.push(this.toElementFn(el as R)));
280
301
  } else {
281
- this._bucketFirst = 0;
282
- this._firstInBucket = 0;
302
+ ans.push(this.push(el as E));
283
303
  }
284
304
  }
285
- this._size -= 1;
286
- return element;
305
+ return ans;
306
+ }
307
+
308
+ /**
309
+ * Time Complexity: O(k)
310
+ * Space Complexity: O(k)
311
+ *
312
+ * The `unshiftMany` function in TypeScript iterates over elements and adds them to the beginning of
313
+ * an array, optionally converting them using a provided function.
314
+ * @param {IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>} elements - The `elements`
315
+ * parameter in the `unshiftMany` function is an iterable containing elements of type `E` or `R`. It
316
+ * can be an array or any other iterable data structure that has a known size or length. The function
317
+ * iterates over each element in the `elements` iterable and
318
+ * @returns The `unshiftMany` function returns an array of boolean values indicating whether each
319
+ * element was successfully added to the beginning of the array.
320
+ */
321
+ unshiftMany(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R> = []) {
322
+ const ans: boolean[] = [];
323
+ for (const el of elements) {
324
+ if (this.toElementFn) {
325
+ ans.push(this.unshift(this.toElementFn(el as R)));
326
+ } else {
327
+ ans.push(this.unshift(el as E));
328
+ }
329
+ }
330
+ return ans;
287
331
  }
288
332
 
289
333
  /**
@@ -25,12 +25,7 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
25
25
  this._autoCompactRatio = autoCompactRatio;
26
26
  }
27
27
 
28
- if (elements) {
29
- for (const el of elements) {
30
- if (this.toElementFn) this.push(this.toElementFn(el as R));
31
- else this.push(el as E);
32
- }
33
- }
28
+ this.pushMany(elements);
34
29
  }
35
30
 
36
31
  protected _elements: E[] = [];
@@ -131,6 +126,26 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
131
126
  return true;
132
127
  }
133
128
 
129
+ /**
130
+ * Time Complexity: O(k)
131
+ * Space Complexity: O(k)
132
+ *
133
+ * The `pushMany` function iterates over elements and pushes them into an array after applying a
134
+ * transformation function if provided.
135
+ * @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
136
+ * is an iterable containing elements of type `E` or `R`.
137
+ * @returns The `pushMany` function is returning an array of boolean values indicating whether each
138
+ * element was successfully pushed into the data structure.
139
+ */
140
+ pushMany(elements: Iterable<E> | Iterable<R>) {
141
+ const ans: boolean[] = [];
142
+ for (const el of elements) {
143
+ if (this.toElementFn) ans.push(this.push(this.toElementFn(el as R)));
144
+ else ans.push(this.push(el as E));
145
+ }
146
+ return ans;
147
+ }
148
+
134
149
  /**
135
150
  * Time Complexity: O(1)
136
151
  * Space Complexity: O(1)
@@ -150,6 +165,9 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
150
165
  }
151
166
 
152
167
  /**
168
+ * Time Complexity: O(n)
169
+ * Space Complexity: O(1)
170
+ *
153
171
  * The delete function removes an element from the list.
154
172
  * @param {E} element - Specify the element to be deleted
155
173
  * @return A boolean value indicating whether the element was successfully deleted or not
@@ -160,6 +178,9 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
160
178
  }
161
179
 
162
180
  /**
181
+ * Time Complexity: O(n)
182
+ * Space Complexity: O(1)
183
+ *
163
184
  * The deleteAt function deletes the element at a given index.
164
185
  * @param {number} index - Determine the index of the element to be deleted
165
186
  * @return A boolean value
@@ -173,7 +194,12 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
173
194
  * Time Complexity: O(1)
174
195
  * Space Complexity: O(1)
175
196
  *
176
- * @param index
197
+ * The `at` function returns the element at a specified index adjusted by an offset, or `undefined`
198
+ * if the index is out of bounds.
199
+ * @param {number} index - The `index` parameter represents the position of the element you want to
200
+ * retrieve from the data structure.
201
+ * @returns The `at` method is returning the element at the specified index adjusted by the offset
202
+ * `_offset`.
177
203
  */
178
204
  at(index: number): E | undefined {
179
205
  return this.elements[index + this._offset];
@@ -213,6 +239,9 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
213
239
  }
214
240
 
215
241
  /**
242
+ * Time Complexity: O(n)
243
+ * Space Complexity: O(1)
244
+ *
216
245
  * The `compact` function in TypeScript slices the elements array based on the offset and resets the
217
246
  * offset to zero.
218
247
  * @returns The `compact()` method is returning a boolean value of `true`.
@@ -265,6 +294,20 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
265
294
  /**
266
295
  * Time Complexity: O(n)
267
296
  * Space Complexity: O(n)
297
+ *
298
+ * The `map` function in TypeScript creates a new Queue by applying a callback function to each
299
+ * element in the original Queue.
300
+ * @param callback - The `callback` parameter is a function that will be applied to each element in
301
+ * the queue. It takes the current element, its index, and the queue itself as arguments, and returns
302
+ * a new element.
303
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be provided to
304
+ * convert a raw element of type `RM` to a new element of type `EM`. This function is used within the
305
+ * `map` method to transform each raw element before passing it to the `callback` function. If
306
+ * @param {any} [thisArg] - The `thisArg` parameter in the `map` function is used to specify the
307
+ * value of `this` when executing the `callback` function. It allows you to set the context (the
308
+ * value of `this`) within the callback function. If `thisArg` is provided, it will be
309
+ * @returns A new Queue object containing elements of type EM, which are the result of applying the
310
+ * callback function to each element in the original Queue object.
268
311
  */
269
312
  map<EM, RM>(
270
313
  callback: ElementCallback<E, R, EM, Queue<E, R>>,
@@ -19,15 +19,7 @@ import { IterableElementBase } from '../base';
19
19
  export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E, R>> {
20
20
  constructor(elements: Iterable<E> | Iterable<R> = [], options?: StackOptions<E, R>) {
21
21
  super(options);
22
- if (elements) {
23
- for (const el of elements) {
24
- if (this.toElementFn) {
25
- this.push(this.toElementFn(el as R));
26
- } else {
27
- this.push(el as E);
28
- }
29
- }
30
- }
22
+ this.pushMany(elements);
31
23
  }
32
24
 
33
25
  protected _elements: E[] = [];
@@ -48,11 +40,6 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
48
40
  return this.elements.length;
49
41
  }
50
42
 
51
- /**
52
- * Time Complexity: O(n)
53
- * Space Complexity: O(n)
54
- */
55
-
56
43
  /**
57
44
  * Time Complexity: O(n)
58
45
  * Space Complexity: O(n)
@@ -67,6 +54,9 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
67
54
  }
68
55
 
69
56
  /**
57
+ * Time Complexity: O(1)
58
+ * Space Complexity: O(1)
59
+ *
70
60
  * The function checks if an array is empty and returns a boolean value.
71
61
  * @returns A boolean value indicating whether the `_elements` array is empty or not.
72
62
  */
@@ -115,9 +105,36 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
115
105
  }
116
106
 
117
107
  /**
118
- * The delete function removes an element from the stack.
119
- * @param element: E Specify the element to be deleted
120
- * @return A boolean value indicating whether the element was successfully deleted or not
108
+ * Time Complexity: O(k)
109
+ * Space Complexity: O(1)
110
+ *
111
+ * The function `pushMany` iterates over elements and pushes them into an array after applying a
112
+ * transformation function if provided.
113
+ * @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
114
+ * is an iterable containing elements of type `E` or `R`. The function iterates over each element in
115
+ * the iterable and pushes it into the data structure. If a transformation function `toElementFn` is
116
+ * provided, it is used to
117
+ * @returns The `pushMany` function is returning an array of boolean values indicating whether each
118
+ * element was successfully pushed into the data structure.
119
+ */
120
+ pushMany(elements: Iterable<E> | Iterable<R>) {
121
+ const ans: boolean[] = [];
122
+ for (const el of elements) {
123
+ if (this.toElementFn) {
124
+ ans.push(this.push(this.toElementFn(el as R)));
125
+ } else {
126
+ ans.push(this.push(el as E));
127
+ }
128
+ }
129
+ return ans;
130
+ }
131
+
132
+ /**
133
+ * Time Complexity: O(n)
134
+ * Space Complexity: O(1)
135
+ *
136
+ * The toArray function returns a copy of the elements in an array.
137
+ * @returns An array of type E.
121
138
  */
122
139
  delete(element: E): boolean {
123
140
  const index = this.elements.indexOf(element);
@@ -125,9 +142,11 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E,
125
142
  }
126
143
 
127
144
  /**
128
- * The deleteAt function deletes the element at a given index.
129
- * @param index: number Determine the index of the element to be deleted
130
- * @return A boolean value
145
+ * Time Complexity: O(n)
146
+ * Space Complexity: O(1)
147
+ *
148
+ * The toArray function returns a copy of the elements in an array.
149
+ * @returns An array of type E.
131
150
  */
132
151
  deleteAt(index: number): boolean {
133
152
  const spliced = this.elements.splice(index, 1);
@@ -268,7 +268,7 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
268
268
  * @returns The `addMany` method returns an array of boolean values indicating whether each word in
269
269
  * the input iterable was successfully added to the data structure.
270
270
  */
271
- addMany(words: Iterable<string> | Iterable<R> = []): boolean[] {
271
+ addMany(words: Iterable<string> | Iterable<R>): boolean[] {
272
272
  const ans: boolean[] = [];
273
273
  for (const word of words) {
274
274
  if (this.toElementFn) {
@@ -366,9 +366,14 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
366
366
  }
367
367
 
368
368
  /**
369
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
370
- * Space Complexity: O(1) - Constant space.
369
+ * Time Complexity: O(n)
370
+ * Space Complexity: O(1)
371
371
  *
372
+ * The function `getHeight` calculates the height of a trie data structure starting from the root
373
+ * node.
374
+ * @returns The `getHeight` method returns the maximum depth or height of the trie tree starting from
375
+ * the root node. It calculates the depth using a breadth-first search (BFS) traversal of the trie
376
+ * tree and returns the maximum depth found.
372
377
  */
373
378
  getHeight(): number {
374
379
  const startNode = this.root;
@@ -1,24 +1,14 @@
1
- import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type {
3
- BinaryTreeDeleteResult,
4
- BinaryTreeNested,
5
- BinaryTreeNodeNested,
6
- BinaryTreeOptions,
7
- BTNRep,
8
- NodePredicate
9
- } from '../types';
1
+ import { BinaryTreeNode } from '../data-structures';
2
+ import type { BinaryTreeDeleteResult, BinaryTreeNodeNested, BTNRep, NodePredicate } from '../types';
10
3
 
11
4
  export interface IBinaryTree<
12
5
  K = any,
13
6
  V = any,
14
7
  R = object,
15
- NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>,
16
- TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>
8
+ NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>
17
9
  > {
18
10
  createNode(key: K, value?: NODE['value']): NODE;
19
11
 
20
- createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
21
-
22
12
  add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
23
13
 
24
14
  addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
@@ -1,6 +1,6 @@
1
1
  import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
2
2
 
3
- export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
3
+ export type EntryCallback<K, V, R> = (key: K, value: V, index: number, container: IterableEntryBase<K, V>) => R;
4
4
  export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
5
5
  export type ReduceEntryCallback<K, V, R> = (
6
6
  accumulator: R,
@@ -1,8 +1,6 @@
1
- import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
1
+ import { AVLTreeMultiMapNode } from '../../../data-structures';
2
2
  import type { AVLTreeOptions } from './avl-tree';
3
3
 
4
- export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
-
6
- export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
4
+ export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>
7
5
 
8
6
  export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {}
@@ -1,8 +1,6 @@
1
- import { AVLTree, AVLTreeNode } from '../../../data-structures';
1
+ import { AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
3
 
4
- export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
-
6
- export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
4
+ export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>
7
5
 
8
6
  export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,10 +1,10 @@
1
- import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
1
+ import { BinaryTreeNode } from '../../../data-structures';
2
2
  import { IterationType, OptValue } from '../../common';
3
3
  import { DFSOperation } from '../../../common';
4
4
 
5
- export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
+ export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>
6
6
 
7
- export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
7
+ // export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
8
8
 
9
9
  export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
10
10
 
@@ -1,13 +1,11 @@
1
- import { BST, BSTNode } from '../../../data-structures';
1
+ import { BSTNode } from '../../../data-structures';
2
2
  import type { BinaryTreeOptions } from './binary-tree';
3
3
  import { Comparable } from '../../utils';
4
4
 
5
- export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
6
-
7
- export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
+ export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>
8
6
 
9
7
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
10
- extractComparable?: (key: K) => Comparable
8
+ specifyComparable?: (key: K) => Comparable
11
9
  isReverse?: boolean;
12
10
  }
13
11
 
@@ -1,10 +1,8 @@
1
- import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
2
- import type { BSTOptions } from "./bst";
1
+ import { RedBlackTreeNode } from '../../../data-structures';
2
+ import type { BSTOptions } from './bst';
3
3
 
4
4
  export type RBTNColor = 'RED' | 'BLACK';
5
5
 
6
- export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
6
+ export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>
7
7
 
8
- export type RedBlackTreeNested<K, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
9
-
10
- export type RBTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};
8
+ export type RedBlackTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};