data-structure-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 (77) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +10 -7
  2. package/.github/workflows/ci.yml +1 -1
  3. package/.github/workflows/release-package.yml +1 -1
  4. package/CHANGELOG.md +1 -1
  5. package/CODE_OF_CONDUCT.md +32 -10
  6. package/COMMANDS.md +3 -1
  7. package/CONTRIBUTING.md +4 -3
  8. package/README.md +103 -28
  9. package/SECURITY.md +1 -1
  10. package/benchmark/report.html +46 -1
  11. package/benchmark/report.json +563 -8
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +40 -22
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js +45 -36
  14. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +105 -113
  16. package/dist/cjs/data-structures/binary-tree/binary-tree.js +133 -119
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/bst.d.ts +53 -44
  19. package/dist/cjs/data-structures/binary-tree/bst.js +137 -154
  20. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +48 -15
  22. package/dist/cjs/data-structures/binary-tree/rb-tree.js +70 -33
  23. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +26 -37
  25. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +58 -137
  26. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  27. package/dist/cjs/data-structures/hash/hash-map.d.ts +2 -6
  28. package/dist/cjs/data-structures/hash/hash-map.js +5 -8
  29. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  30. package/dist/cjs/data-structures/trie/trie.d.ts +3 -0
  31. package/dist/cjs/data-structures/trie/trie.js +19 -4
  32. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  33. package/dist/cjs/interfaces/binary-tree.d.ts +3 -3
  34. package/dist/cjs/types/common.d.ts +6 -1
  35. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +1 -2
  36. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +40 -22
  37. package/dist/mjs/data-structures/binary-tree/avl-tree.js +45 -36
  38. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +105 -113
  39. package/dist/mjs/data-structures/binary-tree/binary-tree.js +133 -128
  40. package/dist/mjs/data-structures/binary-tree/bst.d.ts +53 -44
  41. package/dist/mjs/data-structures/binary-tree/bst.js +137 -154
  42. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +48 -15
  43. package/dist/mjs/data-structures/binary-tree/rb-tree.js +70 -33
  44. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +26 -37
  45. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +59 -138
  46. package/dist/mjs/data-structures/hash/hash-map.d.ts +2 -6
  47. package/dist/mjs/data-structures/hash/hash-map.js +5 -8
  48. package/dist/mjs/data-structures/trie/trie.d.ts +3 -0
  49. package/dist/mjs/data-structures/trie/trie.js +20 -4
  50. package/dist/mjs/interfaces/binary-tree.d.ts +3 -3
  51. package/dist/mjs/types/common.d.ts +6 -1
  52. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +1 -2
  53. package/dist/umd/data-structure-typed.js +422 -466
  54. package/dist/umd/data-structure-typed.min.js +2 -2
  55. package/dist/umd/data-structure-typed.min.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/data-structures/binary-tree/avl-tree.ts +59 -39
  58. package/src/data-structures/binary-tree/binary-tree.ts +192 -180
  59. package/src/data-structures/binary-tree/bst.ts +157 -154
  60. package/src/data-structures/binary-tree/rb-tree.ts +78 -37
  61. package/src/data-structures/binary-tree/tree-multimap.ts +67 -145
  62. package/src/data-structures/hash/hash-map.ts +8 -8
  63. package/src/data-structures/trie/trie.ts +23 -4
  64. package/src/interfaces/binary-tree.ts +3 -3
  65. package/src/types/common.ts +11 -1
  66. package/src/types/data-structures/hash/hash-map.ts +1 -2
  67. package/test/integration/{all-in-one.ts → all-in-one.test.ts} +1 -1
  68. package/test/integration/index.html +87 -0
  69. package/test/performance/data-structures/comparison/comparison.test.ts +5 -5
  70. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +19 -19
  71. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +50 -51
  72. package/test/unit/data-structures/binary-tree/bst.test.ts +49 -54
  73. package/test/unit/data-structures/binary-tree/overall.test.ts +17 -18
  74. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +3 -3
  75. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +118 -66
  76. package/test/unit/unrestricted-interconversion.test.ts +61 -5
  77. package/tsconfig-cjs.json +1 -1
@@ -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,6 +553,19 @@ 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;
534
571
  //# sourceMappingURL=rb-tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rb-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/rb-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAUqB;AACrB,+BAAqC;AAErC,+CAA+C;AAE/C,MAAa,gBAAwF,SAAQ,aAG5G;IAG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,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;IAED;;;;;;;;OAQG;IACO,YAAY,CAAC,OAAU,EAAE,OAAU;QAC3C,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE9B,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AAplBD,oCAolBC"}
@@ -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
  }
@@ -24,20 +24,17 @@ exports.TreeMultimapNode = TreeMultimapNode;
24
24
  * 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.
25
25
  */
26
26
  class TreeMultimap extends avl_tree_1.AVLTree {
27
- /**
28
- * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
29
- * merge duplicated values.
30
- * @param {TreeMultimapOptions} [options] - An optional object that contains additional configuration options for the
31
- * TreeMultimap.
32
- */
33
27
  constructor(elements, options) {
34
28
  super([], options);
35
29
  this._count = 0;
36
30
  if (elements)
37
- this.init(elements);
31
+ this.addMany(elements);
38
32
  }
33
+ // TODO the _count is not accurate after nodes count modified
39
34
  get count() {
40
- return this._count;
35
+ let sum = 0;
36
+ this.subTreeTraverse(node => sum += node.count);
37
+ return sum;
41
38
  }
42
39
  /**
43
40
  * The function creates a new BSTNode with the given key, value, and count.
@@ -54,131 +51,68 @@ class TreeMultimap extends avl_tree_1.AVLTree {
54
51
  createTree(options) {
55
52
  return new TreeMultimap([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options));
56
53
  }
54
+ /**
55
+ * 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.
56
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
57
+ */
57
58
  /**
58
59
  * 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.
59
60
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
60
61
  *
61
- * The `add` function adds a new node to the tree multimap, updating the count if the key already
62
- * exists, and balances the tree if necessary.
63
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
64
- * following types:
65
- * @param {V} [value] - The `value` parameter represents the value associated with the key that is
66
- * being added to the tree. It is an optional parameter, so it can be omitted if not needed.
62
+ * The `add` function overrides the base class `add` function to add a new node to the tree multimap
63
+ * and update the count.
64
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
67
65
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
68
- * times the key-value pair should be added to the multimap. If not provided, the default value is 1.
69
- * @returns a node (`N`) or `undefined`.
66
+ * times the key or node or entry should be added to the multimap. If not provided, the default value
67
+ * is 1.
68
+ * @returns either a node (`N`) or `undefined`.
70
69
  */
71
- add(keyOrNode, value, count = 1) {
72
- if (keyOrNode === null)
73
- return undefined;
74
- let inserted = undefined, newNode;
75
- if (keyOrNode instanceof TreeMultimapNode) {
76
- newNode = this.createNode(keyOrNode.key, keyOrNode.value, keyOrNode.count);
70
+ add(keyOrNodeOrEntry, count = 1) {
71
+ let newNode;
72
+ if (keyOrNodeOrEntry === undefined || keyOrNodeOrEntry === null) {
73
+ return;
77
74
  }
78
- else if (keyOrNode === undefined) {
79
- newNode = undefined;
75
+ else if (keyOrNodeOrEntry instanceof TreeMultimapNode) {
76
+ newNode = keyOrNodeOrEntry;
80
77
  }
81
- else {
82
- newNode = this.createNode(keyOrNode, value, count);
78
+ else if (this.isNodeKey(keyOrNodeOrEntry)) {
79
+ newNode = this.createNode(keyOrNodeOrEntry, undefined, count);
83
80
  }
84
- if (!this.root) {
85
- this._setRoot(newNode);
86
- this._size = this.size + 1;
87
- if (newNode)
88
- this._count += newNode.count;
89
- inserted = this.root;
81
+ else if (this.isEntry(keyOrNodeOrEntry)) {
82
+ const [key, value] = keyOrNodeOrEntry;
83
+ if (key === undefined || key === null) {
84
+ return;
85
+ }
86
+ else {
87
+ newNode = this.createNode(key, value, count);
88
+ }
90
89
  }
91
90
  else {
92
- let cur = this.root;
93
- let traversing = true;
94
- while (traversing) {
95
- if (cur) {
96
- if (newNode) {
97
- if (this._compare(cur.key, newNode.key) === types_1.CP.eq) {
98
- cur.value = newNode.value;
99
- cur.count += newNode.count;
100
- this._count += newNode.count;
101
- traversing = false;
102
- inserted = cur;
103
- }
104
- else if (this._compare(cur.key, newNode.key) === types_1.CP.gt) {
105
- // Traverse left of the node
106
- if (cur.left === undefined) {
107
- //Add to the left of the current node
108
- cur.left = newNode;
109
- this._size = this.size + 1;
110
- this._count += newNode.count;
111
- traversing = false;
112
- inserted = cur.left;
113
- }
114
- else {
115
- //Traverse the left of the current node
116
- if (cur.left)
117
- cur = cur.left;
118
- }
119
- }
120
- else if (this._compare(cur.key, newNode.key) === types_1.CP.lt) {
121
- // Traverse right of the node
122
- if (cur.right === undefined) {
123
- //Add to the right of the current node
124
- cur.right = newNode;
125
- this._size = this.size + 1;
126
- this._count += newNode.count;
127
- traversing = false;
128
- inserted = cur.right;
129
- }
130
- else {
131
- //Traverse the left of the current node
132
- if (cur.right)
133
- cur = cur.right;
134
- }
135
- }
136
- }
137
- else {
138
- // TODO may need to support undefined inserted
139
- }
140
- }
141
- else {
142
- traversing = false;
143
- }
144
- }
91
+ return;
92
+ }
93
+ const orgNodeCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
94
+ const inserted = super.add(newNode);
95
+ if (inserted) {
96
+ this._count += orgNodeCount;
145
97
  }
146
- if (inserted)
147
- this._balancePath(inserted);
148
98
  return inserted;
149
99
  }
150
100
  /**
151
- * 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.
101
+ * 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.
152
102
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
153
103
  */
154
104
  /**
155
- * 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.
105
+ * 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.
156
106
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
157
107
  *
158
- * The function `addMany` takes an array of keys or nodes and adds them to the TreeMultimap,
159
- * returning an array of the inserted nodes.
160
- * @param {(BTNKey | N | undefined)[]} keysOrNodes - An array of keys or nodes. Each element can be
161
- * of type BTNKey, N, or undefined.
162
- * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond to the
163
- * keys or nodes being added. It is used to associate data with each key or node being added to the
164
- * TreeMultimap. If provided, the length of the `data` array should be the same as the length of the
165
- * @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
108
+ * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
109
+ * structure.
110
+ * @param keysOrNodesOrEntries - The parameter `keysOrNodesOrEntries` is an iterable that can contain
111
+ * either keys, nodes, or entries.
112
+ * @returns The method is returning an array of type `N | undefined`.
166
113
  */
167
- addMany(keysOrNodes, data) {
168
- const inserted = [];
169
- for (let i = 0; i < keysOrNodes.length; i++) {
170
- const keyOrNode = keysOrNodes[i];
171
- if (keyOrNode instanceof TreeMultimapNode) {
172
- inserted.push(this.add(keyOrNode.key, keyOrNode.value, keyOrNode.count));
173
- continue;
174
- }
175
- if (keyOrNode === undefined) {
176
- inserted.push(this.add(NaN, undefined, 0));
177
- continue;
178
- }
179
- inserted.push(this.add(keyOrNode, data === null || data === void 0 ? void 0 : data[i], 1));
180
- }
181
- return inserted;
114
+ addMany(keysOrNodesOrEntries) {
115
+ return super.addMany(keysOrNodesOrEntries);
182
116
  }
183
117
  /**
184
118
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
@@ -206,7 +140,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
206
140
  return;
207
141
  const m = l + Math.floor((r - l) / 2);
208
142
  const midNode = sorted[m];
209
- this.add(midNode.key, midNode.value, midNode.count);
143
+ this.add([midNode.key, midNode.value], midNode.count);
210
144
  buildBalanceBST(l, m - 1);
211
145
  buildBalanceBST(m + 1, r);
212
146
  };
@@ -222,7 +156,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
222
156
  if (l <= r) {
223
157
  const m = l + Math.floor((r - l) / 2);
224
158
  const midNode = sorted[m];
225
- this.add(midNode.key, midNode.value, midNode.count);
159
+ this.add([midNode.key, midNode.value], midNode.count);
226
160
  stack.push([m + 1, r]);
227
161
  stack.push([l, m - 1]);
228
162
  }
@@ -289,7 +223,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
289
223
  const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : undefined;
290
224
  if (leftSubTreeRightMost) {
291
225
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
292
- orgCurrent = this._swap(curr, leftSubTreeRightMost);
226
+ orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
293
227
  if (parentOfLeftSubTreeMax) {
294
228
  if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
295
229
  parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
@@ -323,23 +257,6 @@ class TreeMultimap extends avl_tree_1.AVLTree {
323
257
  super.clear();
324
258
  this._count = 0;
325
259
  }
326
- /**
327
- * 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.
328
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
329
- */
330
- init(elements) {
331
- if (elements) {
332
- for (const entryOrKey of elements) {
333
- if (Array.isArray(entryOrKey)) {
334
- const [key, value] = entryOrKey;
335
- this.add(key, value);
336
- }
337
- else {
338
- this.add(entryOrKey);
339
- }
340
- }
341
- }
342
- }
343
260
  /**
344
261
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
345
262
  * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
@@ -356,7 +273,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
356
273
  * added, or `undefined` if no node was added.
357
274
  */
358
275
  _addTo(newNode, parent) {
359
- parent = this.ensureNotKey(parent);
276
+ parent = this.ensureNode(parent);
360
277
  if (parent) {
361
278
  if (parent.left === undefined) {
362
279
  parent.left = newNode;
@@ -383,7 +300,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
383
300
  }
384
301
  }
385
302
  /**
386
- * The `_swap` function swaps the key, value, count, and height properties between two nodes.
303
+ * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
387
304
  * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node from
388
305
  * which the values will be swapped. It can be of type `BTNKey`, `N`, or `undefined`.
389
306
  * @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
@@ -391,9 +308,9 @@ class TreeMultimap extends avl_tree_1.AVLTree {
391
308
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
392
309
  * if either `srcNode` or `destNode` is undefined.
393
310
  */
394
- _swap(srcNode, destNode) {
395
- srcNode = this.ensureNotKey(srcNode);
396
- destNode = this.ensureNotKey(destNode);
311
+ _swapProperties(srcNode, destNode) {
312
+ srcNode = this.ensureNode(srcNode);
313
+ destNode = this.ensureNode(destNode);
397
314
  if (srcNode && destNode) {
398
315
  const { key, value, count, height } = destNode;
399
316
  const tempNode = this.createNode(key, value, count);
@@ -412,6 +329,10 @@ class TreeMultimap extends avl_tree_1.AVLTree {
412
329
  }
413
330
  return undefined;
414
331
  }
332
+ _replaceNode(oldNode, newNode) {
333
+ newNode.count = oldNode.count + newNode.count;
334
+ return super._replaceNode(oldNode, newNode);
335
+ }
415
336
  }
416
337
  exports.TreeMultimap = TreeMultimap;
417
338
  //# sourceMappingURL=tree-multimap.js.map