data-structure-typed 1.42.6 → 1.42.8

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 (50) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +123 -123
  3. package/benchmark/report.html +12 -12
  4. package/benchmark/report.json +101 -101
  5. package/dist/cjs/src/data-structures/binary-tree/avl-tree.d.ts +5 -5
  6. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js +19 -14
  7. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +108 -60
  9. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +189 -89
  10. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/bst.d.ts +30 -8
  12. package/dist/cjs/src/data-structures/binary-tree/bst.js +77 -28
  13. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +35 -28
  15. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +44 -45
  16. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +7 -12
  18. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +38 -37
  19. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
  20. package/dist/cjs/src/interfaces/binary-tree.d.ts +2 -2
  21. package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  22. package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js +6 -0
  23. package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  24. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
  25. package/dist/mjs/src/data-structures/binary-tree/avl-tree.d.ts +5 -5
  26. package/dist/mjs/src/data-structures/binary-tree/avl-tree.js +19 -14
  27. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +108 -60
  28. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +191 -89
  29. package/dist/mjs/src/data-structures/binary-tree/bst.d.ts +30 -8
  30. package/dist/mjs/src/data-structures/binary-tree/bst.js +78 -27
  31. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +35 -28
  32. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +43 -45
  33. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +7 -12
  34. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +38 -37
  35. package/dist/mjs/src/interfaces/binary-tree.d.ts +2 -2
  36. package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  37. package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.js +6 -0
  38. package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
  39. package/dist/umd/data-structure-typed.min.js +1 -1
  40. package/dist/umd/data-structure-typed.min.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/data-structures/binary-tree/avl-tree.ts +24 -18
  43. package/src/data-structures/binary-tree/binary-tree.ts +248 -142
  44. package/src/data-structures/binary-tree/bst.ts +88 -38
  45. package/src/data-structures/binary-tree/rb-tree.ts +52 -58
  46. package/src/data-structures/binary-tree/tree-multimap.ts +50 -54
  47. package/src/interfaces/binary-tree.ts +2 -2
  48. package/src/types/data-structures/binary-tree/binary-tree.ts +7 -1
  49. package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
  50. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
@@ -5,10 +5,10 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { BinaryTreeDeletedResult, BTNCallback, BTNKey, IterationType, RBTNColor, RBTreeNodeNested, RBTreeOptions } from '../../types';
8
+ import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RedBlackTreeNodeNested, RBTreeOptions } from '../../types';
9
9
  import { BST, BSTNode } from "./bst";
10
10
  import { IBinaryTree } from "../../interfaces";
11
- export declare class RBTreeNode<V = any, N extends RBTreeNode<V, N> = RBTreeNodeNested<V>> extends BSTNode<V, N> {
11
+ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNodeNested<V>> extends BSTNode<V, N> {
12
12
  color: RBTNColor;
13
13
  constructor(key: BTNKey, value?: V, color?: RBTNColor);
14
14
  }
@@ -19,74 +19,81 @@ export declare class RBTreeNode<V = any, N extends RBTreeNode<V, N> = RBTreeNode
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 RBTreeNode<V, N> = RBTreeNode<V, RBTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
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
23
  constructor(options?: RBTreeOptions);
24
24
  protected _root: N;
25
25
  get root(): N;
26
26
  protected _size: number;
27
27
  get size(): number;
28
28
  NIL: N;
29
+ /**
30
+ * The `add` function adds a new node to a Red-Black Tree data structure.
31
+ * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
32
+ * following types:
33
+ * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
34
+ * key in the node being added to the Red-Black Tree.
35
+ * @returns The method returns either a node (`N`) or `undefined`.
36
+ */
29
37
  add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
30
38
  createNode(key: BTNKey, value?: V, color?: RBTNColor): N;
31
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeletedResult<N>[];
32
- isNode(node: N | undefined): node is N;
39
+ /**
40
+ * The `delete` function removes a node from a binary tree based on a given identifier and updates
41
+ * the tree accordingly.
42
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
43
+ * that you want to use to identify the node that you want to delete from the binary tree. It can be
44
+ * of any type that is returned by the callback function `C`. It can also be `null` or `undefined` if
45
+ * you don't want to
46
+ * @param {C} callback - The `callback` parameter is a function that takes a node of type `N` and
47
+ * returns a value of type `ReturnType<C>`. It is used to determine if a node should be deleted based
48
+ * on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
49
+ * @returns an array of `BiTreeDeleteResult<N>`.
50
+ */
51
+ delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback?: C): BiTreeDeleteResult<N>[];
52
+ isRealNode(node: N | undefined): node is N;
33
53
  getNode<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
34
54
  getNode<C extends BTNCallback<N, N>>(identifier: N | undefined, callback?: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
35
55
  getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
36
- /**
37
- * The function returns the leftmost node in a red-black tree.
38
- * @param {RBTreeNode} node - The parameter "node" is of type RBTreeNode, which represents a node in
39
- * a Red-Black Tree.
40
- * @returns The leftmost node in the given RBTreeNode.
41
- */
42
- getLeftMost(node?: N): N;
43
- /**
44
- * The function returns the rightmost node in a red-black tree.
45
- * @param {RBTreeNode} node - The parameter "node" is of type RBTreeNode.
46
- * @returns the rightmost node in a red-black tree.
47
- */
48
- getRightMost(node: N): N;
49
56
  /**
50
57
  * The function returns the successor of a given node in a red-black tree.
51
- * @param {RBTreeNode} x - RBTreeNode - The node for which we want to find the successor.
52
- * @returns the successor of the given RBTreeNode.
58
+ * @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
59
+ * @returns the successor of the given RedBlackTreeNode.
53
60
  */
54
61
  getSuccessor(x: N): N | undefined;
55
62
  /**
56
63
  * The function returns the predecessor of a given node in a red-black tree.
57
- * @param {RBTreeNode} x - The parameter `x` is of type `RBTreeNode`, which represents a node in a
64
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
58
65
  * Red-Black Tree.
59
- * @returns the predecessor of the given RBTreeNode 'x'.
66
+ * @returns the predecessor of the given RedBlackTreeNode 'x'.
60
67
  */
61
68
  getPredecessor(x: N): N;
62
69
  clear(): void;
63
70
  protected _setRoot(v: N): void;
64
71
  /**
65
72
  * The function performs a left rotation on a red-black tree node.
66
- * @param {RBTreeNode} x - The parameter `x` is a RBTreeNode object.
73
+ * @param {RedBlackTreeNode} x - The parameter `x` is a RedBlackTreeNode object.
67
74
  */
68
75
  protected _leftRotate(x: N): void;
69
76
  /**
70
77
  * The function performs a right rotation on a red-black tree node.
71
- * @param {RBTreeNode} x - x is a RBTreeNode, which represents the node that needs to be right
78
+ * @param {RedBlackTreeNode} x - x is a RedBlackTreeNode, which represents the node that needs to be right
72
79
  * rotated.
73
80
  */
74
81
  protected _rightRotate(x: N): void;
75
82
  /**
76
83
  * The _fixDelete function is used to rebalance the Red-Black Tree after a node deletion.
77
- * @param {RBTreeNode} x - The parameter `x` is of type `RBTreeNode`, which represents a node in a
84
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
78
85
  * red-black tree.
79
86
  */
80
87
  protected _fixDelete(x: N): void;
81
88
  /**
82
89
  * The function `_rbTransplant` replaces one node in a red-black tree with another node.
83
- * @param {RBTreeNode} u - The parameter "u" represents a RBTreeNode object.
84
- * @param {RBTreeNode} v - The parameter "v" is a RBTreeNode object.
90
+ * @param {RedBlackTreeNode} u - The parameter "u" represents a RedBlackTreeNode object.
91
+ * @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
85
92
  */
86
93
  protected _rbTransplant(u: N, v: N): void;
87
94
  /**
88
95
  * The `_fixInsert` function is used to fix the red-black tree after an insertion operation.
89
- * @param {RBTreeNode} k - The parameter `k` is a RBTreeNode object, which represents a node in a
96
+ * @param {RedBlackTreeNode} k - The parameter `k` is a RedBlackTreeNode object, which represents a node in a
90
97
  * red-black tree.
91
98
  */
92
99
  protected _fixInsert(k: N): void;
@@ -7,17 +7,17 @@
7
7
  * @license MIT License
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.RedBlackTree = exports.RBTreeNode = void 0;
10
+ exports.RedBlackTree = exports.RedBlackTreeNode = void 0;
11
11
  const types_1 = require("../../types");
12
12
  const bst_1 = require("./bst");
13
13
  const binary_tree_1 = require("./binary-tree");
14
- class RBTreeNode extends bst_1.BSTNode {
14
+ class RedBlackTreeNode extends bst_1.BSTNode {
15
15
  constructor(key, value, color = types_1.RBTNColor.BLACK) {
16
16
  super(key, value);
17
17
  this.color = color;
18
18
  }
19
19
  }
20
- exports.RBTreeNode = RBTreeNode;
20
+ exports.RedBlackTreeNode = RedBlackTreeNode;
21
21
  /**
22
22
  * 1. Each node is either red or black.
23
23
  * 2. The root node is always black.
@@ -29,7 +29,7 @@ class RedBlackTree extends bst_1.BST {
29
29
  constructor(options) {
30
30
  super(options);
31
31
  this._size = 0;
32
- this.NIL = new RBTreeNode(NaN);
32
+ this.NIL = new RedBlackTreeNode(NaN);
33
33
  this._root = this.NIL;
34
34
  }
35
35
  get root() {
@@ -38,12 +38,20 @@ class RedBlackTree extends bst_1.BST {
38
38
  get size() {
39
39
  return this._size;
40
40
  }
41
+ /**
42
+ * The `add` function adds a new node to a Red-Black Tree data structure.
43
+ * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
44
+ * following types:
45
+ * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
46
+ * key in the node being added to the Red-Black Tree.
47
+ * @returns The method returns either a node (`N`) or `undefined`.
48
+ */
41
49
  add(keyOrNode, value) {
42
50
  let node;
43
- if (typeof keyOrNode === 'number') {
51
+ if (this.isNodeKey(keyOrNode)) {
44
52
  node = this.createNode(keyOrNode, value, types_1.RBTNColor.RED);
45
53
  }
46
- else if (keyOrNode instanceof RBTreeNode) {
54
+ else if (keyOrNode instanceof RedBlackTreeNode) {
47
55
  node = keyOrNode;
48
56
  }
49
57
  else if (keyOrNode === null) {
@@ -91,9 +99,21 @@ class RedBlackTree extends bst_1.BST {
91
99
  this._size++;
92
100
  }
93
101
  createNode(key, value, color = types_1.RBTNColor.BLACK) {
94
- return new RBTreeNode(key, value, color);
102
+ return new RedBlackTreeNode(key, value, color);
95
103
  }
96
- delete(identifier, callback = this.defaultOneParamCallback) {
104
+ /**
105
+ * The `delete` function removes a node from a binary tree based on a given identifier and updates
106
+ * the tree accordingly.
107
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value
108
+ * that you want to use to identify the node that you want to delete from the binary tree. It can be
109
+ * of any type that is returned by the callback function `C`. It can also be `null` or `undefined` if
110
+ * you don't want to
111
+ * @param {C} callback - The `callback` parameter is a function that takes a node of type `N` and
112
+ * returns a value of type `ReturnType<C>`. It is used to determine if a node should be deleted based
113
+ * on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
114
+ * @returns an array of `BiTreeDeleteResult<N>`.
115
+ */
116
+ delete(identifier, callback = this._defaultOneParamCallback) {
97
117
  const ans = [];
98
118
  if (identifier === null)
99
119
  return ans;
@@ -151,7 +171,7 @@ class RedBlackTree extends bst_1.BST {
151
171
  // TODO
152
172
  return ans;
153
173
  }
154
- isNode(node) {
174
+ isRealNode(node) {
155
175
  return node !== this.NIL && node !== undefined;
156
176
  }
157
177
  /**
@@ -162,50 +182,29 @@ class RedBlackTree extends bst_1.BST {
162
182
  * @param callback - The `callback` parameter is a function that is used to determine whether a node
163
183
  * matches the desired criteria. It takes a node as input and returns a boolean value indicating
164
184
  * whether the node matches the criteria or not. The default callback function
165
- * (`this.defaultOneParamCallback`) is used if no callback function is
185
+ * (`this._defaultOneParamCallback`) is used if no callback function is
166
186
  * @param beginRoot - The `beginRoot` parameter is the starting point for the search. It specifies
167
187
  * the root node from which the search should begin.
168
188
  * @param iterationType - The `iterationType` parameter specifies the type of iteration to be
169
189
  * performed when searching for a node in the binary tree. It can have one of the following values:
170
190
  * @returns either the found node (of type N) or null if no node is found.
171
191
  */
172
- getNode(identifier, callback = this.defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
192
+ getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
173
193
  var _a;
174
194
  if (identifier instanceof binary_tree_1.BinaryTreeNode)
175
195
  callback = (node => node);
196
+ beginRoot = this.ensureNotKey(beginRoot);
176
197
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
177
198
  }
178
- /**
179
- * The function returns the leftmost node in a red-black tree.
180
- * @param {RBTreeNode} node - The parameter "node" is of type RBTreeNode, which represents a node in
181
- * a Red-Black Tree.
182
- * @returns The leftmost node in the given RBTreeNode.
183
- */
184
- getLeftMost(node = this.root) {
185
- while (node.left !== undefined && node.left !== this.NIL) {
186
- node = node.left;
187
- }
188
- return node;
189
- }
190
- /**
191
- * The function returns the rightmost node in a red-black tree.
192
- * @param {RBTreeNode} node - The parameter "node" is of type RBTreeNode.
193
- * @returns the rightmost node in a red-black tree.
194
- */
195
- getRightMost(node) {
196
- while (node.right !== undefined && node.right !== this.NIL) {
197
- node = node.right;
198
- }
199
- return node;
200
- }
201
199
  /**
202
200
  * The function returns the successor of a given node in a red-black tree.
203
- * @param {RBTreeNode} x - RBTreeNode - The node for which we want to find the successor.
204
- * @returns the successor of the given RBTreeNode.
201
+ * @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
202
+ * @returns the successor of the given RedBlackTreeNode.
205
203
  */
206
204
  getSuccessor(x) {
205
+ var _a;
207
206
  if (x.right !== this.NIL) {
208
- return this.getLeftMost(x.right);
207
+ return (_a = this.getLeftMost(x.right)) !== null && _a !== void 0 ? _a : undefined;
209
208
  }
210
209
  let y = x.parent;
211
210
  while (y !== this.NIL && y !== undefined && x === y.right) {
@@ -216,9 +215,9 @@ class RedBlackTree extends bst_1.BST {
216
215
  }
217
216
  /**
218
217
  * The function returns the predecessor of a given node in a red-black tree.
219
- * @param {RBTreeNode} x - The parameter `x` is of type `RBTreeNode`, which represents a node in a
218
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
220
219
  * Red-Black Tree.
221
- * @returns the predecessor of the given RBTreeNode 'x'.
220
+ * @returns the predecessor of the given RedBlackTreeNode 'x'.
222
221
  */
223
222
  getPredecessor(x) {
224
223
  if (x.left !== this.NIL) {
@@ -243,7 +242,7 @@ class RedBlackTree extends bst_1.BST {
243
242
  }
244
243
  /**
245
244
  * The function performs a left rotation on a red-black tree node.
246
- * @param {RBTreeNode} x - The parameter `x` is a RBTreeNode object.
245
+ * @param {RedBlackTreeNode} x - The parameter `x` is a RedBlackTreeNode object.
247
246
  */
248
247
  _leftRotate(x) {
249
248
  if (x.right) {
@@ -269,7 +268,7 @@ class RedBlackTree extends bst_1.BST {
269
268
  }
270
269
  /**
271
270
  * The function performs a right rotation on a red-black tree node.
272
- * @param {RBTreeNode} x - x is a RBTreeNode, which represents the node that needs to be right
271
+ * @param {RedBlackTreeNode} x - x is a RedBlackTreeNode, which represents the node that needs to be right
273
272
  * rotated.
274
273
  */
275
274
  _rightRotate(x) {
@@ -296,7 +295,7 @@ class RedBlackTree extends bst_1.BST {
296
295
  }
297
296
  /**
298
297
  * The _fixDelete function is used to rebalance the Red-Black Tree after a node deletion.
299
- * @param {RBTreeNode} x - The parameter `x` is of type `RBTreeNode`, which represents a node in a
298
+ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a
300
299
  * red-black tree.
301
300
  */
302
301
  _fixDelete(x) {
@@ -365,8 +364,8 @@ class RedBlackTree extends bst_1.BST {
365
364
  }
366
365
  /**
367
366
  * The function `_rbTransplant` replaces one node in a red-black tree with another node.
368
- * @param {RBTreeNode} u - The parameter "u" represents a RBTreeNode object.
369
- * @param {RBTreeNode} v - The parameter "v" is a RBTreeNode object.
367
+ * @param {RedBlackTreeNode} u - The parameter "u" represents a RedBlackTreeNode object.
368
+ * @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
370
369
  */
371
370
  _rbTransplant(u, v) {
372
371
  if (u.parent === undefined) {
@@ -382,7 +381,7 @@ class RedBlackTree extends bst_1.BST {
382
381
  }
383
382
  /**
384
383
  * The `_fixInsert` function is used to fix the red-black tree after an insertion operation.
385
- * @param {RBTreeNode} k - The parameter `k` is a RBTreeNode object, which represents a node in a
384
+ * @param {RedBlackTreeNode} k - The parameter `k` is a RedBlackTreeNode object, which represents a node in a
386
385
  * red-black tree.
387
386
  */
388
387
  _fixInsert(k) {
@@ -1 +1 @@
1
- {"version":3,"file":"rb-tree.js","sourceRoot":"","sources":["../../../../../src/data-structures/binary-tree/rb-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAQqB;AACrB,+BAAmC;AAEnC,+CAA6C;AAE7C,MAAa,UAAsE,SAAQ,aAAa;IAEtG,YAAY,GAAW,EAAE,KAAS,EAAE,QAAmB,iBAAS,CAAC,KAAK;QACpE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAND,gCAMC;AAED;;;;;;GAMG;AACH,MAAa,YACX,SAAQ,SAAS;IAIjB,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAUP,UAAK,GAAW,CAAC,CAAC;QAM5B,QAAG,GAAM,IAAI,UAAU,CAAI,GAAG,CAAiB,CAAC;QAf9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC;IACxB,CAAC;IAID,IAAI,IAAI;QACN,OAAO,IAAI,C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KAAK,CAAC,EAAE;oBACtB,CAAC,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBAC1B,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBACjC,CAAC,CAAC,MAAM,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,GAAG,CAAC;oBACvC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,MAAO,CAAC;iBACtB;qBAAM;oBACL,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;wBACxB,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;wBACb,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;qBACrB;oBAED,CAAC,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBAClC,CAAC,CAAC,MAAO,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,GAAG,CAAC;oBACxC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,MAAO,CAAC,MAAO,CAAC,CAAC;iBACtC;aACF;YACD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;gBACnB,MAAM;aACP;SACF;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;IACpC,CAAC;CACF;AAjcD,oCAicC"}
1
+ {"version":3,"file":"rb-tree.js","sourceRoot":"","sources":["../../../../../src/data-structures/binary-tree/rb-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAQqB;AACrB,+BAAmC;AAEnC,+CAA6C;AAE7C,MAAa,gBAAwF,SAAQ,aAAa;IAExH,YAAY,GAAW,EAAE,KAAS,EAAE,QAAmB,iBAAS,CAAC,KAAK;QACpE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAND,4CAMC;AAED;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AAC,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBAC1B,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBACjC,CAAC,CAAC,MAAM,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,GAAG,CAAC;oBACvC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,MAAO,CAAC;iBACtB;qBAAM;oBACL,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;wBACxB,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;wBACb,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;qBACrB;oBAED,CAAC,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;oBAClC,CAAC,CAAC,MAAO,CAAC,MAAO,CAAC,KAAK,GAAG,iBAAS,CAAC,GAAG,CAAC;oBACxC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,MAAO,CAAC,MAAO,CAAC,CAAC;iBACtC;aACF;YACD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;gBACnB,MAAM;aACP;SACF;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,iBAAS,CAAC,KAAK,CAAC;IACpC,CAAC;CACF;AA3bD,oCA2bC"}
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { BTNKey, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
9
- import { BinaryTreeDeletedResult, BTNCallback, IterationType } from '../../types';
9
+ import { BiTreeDeleteResult, BTNCallback, IterationType } 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> {
@@ -68,7 +68,7 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
68
68
  * be added as a child.
69
69
  * @returns The method `_addTo` returns either the `parent.left`, `parent.right`, or `undefined`.
70
70
  */
71
- _addTo(newNode: N | undefined, parent: N): N | undefined;
71
+ protected _addTo(newNode: N | undefined, parent: BTNKey | N | undefined): N | undefined;
72
72
  /**
73
73
  * The `addMany` function adds multiple keys or nodes to a TreeMultimap and returns an array of the
74
74
  * inserted nodes.
@@ -79,7 +79,7 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
79
79
  * each key or node.
80
80
  * @returns The function `addMany` returns an array of `N`, `undefined`, or `undefined` values.
81
81
  */
82
- addMany(keysOrNodes: (BTNKey | undefined)[] | (N | undefined)[], data?: V[]): (N | undefined)[];
82
+ addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: V[]): (N | undefined)[];
83
83
  /**
84
84
  * The `perfectlyBalance` function in TypeScript takes a sorted array of nodes and builds a balanced
85
85
  * binary search tree using either a recursive or iterative approach.
@@ -98,14 +98,14 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
98
98
  * @param callback - The `callback` parameter is a function that takes a node as input and returns a
99
99
  * value. This value is compared with the `identifier` parameter to determine if the node should be
100
100
  * included in the result. The `callback` parameter has a default value of
101
- * `this.defaultOneParamCallback`
101
+ * `this._defaultOneParamCallback`
102
102
  * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
103
103
  * being deleted. If set to true, the count of the node will not be considered and the node will be
104
104
  * deleted regardless of its count. If set to false (default), the count of the node will be
105
105
  * decremented by 1 and
106
- * @returns The method `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
106
+ * @returns The method `delete` returns an array of `BiTreeDeleteResult<N>` objects.
107
107
  */
108
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
108
+ delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BiTreeDeleteResult<N>[];
109
109
  /**
110
110
  * The clear() function clears the contents of a data structure and sets the count to zero.
111
111
  */
@@ -117,10 +117,5 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
117
117
  * from `srcNode` will be swapped into.
118
118
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
119
119
  */
120
- protected _swap(srcNode: N, destNode: N): N;
121
- /**
122
- * The function sets the value of the "_count" property.
123
- * @param {number} v - number
124
- */
125
- protected _setCount(v: number): void;
120
+ protected _swap(srcNode: BTNKey | N | undefined, destNode: BTNKey | N | undefined): N | undefined;
126
121
  }
@@ -78,7 +78,8 @@ class TreeMultimap extends avl_tree_1.AVLTree {
78
78
  if (!this.root) {
79
79
  this._setRoot(newNode);
80
80
  this._size = this.size + 1;
81
- newNode && this._setCount(this.count + newNode.count);
81
+ if (newNode)
82
+ this._count += newNode.count;
82
83
  inserted = this.root;
83
84
  }
84
85
  else {
@@ -90,7 +91,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
90
91
  if (this._compare(cur.key, newNode.key) === types_1.CP.eq) {
91
92
  cur.value = newNode.value;
92
93
  cur.count += newNode.count;
93
- this._setCount(this.count + newNode.count);
94
+ this._count += newNode.count;
94
95
  traversing = false;
95
96
  inserted = cur;
96
97
  }
@@ -100,7 +101,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
100
101
  //Add to the left of the current node
101
102
  cur.left = newNode;
102
103
  this._size = this.size + 1;
103
- this._setCount(this.count + newNode.count);
104
+ this._count += newNode.count;
104
105
  traversing = false;
105
106
  inserted = cur.left;
106
107
  }
@@ -116,7 +117,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
116
117
  //Add to the right of the current node
117
118
  cur.right = newNode;
118
119
  this._size = this.size + 1;
119
- this._setCount(this.count + newNode.count);
120
+ this._count += newNode.count;
120
121
  traversing = false;
121
122
  inserted = cur.right;
122
123
  }
@@ -149,12 +150,13 @@ class TreeMultimap extends avl_tree_1.AVLTree {
149
150
  * @returns The method `_addTo` returns either the `parent.left`, `parent.right`, or `undefined`.
150
151
  */
151
152
  _addTo(newNode, parent) {
153
+ parent = this.ensureNotKey(parent);
152
154
  if (parent) {
153
155
  if (parent.left === undefined) {
154
156
  parent.left = newNode;
155
157
  if (newNode !== undefined) {
156
158
  this._size = this.size + 1;
157
- this._setCount(this.count + newNode.count);
159
+ this._count += newNode.count;
158
160
  }
159
161
  return parent.left;
160
162
  }
@@ -162,7 +164,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
162
164
  parent.right = newNode;
163
165
  if (newNode !== undefined) {
164
166
  this._size = this.size + 1;
165
- this._setCount(this.count + newNode.count);
167
+ this._count += newNode.count;
166
168
  }
167
169
  return parent.right;
168
170
  }
@@ -253,26 +255,26 @@ class TreeMultimap extends avl_tree_1.AVLTree {
253
255
  * @param callback - The `callback` parameter is a function that takes a node as input and returns a
254
256
  * value. This value is compared with the `identifier` parameter to determine if the node should be
255
257
  * included in the result. The `callback` parameter has a default value of
256
- * `this.defaultOneParamCallback`
258
+ * `this._defaultOneParamCallback`
257
259
  * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
258
260
  * being deleted. If set to true, the count of the node will not be considered and the node will be
259
261
  * deleted regardless of its count. If set to false (default), the count of the node will be
260
262
  * decremented by 1 and
261
- * @returns The method `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
263
+ * @returns The method `delete` returns an array of `BiTreeDeleteResult<N>` objects.
262
264
  */
263
- delete(identifier, callback = this.defaultOneParamCallback, ignoreCount = false) {
265
+ delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {
264
266
  var _a;
265
- const bstDeletedResult = [];
267
+ const deletedResult = [];
266
268
  if (!this.root)
267
- return bstDeletedResult;
269
+ return deletedResult;
268
270
  const curr = (_a = this.getNode(identifier, callback)) !== null && _a !== void 0 ? _a : undefined;
269
271
  if (!curr)
270
- return bstDeletedResult;
272
+ return deletedResult;
271
273
  const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : undefined;
272
274
  let needBalanced = undefined, orgCurrent = curr;
273
275
  if (curr.count > 1 && !ignoreCount) {
274
276
  curr.count--;
275
- this._setCount(this.count - 1);
277
+ this._count--;
276
278
  }
277
279
  else {
278
280
  if (!curr.left) {
@@ -309,20 +311,21 @@ class TreeMultimap extends avl_tree_1.AVLTree {
309
311
  }
310
312
  this._size = this.size - 1;
311
313
  // TODO How to handle when the count of target node is lesser than current node's count
312
- this._setCount(this.count - orgCurrent.count);
314
+ if (orgCurrent)
315
+ this._count -= orgCurrent.count;
313
316
  }
314
- bstDeletedResult.push({ deleted: orgCurrent, needBalanced });
317
+ deletedResult.push({ deleted: orgCurrent, needBalanced });
315
318
  if (needBalanced) {
316
319
  this._balancePath(needBalanced);
317
320
  }
318
- return bstDeletedResult;
321
+ return deletedResult;
319
322
  }
320
323
  /**
321
324
  * The clear() function clears the contents of a data structure and sets the count to zero.
322
325
  */
323
326
  clear() {
324
327
  super.clear();
325
- this._setCount(0);
328
+ this._count = 0;
326
329
  }
327
330
  /**
328
331
  * The function swaps the values of two nodes in a binary tree.
@@ -332,27 +335,25 @@ class TreeMultimap extends avl_tree_1.AVLTree {
332
335
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
333
336
  */
334
337
  _swap(srcNode, destNode) {
335
- const { key, value, count, height } = destNode;
336
- const tempNode = this.createNode(key, value, count);
337
- if (tempNode) {
338
- tempNode.height = height;
339
- destNode.key = srcNode.key;
340
- destNode.value = srcNode.value;
341
- destNode.count = srcNode.count;
342
- destNode.height = srcNode.height;
343
- srcNode.key = tempNode.key;
344
- srcNode.value = tempNode.value;
345
- srcNode.count = tempNode.count;
346
- srcNode.height = tempNode.height;
338
+ srcNode = this.ensureNotKey(srcNode);
339
+ destNode = this.ensureNotKey(destNode);
340
+ if (srcNode && destNode) {
341
+ const { key, value, count, height } = destNode;
342
+ const tempNode = this.createNode(key, value, count);
343
+ if (tempNode) {
344
+ tempNode.height = height;
345
+ destNode.key = srcNode.key;
346
+ destNode.value = srcNode.value;
347
+ destNode.count = srcNode.count;
348
+ destNode.height = srcNode.height;
349
+ srcNode.key = tempNode.key;
350
+ srcNode.value = tempNode.value;
351
+ srcNode.count = tempNode.count;
352
+ srcNode.height = tempNode.height;
353
+ }
354
+ return destNode;
347
355
  }
348
- return destNode;
349
- }
350
- /**
351
- * The function sets the value of the "_count" property.
352
- * @param {number} v - number
353
- */
354
- _setCount(v) {
355
- this._count = v;
356
+ return undefined;
356
357
  }
357
358
  }
358
359
  exports.TreeMultimap = TreeMultimap;