avl-tree-typed 1.47.6 → 1.47.7

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 (28) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +40 -22
  2. package/dist/data-structures/binary-tree/avl-tree.js +45 -36
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +105 -113
  4. package/dist/data-structures/binary-tree/binary-tree.js +133 -119
  5. package/dist/data-structures/binary-tree/bst.d.ts +53 -44
  6. package/dist/data-structures/binary-tree/bst.js +137 -154
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +48 -15
  8. package/dist/data-structures/binary-tree/rb-tree.js +70 -33
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +26 -37
  10. package/dist/data-structures/binary-tree/tree-multimap.js +58 -137
  11. package/dist/data-structures/hash/hash-map.d.ts +2 -6
  12. package/dist/data-structures/hash/hash-map.js +5 -8
  13. package/dist/data-structures/trie/trie.d.ts +3 -0
  14. package/dist/data-structures/trie/trie.js +19 -4
  15. package/dist/interfaces/binary-tree.d.ts +3 -3
  16. package/dist/types/common.d.ts +6 -1
  17. package/dist/types/data-structures/hash/hash-map.d.ts +1 -2
  18. package/package.json +2 -2
  19. package/src/data-structures/binary-tree/avl-tree.ts +59 -39
  20. package/src/data-structures/binary-tree/binary-tree.ts +192 -180
  21. package/src/data-structures/binary-tree/bst.ts +157 -154
  22. package/src/data-structures/binary-tree/rb-tree.ts +78 -37
  23. package/src/data-structures/binary-tree/tree-multimap.ts +67 -145
  24. package/src/data-structures/hash/hash-map.ts +8 -8
  25. package/src/data-structures/trie/trie.ts +23 -4
  26. package/src/interfaces/binary-tree.ts +3 -3
  27. package/src/types/common.ts +11 -1
  28. package/src/types/data-structures/hash/hash-map.ts +1 -2
@@ -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, IterableEntriesOrKeys, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
8
+ import { BiTreeDeleteResult, BTNCallback, BTNKey, BTNodeExemplar, 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> {
@@ -22,29 +22,53 @@ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N>
22
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
23
  Sentinel: N;
24
24
  /**
25
- * The constructor function initializes a Red-Black Tree with an optional set of options.
26
- * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
27
- * passed to the constructor. It is used to configure the RBTree object with specific options.
28
- */
29
- constructor(elements?: IterableEntriesOrKeys<V>, options?: Partial<RBTreeOptions>);
25
+ * This is the constructor function for a Red-Black Tree data structure in TypeScript, which
26
+ * initializes the tree with optional elements and options.
27
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<V, N>`
28
+ * objects. It represents the initial elements that will be added to the RBTree during its
29
+ * construction. If this parameter is provided, the `addMany` method is called to add all the
30
+ * elements to the
31
+ * @param [options] - The `options` parameter is an optional object that allows you to customize the
32
+ * behavior of the RBTree. It is of type `Partial<RBTreeOptions>`, which means that you can provide
33
+ * only a subset of the properties defined in the `RBTreeOptions` interface.
34
+ */
35
+ constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<RBTreeOptions>);
30
36
  protected _root: N;
31
37
  get root(): N;
32
38
  protected _size: number;
33
39
  get size(): number;
40
+ /**
41
+ * The function creates a new Red-Black Tree node with the specified key, value, and color.
42
+ * @param {BTNKey} key - The key parameter is the key value associated with the node. It is used to
43
+ * identify and compare nodes in the Red-Black Tree.
44
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
45
+ * associated with the node. It is of type `V`, which is a generic type that can be replaced with any
46
+ * specific type when using the `createNode` method.
47
+ * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
48
+ * Red-Black Tree. It can be either "RED" or "BLACK". By default, the color is set to "BLACK".
49
+ * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
50
+ * value, and color.
51
+ */
34
52
  createNode(key: BTNKey, value?: V, color?: RBTNColor): N;
53
+ /**
54
+ * The function creates a Red-Black Tree with the specified options and returns it.
55
+ * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
56
+ * passed to the `createTree` function. It is used to customize the behavior of the `RedBlackTree`
57
+ * class.
58
+ * @returns a new instance of a RedBlackTree object.
59
+ */
35
60
  createTree(options?: RBTreeOptions): TREE;
36
61
  /**
37
62
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
38
63
  * Space Complexity: O(1)
39
- *
40
- * The `add` function adds a new node to a Red-Black Tree data structure.
41
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
42
- * following types:
43
- * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
44
- * key in the node being added to the Red-Black Tree.
45
- * @returns The method returns either a node (`N`) or `undefined`.
46
64
  */
47
- add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
65
+ /**
66
+ * The function adds a node to a Red-Black Tree data structure.
67
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
68
+ * @returns The method `add` returns either an instance of `N` (the node that was added) or
69
+ * `undefined`.
70
+ */
71
+ add(keyOrNodeOrEntry: BTNodeExemplar<V, N>): N | undefined;
48
72
  /**
49
73
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
50
74
  * Space Complexity: O(1)
@@ -105,7 +129,6 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
105
129
  * Space Complexity: O(1)
106
130
  */
107
131
  clear(): void;
108
- init(elements: IterableEntriesOrKeys<V>): void;
109
132
  protected _setRoot(v: N): void;
110
133
  /**
111
134
  * Time Complexity: O(1)
@@ -170,4 +193,14 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
170
193
  * red-black tree.
171
194
  */
172
195
  protected _fixInsert(k: N): void;
196
+ /**
197
+ * The function replaces an old node with a new node while preserving the color of the old node.
198
+ * @param {N} oldNode - The `oldNode` parameter represents the node that needs to be replaced in a
199
+ * data structure. It is of type `N`, which is the type of the nodes in the data structure.
200
+ * @param {N} newNode - The `newNode` parameter is the node that will replace the `oldNode` in the
201
+ * data structure.
202
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
203
+ * superclass, passing in the `oldNode` and `newNode` as arguments.
204
+ */
205
+ protected _replaceNode(oldNode: N, newNode: N): N;
173
206
  }
@@ -27,9 +27,15 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
27
27
  */
28
28
  class RedBlackTree extends bst_1.BST {
29
29
  /**
30
- * The constructor function initializes a Red-Black Tree with an optional set of options.
31
- * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
32
- * passed to the constructor. It is used to configure the RBTree object with specific options.
30
+ * This is the constructor function for a Red-Black Tree data structure in TypeScript, which
31
+ * initializes the tree with optional elements and options.
32
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<V, N>`
33
+ * objects. It represents the initial elements that will be added to the RBTree during its
34
+ * construction. If this parameter is provided, the `addMany` method is called to add all the
35
+ * elements to the
36
+ * @param [options] - The `options` parameter is an optional object that allows you to customize the
37
+ * behavior of the RBTree. It is of type `Partial<RBTreeOptions>`, which means that you can provide
38
+ * only a subset of the properties defined in the `RBTreeOptions` interface.
33
39
  */
34
40
  constructor(elements, options) {
35
41
  super([], options);
@@ -37,7 +43,7 @@ class RedBlackTree extends bst_1.BST {
37
43
  this._size = 0;
38
44
  this._root = this.Sentinel;
39
45
  if (elements)
40
- this.init(elements);
46
+ super.addMany(elements);
41
47
  }
42
48
  get root() {
43
49
  return this._root;
@@ -45,36 +51,60 @@ class RedBlackTree extends bst_1.BST {
45
51
  get size() {
46
52
  return this._size;
47
53
  }
54
+ /**
55
+ * The function creates a new Red-Black Tree node with the specified key, value, and color.
56
+ * @param {BTNKey} key - The key parameter is the key value associated with the node. It is used to
57
+ * identify and compare nodes in the Red-Black Tree.
58
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
59
+ * associated with the node. It is of type `V`, which is a generic type that can be replaced with any
60
+ * specific type when using the `createNode` method.
61
+ * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
62
+ * Red-Black Tree. It can be either "RED" or "BLACK". By default, the color is set to "BLACK".
63
+ * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
64
+ * value, and color.
65
+ */
48
66
  createNode(key, value, color = types_1.RBTNColor.BLACK) {
49
67
  return new RedBlackTreeNode(key, value, color);
50
68
  }
69
+ /**
70
+ * The function creates a Red-Black Tree with the specified options and returns it.
71
+ * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
72
+ * passed to the `createTree` function. It is used to customize the behavior of the `RedBlackTree`
73
+ * class.
74
+ * @returns a new instance of a RedBlackTree object.
75
+ */
51
76
  createTree(options) {
52
77
  return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options));
53
78
  }
54
79
  /**
55
80
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
56
81
  * Space Complexity: O(1)
57
- *
58
- * The `add` function adds a new node to a Red-Black Tree data structure.
59
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
60
- * following types:
61
- * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
62
- * key in the node being added to the Red-Black Tree.
63
- * @returns The method returns either a node (`N`) or `undefined`.
64
82
  */
65
- add(keyOrNode, value) {
83
+ /**
84
+ * The function adds a node to a Red-Black Tree data structure.
85
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
86
+ * @returns The method `add` returns either an instance of `N` (the node that was added) or
87
+ * `undefined`.
88
+ */
89
+ add(keyOrNodeOrEntry) {
66
90
  let node;
67
- if (this.isNodeKey(keyOrNode)) {
68
- node = this.createNode(keyOrNode, value, types_1.RBTNColor.RED);
91
+ if (this.isNodeKey(keyOrNodeOrEntry)) {
92
+ node = this.createNode(keyOrNodeOrEntry, undefined, types_1.RBTNColor.RED);
69
93
  }
70
- else if (keyOrNode instanceof RedBlackTreeNode) {
71
- node = keyOrNode;
94
+ else if (keyOrNodeOrEntry instanceof RedBlackTreeNode) {
95
+ node = keyOrNodeOrEntry;
72
96
  }
73
- else if (keyOrNode === null) {
97
+ else if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) {
74
98
  return;
75
99
  }
76
- else if (keyOrNode === undefined) {
77
- return;
100
+ else if (this.isEntry(keyOrNodeOrEntry)) {
101
+ const [key, value] = keyOrNodeOrEntry;
102
+ if (key === undefined || key === null) {
103
+ return;
104
+ }
105
+ else {
106
+ node = this.createNode(key, value, types_1.RBTNColor.RED);
107
+ }
78
108
  }
79
109
  else {
80
110
  return;
@@ -93,6 +123,9 @@ class RedBlackTree extends bst_1.BST {
93
123
  x = x === null || x === void 0 ? void 0 : x.right;
94
124
  }
95
125
  else {
126
+ if (node !== x) {
127
+ this._replaceNode(x, node);
128
+ }
96
129
  return;
97
130
  }
98
131
  }
@@ -203,6 +236,10 @@ class RedBlackTree extends bst_1.BST {
203
236
  isRealNode(node) {
204
237
  return node !== this.Sentinel && node !== undefined;
205
238
  }
239
+ /**
240
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
241
+ * Space Complexity: O(1)
242
+ */
206
243
  /**
207
244
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
208
245
  * Space Complexity: O(1)
@@ -228,7 +265,7 @@ class RedBlackTree extends bst_1.BST {
228
265
  var _a;
229
266
  if (identifier instanceof binary_tree_1.BinaryTreeNode)
230
267
  callback = (node => node);
231
- beginRoot = this.ensureNotKey(beginRoot);
268
+ beginRoot = this.ensureNode(beginRoot);
232
269
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
233
270
  }
234
271
  /**
@@ -287,19 +324,6 @@ class RedBlackTree extends bst_1.BST {
287
324
  this._root = this.Sentinel;
288
325
  this._size = 0;
289
326
  }
290
- init(elements) {
291
- if (elements) {
292
- for (const entryOrKey of elements) {
293
- if (Array.isArray(entryOrKey)) {
294
- const [key, value] = entryOrKey;
295
- this.add(key, value);
296
- }
297
- else {
298
- this.add(entryOrKey);
299
- }
300
- }
301
- }
302
- }
303
327
  _setRoot(v) {
304
328
  if (v) {
305
329
  v.parent = undefined;
@@ -529,5 +553,18 @@ class RedBlackTree extends bst_1.BST {
529
553
  }
530
554
  this.root.color = types_1.RBTNColor.BLACK;
531
555
  }
556
+ /**
557
+ * The function replaces an old node with a new node while preserving the color of the old node.
558
+ * @param {N} oldNode - The `oldNode` parameter represents the node that needs to be replaced in a
559
+ * data structure. It is of type `N`, which is the type of the nodes in the data structure.
560
+ * @param {N} newNode - The `newNode` parameter is the node that will replace the `oldNode` in the
561
+ * data structure.
562
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
563
+ * superclass, passing in the `oldNode` and `newNode` as arguments.
564
+ */
565
+ _replaceNode(oldNode, newNode) {
566
+ newNode.color = oldNode.color;
567
+ return super._replaceNode(oldNode, newNode);
568
+ }
532
569
  }
533
570
  exports.RedBlackTree = RedBlackTree;
@@ -5,8 +5,8 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BTNKey, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
9
- import { BiTreeDeleteResult, BTNCallback, IterableEntriesOrKeys, IterationType, TreeMultimapNested } from '../../types';
8
+ import type { BSTNodeKeyOrNode, BTNKey, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } 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> {
@@ -27,13 +27,7 @@ export declare class TreeMultimapNode<V = any, N extends TreeMultimapNode<V, N>
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
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
- /**
31
- * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
32
- * merge duplicated values.
33
- * @param {TreeMultimapOptions} [options] - An optional object that contains additional configuration options for the
34
- * TreeMultimap.
35
- */
36
- constructor(elements?: IterableEntriesOrKeys<V>, options?: Partial<TreeMultimapOptions>);
30
+ constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<TreeMultimapOptions>);
37
31
  private _count;
38
32
  get count(): number;
39
33
  /**
@@ -47,39 +41,38 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
47
41
  */
48
42
  createNode(key: BTNKey, value?: V, count?: number): N;
49
43
  createTree(options?: TreeMultimapOptions): TREE;
44
+ /**
45
+ * 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.
46
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
47
+ */
50
48
  /**
51
49
  * 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.
52
50
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
53
51
  *
54
- * The `add` function adds a new node to the tree multimap, updating the count if the key already
55
- * exists, and balances the tree if necessary.
56
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
57
- * following types:
58
- * @param {V} [value] - The `value` parameter represents the value associated with the key that is
59
- * being added to the tree. It is an optional parameter, so it can be omitted if not needed.
52
+ * The `add` function overrides the base class `add` function to add a new node to the tree multimap
53
+ * and update the count.
54
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
60
55
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
61
- * times the key-value pair should be added to the multimap. If not provided, the default value is 1.
62
- * @returns a node (`N`) or `undefined`.
56
+ * times the key or node or entry should be added to the multimap. If not provided, the default value
57
+ * is 1.
58
+ * @returns either a node (`N`) or `undefined`.
63
59
  */
64
- add(keyOrNode: BTNKey | N | null | undefined, value?: V, count?: number): N | undefined;
60
+ add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count?: number): N | undefined;
65
61
  /**
66
- * 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.
62
+ * Time Complexity: O(k 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.
67
63
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
68
64
  */
69
65
  /**
70
- * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
66
+ * Time Complexity: O(k 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.
71
67
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
72
68
  *
73
- * The function `addMany` takes an array of keys or nodes and adds them to the TreeMultimap,
74
- * returning an array of the inserted nodes.
75
- * @param {(BTNKey | N | undefined)[]} keysOrNodes - An array of keys or nodes. Each element can be
76
- * of type BTNKey, N, or undefined.
77
- * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond to the
78
- * keys or nodes being added. It is used to associate data with each key or node being added to the
79
- * TreeMultimap. If provided, the length of the `data` array should be the same as the length of the
80
- * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
69
+ * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
70
+ * structure.
71
+ * @param keysOrNodesOrEntries - The parameter `keysOrNodesOrEntries` is an iterable that can contain
72
+ * either keys, nodes, or entries.
73
+ * @returns The method is returning an array of type `N | undefined`.
81
74
  */
82
- addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: V[]): (N | undefined)[];
75
+ addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<V, N>>): (N | undefined)[];
83
76
  /**
84
77
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
85
78
  * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
@@ -128,11 +121,6 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
128
121
  * The clear() function clears the contents of a data structure and sets the count to zero.
129
122
  */
130
123
  clear(): void;
131
- /**
132
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
133
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
134
- */
135
- init(elements: IterableEntriesOrKeys<V>): void;
136
124
  /**
137
125
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
138
126
  * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
@@ -148,9 +136,9 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
148
136
  * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
149
137
  * added, or `undefined` if no node was added.
150
138
  */
151
- protected _addTo(newNode: N | undefined, parent: BTNKey | N | undefined): N | undefined;
139
+ protected _addTo(newNode: N | undefined, parent: BSTNodeKeyOrNode<N>): N | undefined;
152
140
  /**
153
- * The `_swap` function swaps the key, value, count, and height properties between two nodes.
141
+ * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
154
142
  * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node from
155
143
  * which the values will be swapped. It can be of type `BTNKey`, `N`, or `undefined`.
156
144
  * @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
@@ -158,5 +146,6 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
158
146
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
159
147
  * if either `srcNode` or `destNode` is undefined.
160
148
  */
161
- protected _swap(srcNode: BTNKey | N | undefined, destNode: BTNKey | N | undefined): N | undefined;
149
+ protected _swapProperties(srcNode: BSTNodeKeyOrNode<N>, destNode: BSTNodeKeyOrNode<N>): N | undefined;
150
+ protected _replaceNode(oldNode: N, newNode: N): N;
162
151
  }