doubly-linked-list-typed 1.51.9 → 1.52.1

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 (102) hide show
  1. package/dist/data-structures/base/index.d.ts +2 -1
  2. package/dist/data-structures/base/index.js +2 -1
  3. package/dist/data-structures/base/iterable-element-base.d.ts +171 -0
  4. package/dist/data-structures/base/iterable-element-base.js +225 -0
  5. package/dist/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  6. package/dist/data-structures/base/{iterable-base.js → iterable-entry-base.js} +12 -189
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +13 -13
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +13 -13
  10. package/dist/data-structures/binary-tree/avl-tree.js +6 -6
  11. package/dist/data-structures/binary-tree/binary-tree.d.ts +99 -99
  12. package/dist/data-structures/binary-tree/binary-tree.js +54 -52
  13. package/dist/data-structures/binary-tree/bst.d.ts +37 -45
  14. package/dist/data-structures/binary-tree/bst.js +17 -25
  15. package/dist/data-structures/binary-tree/rb-tree.d.ts +10 -10
  16. package/dist/data-structures/binary-tree/rb-tree.js +6 -6
  17. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
  18. package/dist/data-structures/binary-tree/tree-multi-map.js +5 -5
  19. package/dist/data-structures/graph/directed-graph.js +2 -1
  20. package/dist/data-structures/hash/hash-map.d.ts +2 -2
  21. package/dist/data-structures/heap/heap.d.ts +43 -114
  22. package/dist/data-structures/heap/heap.js +59 -127
  23. package/dist/data-structures/heap/max-heap.d.ts +50 -4
  24. package/dist/data-structures/heap/max-heap.js +76 -10
  25. package/dist/data-structures/heap/min-heap.d.ts +51 -5
  26. package/dist/data-structures/heap/min-heap.js +68 -11
  27. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  28. package/dist/data-structures/linked-list/doubly-linked-list.js +26 -28
  29. package/dist/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  30. package/dist/data-structures/linked-list/singly-linked-list.js +29 -26
  31. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  32. package/dist/data-structures/priority-queue/max-priority-queue.js +79 -10
  33. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  34. package/dist/data-structures/priority-queue/min-priority-queue.js +71 -11
  35. package/dist/data-structures/priority-queue/priority-queue.d.ts +50 -4
  36. package/dist/data-structures/priority-queue/priority-queue.js +70 -1
  37. package/dist/data-structures/queue/deque.d.ts +27 -18
  38. package/dist/data-structures/queue/deque.js +43 -21
  39. package/dist/data-structures/queue/queue.d.ts +8 -29
  40. package/dist/data-structures/queue/queue.js +15 -32
  41. package/dist/data-structures/stack/stack.d.ts +17 -22
  42. package/dist/data-structures/stack/stack.js +25 -24
  43. package/dist/data-structures/trie/trie.d.ts +18 -13
  44. package/dist/data-structures/trie/trie.js +26 -15
  45. package/dist/interfaces/binary-tree.d.ts +4 -4
  46. package/dist/types/common.d.ts +1 -22
  47. package/dist/types/data-structures/base/base.d.ts +5 -2
  48. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  49. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  50. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +20 -4
  51. package/dist/types/data-structures/binary-tree/bst.d.ts +5 -3
  52. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +2 -3
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -3
  54. package/dist/types/data-structures/heap/heap.d.ts +3 -2
  55. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  56. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  57. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  58. package/dist/types/data-structures/queue/deque.d.ts +4 -2
  59. package/dist/types/data-structures/queue/queue.d.ts +2 -1
  60. package/dist/types/data-structures/stack/stack.d.ts +2 -1
  61. package/dist/types/data-structures/trie/trie.d.ts +3 -2
  62. package/package.json +2 -2
  63. package/src/data-structures/base/index.ts +2 -1
  64. package/src/data-structures/base/iterable-element-base.ts +250 -0
  65. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  66. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +14 -15
  67. package/src/data-structures/binary-tree/avl-tree.ts +13 -14
  68. package/src/data-structures/binary-tree/binary-tree.ts +156 -152
  69. package/src/data-structures/binary-tree/bst.ts +52 -60
  70. package/src/data-structures/binary-tree/rb-tree.ts +12 -13
  71. package/src/data-structures/binary-tree/tree-multi-map.ts +12 -13
  72. package/src/data-structures/graph/directed-graph.ts +2 -1
  73. package/src/data-structures/hash/hash-map.ts +4 -4
  74. package/src/data-structures/heap/heap.ts +71 -152
  75. package/src/data-structures/heap/max-heap.ts +88 -13
  76. package/src/data-structures/heap/min-heap.ts +78 -15
  77. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  78. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  79. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  80. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  81. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  82. package/src/data-structures/queue/deque.ts +50 -25
  83. package/src/data-structures/queue/queue.ts +23 -37
  84. package/src/data-structures/stack/stack.ts +31 -26
  85. package/src/data-structures/trie/trie.ts +33 -18
  86. package/src/interfaces/binary-tree.ts +4 -5
  87. package/src/types/common.ts +2 -24
  88. package/src/types/data-structures/base/base.ts +14 -6
  89. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -3
  90. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -3
  91. package/src/types/data-structures/binary-tree/binary-tree.ts +24 -5
  92. package/src/types/data-structures/binary-tree/bst.ts +9 -3
  93. package/src/types/data-structures/binary-tree/rb-tree.ts +2 -3
  94. package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -3
  95. package/src/types/data-structures/heap/heap.ts +4 -1
  96. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  97. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  98. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  99. package/src/types/data-structures/queue/deque.ts +6 -1
  100. package/src/types/data-structures/queue/queue.ts +3 -1
  101. package/src/types/data-structures/stack/stack.ts +3 -1
  102. package/src/types/data-structures/trie/trie.ts +3 -1
@@ -13,19 +13,17 @@ const linked_list_1 = require("../linked-list");
13
13
  * 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
14
14
  */
15
15
  class Queue extends base_1.IterableElementBase {
16
- /**
17
- * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
18
- * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
19
- * will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
20
- * initialized as an empty array.
21
- */
22
- constructor(elements = []) {
23
- super();
16
+ constructor(elements = [], options) {
17
+ super(options);
24
18
  this._elements = [];
25
19
  this._offset = 0;
26
20
  if (elements) {
27
- for (const el of elements)
28
- this.push(el);
21
+ for (const el of elements) {
22
+ if (this.toElementFn)
23
+ this.push(this.toElementFn(el));
24
+ else
25
+ this.push(el);
26
+ }
29
27
  }
30
28
  }
31
29
  /**
@@ -89,7 +87,6 @@ class Queue extends base_1.IterableElementBase {
89
87
  *
90
88
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
91
89
  * @public
92
- * @static
93
90
  * @param {E[]} elements - The "elements" parameter is an array of elements of type E.
94
91
  * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
95
92
  * array.
@@ -167,7 +164,7 @@ class Queue extends base_1.IterableElementBase {
167
164
  * @param index
168
165
  */
169
166
  at(index) {
170
- return this.elements[index];
167
+ return this.elements[index + this._offset];
171
168
  }
172
169
  /**
173
170
  * Time Complexity: O(1)
@@ -224,7 +221,7 @@ class Queue extends base_1.IterableElementBase {
224
221
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
225
222
  */
226
223
  clone() {
227
- return new Queue(this.elements.slice(this.offset));
224
+ return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
228
225
  }
229
226
  /**
230
227
  * Time Complexity: O(n)
@@ -247,7 +244,7 @@ class Queue extends base_1.IterableElementBase {
247
244
  * satisfy the given predicate function.
248
245
  */
249
246
  filter(predicate, thisArg) {
250
- const newDeque = new Queue([]);
247
+ const newDeque = new Queue([], { toElementFn: this.toElementFn });
251
248
  let index = 0;
252
249
  for (const el of this) {
253
250
  if (predicate.call(thisArg, el, index, this)) {
@@ -261,22 +258,8 @@ class Queue extends base_1.IterableElementBase {
261
258
  * Time Complexity: O(n)
262
259
  * Space Complexity: O(n)
263
260
  */
264
- /**
265
- * Time Complexity: O(n)
266
- * Space Complexity: O(n)
267
- *
268
- * The `map` function takes a callback function and applies it to each element in the queue,
269
- * returning a new queue with the results.
270
- * @param callback - The callback parameter is a function that will be called for each element in the
271
- * queue. It takes three arguments: the current element, the index of the current element, and the
272
- * queue itself. The callback function should return a new value that will be added to the new queue.
273
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
274
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
275
- * passed as the `this` value to the `callback` function. If `thisArg` is
276
- * @returns The `map` function is returning a new `Queue` object with the transformed elements.
277
- */
278
- map(callback, thisArg) {
279
- const newDeque = new Queue([]);
261
+ map(callback, toElementFn, thisArg) {
262
+ const newDeque = new Queue([], { toElementFn });
280
263
  let index = 0;
281
264
  for (const el of this) {
282
265
  newDeque.push(callback.call(thisArg, el, index, this));
@@ -295,7 +278,7 @@ class Queue extends base_1.IterableElementBase {
295
278
  * The function `_getIterator` returns an iterable iterator for the elements in the class.
296
279
  */
297
280
  *_getIterator() {
298
- for (const item of this.elements) {
281
+ for (const item of this.elements.slice(this.offset)) {
299
282
  yield item;
300
283
  }
301
284
  }
@@ -321,7 +304,7 @@ class LinkedListQueue extends linked_list_1.SinglyLinkedList {
321
304
  * values as the original `LinkedListQueue`.
322
305
  */
323
306
  clone() {
324
- return new LinkedListQueue(this.values());
307
+ return new LinkedListQueue(this, { toElementFn: this.toElementFn });
325
308
  }
326
309
  }
327
310
  exports.LinkedListQueue = LinkedListQueue;
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { ElementCallback } from '../../types';
8
+ import type { ElementCallback, StackOptions } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
10
  /**
11
11
  * 1. Last In, First Out (LIFO): The core characteristic of a stack is its last in, first out nature, meaning the last element added to the stack will be the first to be removed.
@@ -15,14 +15,8 @@ import { IterableElementBase } from '../base';
15
15
  * 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
16
16
  * 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
17
17
  */
18
- export declare class Stack<E = any> extends IterableElementBase<E> {
19
- /**
20
- * The constructor initializes an array of elements, which can be provided as an optional parameter.
21
- * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
22
- * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
23
- * is provided and is an array, it is assigned to the `_elements
24
- */
25
- constructor(elements?: Iterable<E>);
18
+ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E, R>> {
19
+ constructor(elements?: Iterable<E> | Iterable<R>, options?: StackOptions<E, R>);
26
20
  protected _elements: E[];
27
21
  /**
28
22
  * The elements function returns the elements of this set.
@@ -137,7 +131,7 @@ export declare class Stack<E = any> extends IterableElementBase<E> {
137
131
  * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
138
132
  * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
139
133
  */
140
- clone(): Stack<E>;
134
+ clone(): Stack<E, R>;
141
135
  /**
142
136
  * Time Complexity: O(n)
143
137
  * Space Complexity: O(n)
@@ -158,25 +152,26 @@ export declare class Stack<E = any> extends IterableElementBase<E> {
158
152
  * @returns The `filter` method is returning a new `Stack` object that contains the elements that
159
153
  * satisfy the given predicate function.
160
154
  */
161
- filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Stack<E>;
155
+ filter(predicate: ElementCallback<E, R, boolean, Stack<E, R>>, thisArg?: any): Stack<E, R>;
162
156
  /**
163
157
  * Time Complexity: O(n)
164
158
  * Space Complexity: O(n)
165
159
  */
166
160
  /**
167
- * Time Complexity: O(n)
168
- * Space Complexity: O(n)
169
- *
170
161
  * The `map` function takes a callback function and applies it to each element in the stack,
171
162
  * returning a new stack with the results.
172
- * @param callback - The `callback` parameter is a function that will be called for each element in
173
- * the stack. It takes three arguments:
174
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
175
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
176
- * passed as the `this` value to the `callback` function. If `thisArg` is
177
- * @returns The `map` method is returning a new `Stack` object.
178
- */
179
- map<T>(callback: ElementCallback<E, T>, thisArg?: any): Stack<T>;
163
+ * @param callback - The callback parameter is a function that will be called for each element in the
164
+ * stack. It takes three arguments: the current element, the index of the element, and the stack
165
+ * itself. It should return a new value that will be added to the new stack.
166
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
167
+ * transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
168
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
169
+ * specify the value of `this` within the callback function. It is used to set the context or scope
170
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
171
+ * value of
172
+ * @returns a new Stack object with elements of type EM and raw elements of type RM.
173
+ */
174
+ map<EM, RM>(callback: ElementCallback<E, R, EM, Stack<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Stack<EM, RM>;
180
175
  /**
181
176
  * Time Complexity: O(n)
182
177
  * Space Complexity: O(n)
@@ -11,18 +11,18 @@ const base_1 = require("../base");
11
11
  * 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
12
12
  */
13
13
  class Stack extends base_1.IterableElementBase {
14
- /**
15
- * The constructor initializes an array of elements, which can be provided as an optional parameter.
16
- * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
17
- * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
18
- * is provided and is an array, it is assigned to the `_elements
19
- */
20
- constructor(elements = []) {
21
- super();
14
+ constructor(elements = [], options) {
15
+ super(options);
22
16
  this._elements = [];
23
17
  if (elements) {
24
- for (const el of elements)
25
- this.push(el);
18
+ for (const el of elements) {
19
+ if (this.toElementFn) {
20
+ this.push(this.toElementFn(el));
21
+ }
22
+ else {
23
+ this.push(el);
24
+ }
25
+ }
26
26
  }
27
27
  }
28
28
  /**
@@ -168,7 +168,7 @@ class Stack extends base_1.IterableElementBase {
168
168
  * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
169
169
  */
170
170
  clone() {
171
- return new Stack(this.elements.slice());
171
+ return new Stack(this, { toElementFn: this.toElementFn });
172
172
  }
173
173
  /**
174
174
  * Time Complexity: O(n)
@@ -191,7 +191,7 @@ class Stack extends base_1.IterableElementBase {
191
191
  * satisfy the given predicate function.
192
192
  */
193
193
  filter(predicate, thisArg) {
194
- const newStack = new Stack();
194
+ const newStack = new Stack([], { toElementFn: this.toElementFn });
195
195
  let index = 0;
196
196
  for (const el of this) {
197
197
  if (predicate.call(thisArg, el, index, this)) {
@@ -206,20 +206,21 @@ class Stack extends base_1.IterableElementBase {
206
206
  * Space Complexity: O(n)
207
207
  */
208
208
  /**
209
- * Time Complexity: O(n)
210
- * Space Complexity: O(n)
211
- *
212
209
  * The `map` function takes a callback function and applies it to each element in the stack,
213
210
  * returning a new stack with the results.
214
- * @param callback - The `callback` parameter is a function that will be called for each element in
215
- * the stack. It takes three arguments:
216
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
217
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
218
- * passed as the `this` value to the `callback` function. If `thisArg` is
219
- * @returns The `map` method is returning a new `Stack` object.
220
- */
221
- map(callback, thisArg) {
222
- const newStack = new Stack();
211
+ * @param callback - The callback parameter is a function that will be called for each element in the
212
+ * stack. It takes three arguments: the current element, the index of the element, and the stack
213
+ * itself. It should return a new value that will be added to the new stack.
214
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
215
+ * transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
216
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
217
+ * specify the value of `this` within the callback function. It is used to set the context or scope
218
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
219
+ * value of
220
+ * @returns a new Stack object with elements of type EM and raw elements of type RM.
221
+ */
222
+ map(callback, toElementFn, thisArg) {
223
+ const newStack = new Stack([], { toElementFn });
223
224
  let index = 0;
224
225
  for (const el of this) {
225
226
  newStack.push(callback.call(thisArg, el, index, this));
@@ -66,14 +66,14 @@ export declare class TrieNode {
66
66
  * 10. IP Routing: Used in certain types of IP routing algorithms.
67
67
  * 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data.
68
68
  */
69
- export declare class Trie extends IterableElementBase<string, Trie> {
69
+ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
70
70
  /**
71
71
  * The constructor function for the Trie class.
72
72
  * @param words: Iterable string Initialize the trie with a set of words
73
73
  * @param options?: TrieOptions Allow the user to pass in options for the trie
74
74
  * @return This
75
75
  */
76
- constructor(words?: Iterable<string>, options?: TrieOptions);
76
+ constructor(words?: Iterable<string> | Iterable<R>, options?: TrieOptions<R>);
77
77
  protected _size: number;
78
78
  /**
79
79
  * The size function returns the size of the stack.
@@ -243,7 +243,7 @@ export declare class Trie extends IterableElementBase<string, Trie> {
243
243
  * sensitivity as the original Trie.
244
244
  * @returns A new instance of the Trie class is being returned.
245
245
  */
246
- clone(): Trie;
246
+ clone(): Trie<R>;
247
247
  /**
248
248
  * Time Complexity: O(n)
249
249
  * Space Complexity: O(n)
@@ -262,7 +262,7 @@ export declare class Trie extends IterableElementBase<string, Trie> {
262
262
  * specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
263
263
  * @returns The `filter` method is returning an array of strings (`string[]`).
264
264
  */
265
- filter(predicate: ElementCallback<string, boolean>, thisArg?: any): Trie;
265
+ filter(predicate: ElementCallback<string, R, boolean, Trie<R>>, thisArg?: any): Trie<R>;
266
266
  /**
267
267
  * Time Complexity: O(n)
268
268
  * Space Complexity: O(n)
@@ -271,16 +271,21 @@ export declare class Trie extends IterableElementBase<string, Trie> {
271
271
  * Time Complexity: O(n)
272
272
  * Space Complexity: O(n)
273
273
  *
274
- * The `map` function creates a new Trie by applying a callback function to each element in the Trie.
274
+ * The `map` function creates a new Trie by applying a callback function to each element in the
275
+ * current Trie.
275
276
  * @param callback - The callback parameter is a function that will be called for each element in the
276
- * Trie. It takes three arguments: the current element in the Trie, the index of the current element,
277
- * and the Trie itself. The callback function should return a new value for the element.
278
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
279
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
280
- * passed as the `this` value to the `callback` function. If `thisArg` is
281
- * @returns The `map` function is returning a new Trie object.
282
- */
283
- map(callback: ElementCallback<string, string>, thisArg?: any): Trie;
277
+ * Trie. It takes four arguments:
278
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
279
+ * convert the raw element (`RM`) into a string representation. This can be useful if the raw element
280
+ * is not already a string or if you want to customize how the element is converted into a string. If
281
+ * this parameter is
282
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
283
+ * specify the value of `this` within the callback function. It is used to set the context or scope
284
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
285
+ * value of
286
+ * @returns a new Trie object.
287
+ */
288
+ map<RM>(callback: ElementCallback<string, R, string, Trie<R>>, toElementFn?: (rawElement: RM) => string, thisArg?: any): Trie<RM>;
284
289
  /**
285
290
  * Time Complexity: O(n)
286
291
  * Space Complexity: O(n)
@@ -83,7 +83,7 @@ class Trie extends base_1.IterableElementBase {
83
83
  * @return This
84
84
  */
85
85
  constructor(words = [], options) {
86
- super();
86
+ super(options);
87
87
  this._size = 0;
88
88
  this._caseSensitive = true;
89
89
  this._root = new TrieNode('');
@@ -93,8 +93,14 @@ class Trie extends base_1.IterableElementBase {
93
93
  this._caseSensitive = caseSensitive;
94
94
  }
95
95
  if (words) {
96
- for (const word of words)
97
- this.add(word);
96
+ for (const word of words) {
97
+ if (this.toElementFn) {
98
+ this.add(this.toElementFn(word));
99
+ }
100
+ else {
101
+ this.add(word);
102
+ }
103
+ }
98
104
  }
99
105
  }
100
106
  /**
@@ -433,7 +439,7 @@ class Trie extends base_1.IterableElementBase {
433
439
  * @returns A new instance of the Trie class is being returned.
434
440
  */
435
441
  clone() {
436
- return new Trie(this.values(), { caseSensitive: this.caseSensitive });
442
+ return new Trie(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
437
443
  }
438
444
  /**
439
445
  * Time Complexity: O(n)
@@ -454,7 +460,7 @@ class Trie extends base_1.IterableElementBase {
454
460
  * @returns The `filter` method is returning an array of strings (`string[]`).
455
461
  */
456
462
  filter(predicate, thisArg) {
457
- const results = new Trie();
463
+ const results = new Trie([], { toElementFn: this.toElementFn, caseSensitive: this.caseSensitive });
458
464
  let index = 0;
459
465
  for (const word of this) {
460
466
  if (predicate.call(thisArg, word, index, this)) {
@@ -472,17 +478,22 @@ class Trie extends base_1.IterableElementBase {
472
478
  * Time Complexity: O(n)
473
479
  * Space Complexity: O(n)
474
480
  *
475
- * The `map` function creates a new Trie by applying a callback function to each element in the Trie.
481
+ * The `map` function creates a new Trie by applying a callback function to each element in the
482
+ * current Trie.
476
483
  * @param callback - The callback parameter is a function that will be called for each element in the
477
- * Trie. It takes three arguments: the current element in the Trie, the index of the current element,
478
- * and the Trie itself. The callback function should return a new value for the element.
479
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
480
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
481
- * passed as the `this` value to the `callback` function. If `thisArg` is
482
- * @returns The `map` function is returning a new Trie object.
483
- */
484
- map(callback, thisArg) {
485
- const newTrie = new Trie();
484
+ * Trie. It takes four arguments:
485
+ * @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
486
+ * convert the raw element (`RM`) into a string representation. This can be useful if the raw element
487
+ * is not already a string or if you want to customize how the element is converted into a string. If
488
+ * this parameter is
489
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
490
+ * specify the value of `this` within the callback function. It is used to set the context or scope
491
+ * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
492
+ * value of
493
+ * @returns a new Trie object.
494
+ */
495
+ map(callback, toElementFn, thisArg) {
496
+ const newTrie = new Trie([], { toElementFn, caseSensitive: this.caseSensitive });
486
497
  let index = 0;
487
498
  for (const word of this) {
488
499
  newTrie.add(callback.call(thisArg, word, index, this));
@@ -1,9 +1,9 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, Comparable, KeyOrNodeOrEntry } from '../types';
3
- export interface IBinaryTree<K extends Comparable, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
2
+ import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNKeyOrNodeOrEntry } from '../types';
3
+ export interface IBinaryTree<K = any, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
4
4
  createNode(key: K, value?: NODE['value']): NODE;
5
5
  createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
6
- add(keyOrNodeOrEntryOrRawElement: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
7
- addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
6
+ add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
7
+ addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
8
  delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
9
9
  }
@@ -1,36 +1,15 @@
1
1
  export type CP = 1 | -1 | 0;
2
- /**
3
- * Enum representing different loop types.
4
- *
5
- * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
6
- * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
7
- */
8
2
  export type IterationType = 'ITERATIVE' | 'RECURSIVE';
9
3
  export type FamilyPosition = 'ROOT' | 'LEFT' | 'RIGHT' | 'ROOT_LEFT' | 'ROOT_RIGHT' | 'ISOLATED' | 'MAL_NODE';
10
4
  export type Comparator<K> = (a: K, b: K) => number;
11
5
  export type DFSOrderPattern = 'PRE' | 'IN' | 'POST';
12
6
  export type NodeDisplayLayout = [string[], number, number, number];
13
- export type BTNCallback<N, D = any> = (node: N) => D;
14
7
  export interface IterableWithSize<T> extends Iterable<T> {
15
8
  size: number | ((...args: any[]) => number);
16
9
  }
17
10
  export interface IterableWithLength<T> extends Iterable<T> {
18
11
  length: number | ((...args: any[]) => number);
19
12
  }
13
+ export type OptValue<V> = V | undefined;
20
14
  export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>;
21
- export type BinaryTreePrintOptions = {
22
- isShowUndefined?: boolean;
23
- isShowNull?: boolean;
24
- isShowRedBlackNIL?: boolean;
25
- };
26
- export type BTNEntry<K, V> = [K | null | undefined, V | undefined];
27
- export type BTNKeyOrNode<K, N> = K | null | undefined | N;
28
- export type KeyOrNodeOrEntry<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>;
29
- export type BTNodePureKeyOrNode<K, N> = K | N;
30
- export type BTNPureKeyOrNodeOrEntry<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
31
- export type BSTNKeyOrNode<K, N> = K | undefined | N;
32
- export type BinaryTreeDeleteResult<N> = {
33
- deleted: N | null | undefined;
34
- needBalanced: N | null | undefined;
35
- };
36
15
  export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED';
@@ -1,5 +1,8 @@
1
1
  import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
2
2
  export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
3
- export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
3
+ export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
4
4
  export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
5
- export type ReduceElementCallback<V, R> = (accumulator: R, element: V, index: number, container: IterableElementBase<V>) => R;
5
+ export type ReduceElementCallback<E, R, RT, C> = (accumulator: RT, element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
6
+ export type IterableElementBaseOptions<E, R> = {
7
+ toElementFn?: (rawElement: R) => E;
8
+ };
@@ -1,6 +1,5 @@
1
1
  import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
2
2
  import type { AVLTreeOptions } from './avl-tree';
3
- import { Comparable } from "../../utils";
4
- export type AVLTreeMultiMapNodeNested<K extends Comparable, 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
- export type AVLTreeMultiMapNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
5
  export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
@@ -1,6 +1,5 @@
1
1
  import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
- import { Comparable } from "../../utils";
4
- export type AVLTreeNodeNested<K extends Comparable, 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
- export type AVLTreeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
5
  export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,9 +1,25 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
- import { BTNEntry, IterationType } from '../../common';
3
- import { Comparable } from '../../utils';
4
- export type BinaryTreeNodeNested<K extends Comparable, 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 BinaryTreeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
2
+ import { IterationType, OptValue } from '../../common';
3
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
5
  export type BinaryTreeOptions<K, V, R> = {
7
6
  iterationType?: IterationType;
8
7
  toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
9
8
  };
9
+ export type BinaryTreePrintOptions = {
10
+ isShowUndefined?: boolean;
11
+ isShowNull?: boolean;
12
+ isShowRedBlackNIL?: boolean;
13
+ };
14
+ export type OptBTNOrNull<NODE> = NODE | null | undefined;
15
+ export type OptBTNKeyOrNull<K> = K | null | undefined;
16
+ export type BTNEntry<K, V> = [OptBTNKeyOrNull<K>, OptValue<V>];
17
+ export type BTNKeyOrNode<K, NODE> = OptBTNKeyOrNull<K> | NODE;
18
+ export type BTNKeyOrNodeOrEntry<K, V, NODE> = BTNEntry<K, V> | BTNKeyOrNode<K, NODE>;
19
+ export type BTNPureKeyOrNode<K, NODE> = K | NODE;
20
+ export type BTNPureKeyOrNodeOrEntry<K, V, NODE> = [K, OptValue<V>] | BTNPureKeyOrNode<K, NODE>;
21
+ export type BinaryTreeDeleteResult<NODE> = {
22
+ deleted: OptBTNOrNull<NODE>;
23
+ needBalanced: OptBTNOrNull<NODE>;
24
+ };
25
+ export type BTNCallback<NODE, D = any> = (node: NODE) => D;
@@ -1,9 +1,11 @@
1
1
  import { BST, BSTNode } from '../../../data-structures';
2
2
  import type { BinaryTreeOptions } from './binary-tree';
3
3
  import { Comparator } from '../../common';
4
- import { Comparable } from '../../utils';
5
- export type BSTNodeNested<K extends Comparable, 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
- export type BSTNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
7
6
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
8
7
  comparator?: Comparator<K>;
9
8
  };
9
+ export type OptBSTNKey<K> = K | undefined;
10
+ export type OptBSTN<NODE> = NODE | undefined;
11
+ export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE;
@@ -1,7 +1,6 @@
1
1
  import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
2
2
  import type { BSTOptions } from "./bst";
3
- import { Comparable } from "../../utils";
4
3
  export type RBTNColor = 'RED' | 'BLACK';
5
- export type RedBlackTreeNodeNested<K extends Comparable, 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 RedBlackTreeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
7
6
  export type RBTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};