data-structure-typed 1.46.7 → 1.46.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 (69) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +140 -110
  3. package/benchmark/report.html +1 -46
  4. package/benchmark/report.json +11 -422
  5. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +4 -2
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +10 -0
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +19 -13
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +121 -55
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.d.ts +10 -9
  12. package/dist/cjs/data-structures/binary-tree/bst.js +16 -14
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +7 -5
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.js +32 -23
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +5 -3
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +11 -2
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  20. package/dist/cjs/interfaces/binary-tree.d.ts +3 -3
  21. package/dist/cjs/types/common.d.ts +5 -4
  22. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -1
  23. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -1
  24. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -6
  25. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  26. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +2 -1
  27. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -1
  28. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +2 -1
  29. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +4 -2
  30. package/dist/mjs/data-structures/binary-tree/avl-tree.js +11 -0
  31. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +19 -13
  32. package/dist/mjs/data-structures/binary-tree/binary-tree.js +122 -55
  33. package/dist/mjs/data-structures/binary-tree/bst.d.ts +10 -9
  34. package/dist/mjs/data-structures/binary-tree/bst.js +17 -14
  35. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +7 -5
  36. package/dist/mjs/data-structures/binary-tree/rb-tree.js +34 -24
  37. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +5 -3
  38. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +12 -2
  39. package/dist/mjs/interfaces/binary-tree.d.ts +3 -3
  40. package/dist/mjs/types/common.d.ts +5 -4
  41. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -1
  42. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -1
  43. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +0 -6
  44. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +2 -1
  45. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -1
  46. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +2 -1
  47. package/dist/umd/data-structure-typed.js +198 -103
  48. package/dist/umd/data-structure-typed.min.js +4 -1
  49. package/dist/umd/data-structure-typed.min.js.map +1 -1
  50. package/package.json +7 -6
  51. package/src/data-structures/binary-tree/avl-tree.ts +17 -5
  52. package/src/data-structures/binary-tree/binary-tree.ts +143 -62
  53. package/src/data-structures/binary-tree/bst.ts +23 -19
  54. package/src/data-structures/binary-tree/rb-tree.ts +38 -27
  55. package/src/data-structures/binary-tree/tree-multimap.ts +19 -6
  56. package/src/interfaces/binary-tree.ts +3 -3
  57. package/src/types/common.ts +2 -5
  58. package/src/types/data-structures/binary-tree/avl-tree.ts +5 -1
  59. package/src/types/data-structures/binary-tree/binary-tree.ts +5 -7
  60. package/src/types/data-structures/binary-tree/bst.ts +3 -1
  61. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -1
  62. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -1
  63. package/test/integration/index.html +30 -28
  64. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +7 -0
  65. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +57 -1
  66. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +62 -7
  67. package/test/unit/data-structures/binary-tree/bst.test.ts +56 -1
  68. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +98 -42
  69. package/tsconfig-base.json +2 -1
@@ -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 { BSTComparator, BSTNodeNested, BSTOptions, BTNCallback, BTNKey } from '../../types';
8
+ import type { BSTNested, BSTNodeNested, BSTOptions, BTNCallback, BTNKey } from '../../types';
9
9
  import { CP, IterationType } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBinaryTree } from '../../interfaces';
@@ -33,7 +33,8 @@ export declare class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>
33
33
  */
34
34
  set right(v: N | undefined);
35
35
  }
36
- export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>> extends BinaryTree<V, N> implements IBinaryTree<V, N> {
36
+ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>, TREE extends BST<V, N, TREE> = BST<V, N, BSTNested<V, N>>> extends BinaryTree<V, N, TREE> implements IBinaryTree<V, N, TREE> {
37
+ options: BSTOptions;
37
38
  /**
38
39
  * The constructor function initializes a binary search tree with an optional comparator function.
39
40
  * @param {BSTOptions} [options] - An optional object that contains additional configuration options
@@ -54,6 +55,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
54
55
  * @returns a new instance of the BSTNode class with the specified key and value.
55
56
  */
56
57
  createNode(key: BTNKey, value?: V): N;
58
+ createTree(options?: BSTOptions): TREE;
57
59
  /**
58
60
  * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).
59
61
  * Space Complexity: O(1) - Constant space is used.
@@ -95,7 +97,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
95
97
  * current instance of the binary search tree
96
98
  * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
97
99
  */
98
- addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: (V | undefined)[], isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
100
+ addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: (V | undefined)[], isBalanceAdd?: boolean, iterationType?: IterationType | undefined): (N | undefined)[];
99
101
  /**
100
102
  * Time Complexity: O(log n) - Average case for a balanced tree.
101
103
  * Space Complexity: O(1) - Constant space is used.
@@ -115,7 +117,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
115
117
  * the key of the leftmost node if the comparison result is greater than, and the key of the
116
118
  * rightmost node otherwise. If no node is found, it returns 0.
117
119
  */
118
- lastKey(beginRoot?: BTNKey | N | undefined, iterationType?: IterationType): BTNKey;
120
+ lastKey(beginRoot?: BTNKey | N | undefined, iterationType?: IterationType | undefined): BTNKey;
119
121
  /**
120
122
  * Time Complexity: O(log n) - Average case for a balanced tree.
121
123
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -172,7 +174,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
172
174
  * performed on the binary tree. It can have two possible values:
173
175
  * @returns The method returns an array of nodes (`N[]`).
174
176
  */
175
- getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BTNKey | N | undefined, iterationType?: IterationType): N[];
177
+ getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BTNKey | N | undefined, iterationType?: IterationType | undefined): N[];
176
178
  /**
177
179
  * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.
178
180
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -198,7 +200,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
198
200
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
199
201
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
200
202
  */
201
- lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BTNKey | N | undefined, iterationType?: IterationType): ReturnType<C>[];
203
+ lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BTNKey | N | undefined, iterationType?: IterationType | undefined): ReturnType<C>[];
202
204
  /**
203
205
  * Balancing Adjustment:
204
206
  * Perfectly Balanced Binary Tree: Since the balance of a perfectly balanced binary tree is already fixed, no additional balancing adjustment is needed. Any insertion or deletion operation will disrupt the perfect balance, often requiring a complete reconstruction of the tree.
@@ -223,7 +225,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
223
225
  * values:
224
226
  * @returns The function `perfectlyBalance` returns a boolean value.
225
227
  */
226
- perfectlyBalance(iterationType?: IterationType): boolean;
228
+ perfectlyBalance(iterationType?: IterationType | undefined): boolean;
227
229
  /**
228
230
  * Time Complexity: O(n) - Visiting each node once.
229
231
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -237,8 +239,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
237
239
  * to check if the AVL tree is balanced. It can have two possible values:
238
240
  * @returns a boolean value.
239
241
  */
240
- isAVLBalanced(iterationType?: IterationType): boolean;
241
- protected _comparator: BSTComparator;
242
+ isAVLBalanced(iterationType?: IterationType | undefined): boolean;
242
243
  protected _setRoot(v: N | undefined): void;
243
244
  /**
244
245
  * The function compares two values using a comparator function and returns whether the first value
@@ -45,6 +45,7 @@ export class BSTNode extends BinaryTreeNode {
45
45
  }
46
46
  }
47
47
  export class BST extends BinaryTree {
48
+ options;
48
49
  /**
49
50
  * The constructor function initializes a binary search tree with an optional comparator function.
50
51
  * @param {BSTOptions} [options] - An optional object that contains additional configuration options
@@ -52,13 +53,13 @@ export class BST extends BinaryTree {
52
53
  */
53
54
  constructor(options) {
54
55
  super(options);
55
- this._root = undefined;
56
- if (options !== undefined) {
57
- const { comparator } = options;
58
- if (comparator !== undefined) {
59
- this._comparator = comparator;
60
- }
56
+ if (options) {
57
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b, ...options };
58
+ }
59
+ else {
60
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b };
61
61
  }
62
+ this._root = undefined;
62
63
  }
63
64
  _root;
64
65
  /**
@@ -78,6 +79,9 @@ export class BST extends BinaryTree {
78
79
  createNode(key, value) {
79
80
  return new BSTNode(key, value);
80
81
  }
82
+ createTree(options) {
83
+ return new BST({ ...this.options, ...options });
84
+ }
81
85
  /**
82
86
  * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).
83
87
  * Space Complexity: O(1) - Constant space is used.
@@ -195,7 +199,7 @@ export class BST extends BinaryTree {
195
199
  * current instance of the binary search tree
196
200
  * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
197
201
  */
198
- addMany(keysOrNodes, data, isBalanceAdd = true, iterationType = this.iterationType) {
202
+ addMany(keysOrNodes, data, isBalanceAdd = true, iterationType = this.options.iterationType) {
199
203
  // TODO this addMany function is inefficient, it should be optimized
200
204
  function hasNoUndefined(arr) {
201
205
  return arr.indexOf(undefined) === -1;
@@ -283,7 +287,7 @@ export class BST extends BinaryTree {
283
287
  * the key of the leftmost node if the comparison result is greater than, and the key of the
284
288
  * rightmost node otherwise. If no node is found, it returns 0.
285
289
  */
286
- lastKey(beginRoot = this.root, iterationType = this.iterationType) {
290
+ lastKey(beginRoot = this.root, iterationType = this.options.iterationType) {
287
291
  if (this._compare(0, 1) === CP.lt)
288
292
  return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
289
293
  else if (this._compare(0, 1) === CP.gt)
@@ -379,7 +383,7 @@ export class BST extends BinaryTree {
379
383
  * performed on the binary tree. It can have two possible values:
380
384
  * @returns The method returns an array of nodes (`N[]`).
381
385
  */
382
- getNodes(identifier, callback = this._defaultOneParamCallback, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
386
+ getNodes(identifier, callback = this._defaultOneParamCallback, onlyOne = false, beginRoot = this.root, iterationType = this.options.iterationType) {
383
387
  beginRoot = this.ensureNotKey(beginRoot);
384
388
  if (!beginRoot)
385
389
  return [];
@@ -460,7 +464,7 @@ export class BST extends BinaryTree {
460
464
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
461
465
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
462
466
  */
463
- lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = CP.lt, targetNode = this.root, iterationType = this.iterationType) {
467
+ lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = CP.lt, targetNode = this.root, iterationType = this.options.iterationType) {
464
468
  targetNode = this.ensureNotKey(targetNode);
465
469
  const ans = [];
466
470
  if (!targetNode)
@@ -524,7 +528,7 @@ export class BST extends BinaryTree {
524
528
  * values:
525
529
  * @returns The function `perfectlyBalance` returns a boolean value.
526
530
  */
527
- perfectlyBalance(iterationType = this.iterationType) {
531
+ perfectlyBalance(iterationType = this.options.iterationType) {
528
532
  const sorted = this.dfs(node => node, 'in'), n = sorted.length;
529
533
  this.clear();
530
534
  if (sorted.length < 1)
@@ -574,7 +578,7 @@ export class BST extends BinaryTree {
574
578
  * to check if the AVL tree is balanced. It can have two possible values:
575
579
  * @returns a boolean value.
576
580
  */
577
- isAVLBalanced(iterationType = this.iterationType) {
581
+ isAVLBalanced(iterationType = this.options.iterationType) {
578
582
  if (!this.root)
579
583
  return true;
580
584
  let balanced = true;
@@ -619,7 +623,6 @@ export class BST extends BinaryTree {
619
623
  }
620
624
  return balanced;
621
625
  }
622
- _comparator = (a, b) => a - b;
623
626
  _setRoot(v) {
624
627
  if (v) {
625
628
  v.parent = undefined;
@@ -635,7 +638,7 @@ export class BST extends BinaryTree {
635
638
  * than), CP.lt (less than), or CP.eq (equal).
636
639
  */
637
640
  _compare(a, b) {
638
- const compared = this._comparator(a, b);
641
+ const compared = this.options.comparator(a, b);
639
642
  if (compared > 0)
640
643
  return CP.gt;
641
644
  else if (compared < 0)
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNodeNested } from '../../types';
8
+ import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
9
9
  import { BST, BSTNode } from './bst';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNodeNested<V>> extends BSTNode<V, N> {
@@ -15,12 +15,13 @@ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N>
15
15
  /**
16
16
  * 1. Each node is either red or black.
17
17
  * 2. The root node is always black.
18
- * 3. Leaf nodes are typically NIL nodes and are considered black.
18
+ * 3. Leaf nodes are typically Sentinel nodes and are considered black.
19
19
  * 4. Red nodes must have black children.
20
20
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
21
21
  */
22
- export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
23
- NIL: N;
22
+ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>, TREE extends RedBlackTree<V, N, TREE> = RedBlackTree<V, N, RedBlackTreeNested<V, N>>> extends BST<V, N, TREE> implements IBinaryTree<V, N, TREE> {
23
+ Sentinel: N;
24
+ options: RBTreeOptions;
24
25
  /**
25
26
  * The constructor function initializes a Red-Black Tree with an optional set of options.
26
27
  * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
@@ -31,6 +32,8 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
31
32
  get root(): N;
32
33
  protected _size: number;
33
34
  get size(): number;
35
+ createNode(key: BTNKey, value?: V, color?: RBTNColor): N;
36
+ createTree(options?: RBTreeOptions): TREE;
34
37
  /**
35
38
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
36
39
  * Space Complexity: O(1)
@@ -47,7 +50,6 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
47
50
  * @returns The method returns either a node (`N`) or `undefined`.
48
51
  */
49
52
  add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
50
- createNode(key: BTNKey, value?: V, color?: RBTNColor): N;
51
53
  /**
52
54
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
53
55
  * Space Complexity: O(1)
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { RBTNColor } from '../../types';
8
+ import { IterationType, RBTNColor } from '../../types';
9
9
  import { BST, BSTNode } from './bst';
10
10
  import { BinaryTreeNode } from './binary-tree';
11
11
  export class RedBlackTreeNode extends BSTNode {
@@ -18,12 +18,13 @@ export class RedBlackTreeNode extends BSTNode {
18
18
  /**
19
19
  * 1. Each node is either red or black.
20
20
  * 2. The root node is always black.
21
- * 3. Leaf nodes are typically NIL nodes and are considered black.
21
+ * 3. Leaf nodes are typically Sentinel nodes and are considered black.
22
22
  * 4. Red nodes must have black children.
23
23
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
24
24
  */
25
25
  export class RedBlackTree extends BST {
26
- NIL = new RedBlackTreeNode(NaN);
26
+ Sentinel = new RedBlackTreeNode(NaN);
27
+ options;
27
28
  /**
28
29
  * The constructor function initializes a Red-Black Tree with an optional set of options.
29
30
  * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
@@ -31,7 +32,13 @@ export class RedBlackTree extends BST {
31
32
  */
32
33
  constructor(options) {
33
34
  super(options);
34
- this._root = this.NIL;
35
+ if (options) {
36
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b, ...options };
37
+ }
38
+ else {
39
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b };
40
+ }
41
+ this._root = this.Sentinel;
35
42
  }
36
43
  _root;
37
44
  get root() {
@@ -41,6 +48,12 @@ export class RedBlackTree extends BST {
41
48
  get size() {
42
49
  return this._size;
43
50
  }
51
+ createNode(key, value, color = RBTNColor.BLACK) {
52
+ return new RedBlackTreeNode(key, value, color);
53
+ }
54
+ createTree(options) {
55
+ return new RedBlackTree({ ...this.options, ...options });
56
+ }
44
57
  /**
45
58
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
46
59
  * Space Complexity: O(1)
@@ -73,11 +86,11 @@ export class RedBlackTree extends BST {
73
86
  else {
74
87
  return;
75
88
  }
76
- node.left = this.NIL;
77
- node.right = this.NIL;
89
+ node.left = this.Sentinel;
90
+ node.right = this.Sentinel;
78
91
  let y = undefined;
79
92
  let x = this.root;
80
- while (x !== this.NIL) {
93
+ while (x !== this.Sentinel) {
81
94
  y = x;
82
95
  if (x) {
83
96
  if (node.key < x.key) {
@@ -113,9 +126,6 @@ export class RedBlackTree extends BST {
113
126
  this._fixInsert(node);
114
127
  this._size++;
115
128
  }
116
- createNode(key, value, color = RBTNColor.BLACK) {
117
- return new RedBlackTreeNode(key, value, color);
118
- }
119
129
  /**
120
130
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
121
131
  * Space Complexity: O(1)
@@ -140,9 +150,9 @@ export class RedBlackTree extends BST {
140
150
  if (identifier === null)
141
151
  return ans;
142
152
  const helper = (node) => {
143
- let z = this.NIL;
153
+ let z = this.Sentinel;
144
154
  let x, y;
145
- while (node !== this.NIL) {
155
+ while (node !== this.Sentinel) {
146
156
  if (node && callback(node) === identifier) {
147
157
  z = node;
148
158
  }
@@ -153,17 +163,17 @@ export class RedBlackTree extends BST {
153
163
  node = node?.left;
154
164
  }
155
165
  }
156
- if (z === this.NIL) {
166
+ if (z === this.Sentinel) {
157
167
  this._size--;
158
168
  return;
159
169
  }
160
170
  y = z;
161
171
  let yOriginalColor = y.color;
162
- if (z.left === this.NIL) {
172
+ if (z.left === this.Sentinel) {
163
173
  x = z.right;
164
174
  this._rbTransplant(z, z.right);
165
175
  }
166
- else if (z.right === this.NIL) {
176
+ else if (z.right === this.Sentinel) {
167
177
  x = z.left;
168
178
  this._rbTransplant(z, z.left);
169
179
  }
@@ -194,7 +204,7 @@ export class RedBlackTree extends BST {
194
204
  return ans;
195
205
  }
196
206
  isRealNode(node) {
197
- return node !== this.NIL && node !== undefined;
207
+ return node !== this.Sentinel && node !== undefined;
198
208
  }
199
209
  /**
200
210
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
@@ -221,7 +231,7 @@ export class RedBlackTree extends BST {
221
231
  * `getNodes` method, which is called within the `getNode` method.
222
232
  * @returns a value of type `N`, `null`, or `undefined`.
223
233
  */
224
- getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
234
+ getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.options.iterationType) {
225
235
  if (identifier instanceof BinaryTreeNode)
226
236
  callback = (node => node);
227
237
  beginRoot = this.ensureNotKey(beginRoot);
@@ -240,11 +250,11 @@ export class RedBlackTree extends BST {
240
250
  * @returns the successor of the given RedBlackTreeNode.
241
251
  */
242
252
  getSuccessor(x) {
243
- if (x.right !== this.NIL) {
253
+ if (x.right !== this.Sentinel) {
244
254
  return this.getLeftMost(x.right) ?? undefined;
245
255
  }
246
256
  let y = x.parent;
247
- while (y !== this.NIL && y !== undefined && x === y.right) {
257
+ while (y !== this.Sentinel && y !== undefined && x === y.right) {
248
258
  x = y;
249
259
  y = y.parent;
250
260
  }
@@ -264,18 +274,18 @@ export class RedBlackTree extends BST {
264
274
  * @returns the predecessor of the given RedBlackTreeNode 'x'.
265
275
  */
266
276
  getPredecessor(x) {
267
- if (x.left !== this.NIL) {
277
+ if (x.left !== this.Sentinel) {
268
278
  return this.getRightMost(x.left);
269
279
  }
270
280
  let y = x.parent;
271
- while (y !== this.NIL && x === y.left) {
281
+ while (y !== this.Sentinel && x === y.left) {
272
282
  x = y;
273
283
  y = y.parent;
274
284
  }
275
285
  return y;
276
286
  }
277
287
  clear() {
278
- this._root = this.NIL;
288
+ this._root = this.Sentinel;
279
289
  this._size = 0;
280
290
  }
281
291
  _setRoot(v) {
@@ -299,7 +309,7 @@ export class RedBlackTree extends BST {
299
309
  if (x.right) {
300
310
  const y = x.right;
301
311
  x.right = y.left;
302
- if (y.left !== this.NIL) {
312
+ if (y.left !== this.Sentinel) {
303
313
  if (y.left)
304
314
  y.left.parent = x;
305
315
  }
@@ -333,7 +343,7 @@ export class RedBlackTree extends BST {
333
343
  if (x.left) {
334
344
  const y = x.left;
335
345
  x.left = y.right;
336
- if (y.right !== this.NIL) {
346
+ if (y.right !== this.Sentinel) {
337
347
  if (y.right)
338
348
  y.right.parent = x;
339
349
  }
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { BTNKey, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
9
- import { BiTreeDeleteResult, BTNCallback, IterationType } from '../../types';
9
+ import { BiTreeDeleteResult, BTNCallback, IterationType, TreeMultimapNested } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
12
  export declare class TreeMultimapNode<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNodeNested<V>> extends AVLTreeNode<V, N> {
@@ -26,7 +26,8 @@ export declare class TreeMultimapNode<V = any, N extends TreeMultimapNode<V, N>
26
26
  /**
27
27
  * The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
28
28
  */
29
- export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNode<V, TreeMultimapNodeNested<V>>> extends AVLTree<V, N> implements IBinaryTree<V, N> {
29
+ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNode<V, TreeMultimapNodeNested<V>>, TREE extends TreeMultimap<V, N, TREE> = TreeMultimap<V, N, TreeMultimapNested<V, N>>> extends AVLTree<V, N, TREE> implements IBinaryTree<V, N, TREE> {
30
+ options: TreeMultimapOptions;
30
31
  /**
31
32
  * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
32
33
  * merge duplicated values.
@@ -46,6 +47,7 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
46
47
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
47
48
  */
48
49
  createNode(key: BTNKey, value?: V, count?: number): N;
50
+ createTree(options?: TreeMultimapOptions): TREE;
49
51
  /**
50
52
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
51
53
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -98,7 +100,7 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
98
100
  * values:
99
101
  * @returns a boolean value.
100
102
  */
101
- perfectlyBalance(iterationType?: IterationType): boolean;
103
+ perfectlyBalance(iterationType?: IterationType | undefined): boolean;
102
104
  /**
103
105
  * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
104
106
  * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
@@ -21,14 +21,21 @@ export class TreeMultimapNode extends AVLTreeNode {
21
21
  * The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
22
22
  */
23
23
  export class TreeMultimap extends AVLTree {
24
+ options;
24
25
  /**
25
26
  * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
26
27
  * merge duplicated values.
27
28
  * @param {TreeMultimapOptions} [options] - An optional object that contains additional configuration options for the
28
29
  * TreeMultimap.
29
30
  */
30
- constructor(options) {
31
+ constructor(options = { iterationType: IterationType.ITERATIVE }) {
31
32
  super(options);
33
+ if (options) {
34
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b, ...options };
35
+ }
36
+ else {
37
+ this.options = { iterationType: IterationType.ITERATIVE, comparator: (a, b) => a - b };
38
+ }
32
39
  }
33
40
  _count = 0;
34
41
  get count() {
@@ -46,6 +53,9 @@ export class TreeMultimap extends AVLTree {
46
53
  createNode(key, value, count) {
47
54
  return new TreeMultimapNode(key, value, count);
48
55
  }
56
+ createTree(options) {
57
+ return new TreeMultimap({ ...this.options, ...options });
58
+ }
49
59
  /**
50
60
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
51
61
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -191,7 +201,7 @@ export class TreeMultimap extends AVLTree {
191
201
  * values:
192
202
  * @returns a boolean value.
193
203
  */
194
- perfectlyBalance(iterationType = this.iterationType) {
204
+ perfectlyBalance(iterationType = this.options.iterationType) {
195
205
  const sorted = this.dfs(node => node, 'in'), n = sorted.length;
196
206
  if (sorted.length < 1)
197
207
  return false;
@@ -1,6 +1,6 @@
1
- import { BinaryTreeNode } from '../data-structures';
2
- import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
3
- export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
1
+ import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
+ import { BinaryTreeNested, BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
3
+ export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>, TREE extends BinaryTree<V, N, TREE> = BinaryTreeNested<V, N>> {
4
4
  createNode(key: BTNKey, value?: N['value']): N;
5
5
  add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;
6
6
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
@@ -6,10 +6,6 @@ export declare enum CP {
6
6
  eq = "eq",
7
7
  gt = "gt"
8
8
  }
9
- export declare const enum IterateDirection {
10
- DEFAULT = 0,
11
- REVERSE = 1
12
- }
13
9
  export interface IterableWithSize<T> extends Iterable<T> {
14
10
  size: number | ((...args: any[]) => number);
15
11
  }
@@ -17,3 +13,8 @@ export interface IterableWithLength<T> extends Iterable<T> {
17
13
  length: number | ((...args: any[]) => number);
18
14
  }
19
15
  export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>;
16
+ export type BinaryTreePrintOptions = {
17
+ isShowUndefined?: boolean;
18
+ isShowNull?: boolean;
19
+ isShowRedBlackNIL?: boolean;
20
+ };
@@ -1,4 +1,5 @@
1
- import { AVLTreeNode } from '../../../data-structures';
1
+ import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
3
  export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type AVLTreeNested<T, N extends AVLTreeNode<T, N>> = AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
5
  export type AVLTreeOptions = BSTOptions & {};
@@ -1,4 +1,4 @@
1
- import { BinaryTreeNode } from '../../../data-structures';
1
+ import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
2
  /**
3
3
  * Enum representing different loop types.
4
4
  *
@@ -24,6 +24,8 @@ export type BiTreeDeleteResult<N> = {
24
24
  needBalanced: N | null | undefined;
25
25
  };
26
26
  export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
+ export type BinaryTreeNested<T, N extends BinaryTreeNode<T, N>> = BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
28
  export type BinaryTreeOptions = {
28
29
  iterationType?: IterationType;
29
30
  };
31
+ export type NodeDisplayLayout = [string[], number, number, number];
@@ -19,9 +19,3 @@ export var FamilyPosition;
19
19
  FamilyPosition["ISOLATED"] = "ISOLATED";
20
20
  FamilyPosition["MAL_NODE"] = "MAL_NODE";
21
21
  })(FamilyPosition || (FamilyPosition = {}));
22
- //
23
- // export type BTNIdentifierOrNU<N> = BTNKey | N | null | undefined;
24
- //
25
- // export type BTNIdentifierOrU<N> = BTNKey | N | undefined;
26
- //
27
- // export type BTNOrNU<N> = N | null | undefined;
@@ -1,7 +1,8 @@
1
- import { BSTNode } from '../../../data-structures';
1
+ import { BST, BSTNode } from '../../../data-structures';
2
2
  import type { BinaryTreeOptions, BTNKey } from './binary-tree';
3
3
  export type BSTComparator = (a: BTNKey, b: BTNKey) => number;
4
4
  export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type BSTNested<T, N extends BSTNode<T, N>> = BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
6
  export type BSTOptions = BinaryTreeOptions & {
6
7
  comparator?: BSTComparator;
7
8
  };
@@ -1,8 +1,9 @@
1
- import { RedBlackTreeNode } from '../../../data-structures';
1
+ import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from "./bst";
3
3
  export declare enum RBTNColor {
4
4
  RED = 1,
5
5
  BLACK = 0
6
6
  }
7
7
  export type RedBlackTreeNodeNested<T> = RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
+ export type RedBlackTreeNested<T, N extends RedBlackTreeNode<T, N>> = RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
9
  export type RBTreeOptions = BSTOptions & {};
@@ -1,4 +1,5 @@
1
- import { TreeMultimapNode } from '../../../data-structures';
1
+ import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
2
2
  import { AVLTreeOptions } from './avl-tree';
3
3
  export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type TreeMultimapNested<T, N extends TreeMultimapNode<T, N>> = TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
5
  export type TreeMultimapOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeByKey'> & {};