data-structure-typed 1.47.5 → 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 (169) 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 +36 -18
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js +46 -29
  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 +158 -129
  16. package/dist/cjs/data-structures/binary-tree/binary-tree.js +182 -184
  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 +73 -63
  19. package/dist/cjs/data-structures/binary-tree/bst.js +168 -169
  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 +54 -17
  22. package/dist/cjs/data-structures/binary-tree/rb-tree.js +77 -31
  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 +29 -40
  25. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +66 -136
  26. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  27. package/dist/cjs/data-structures/graph/abstract-graph.js +1 -1
  28. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  29. package/dist/cjs/data-structures/hash/hash-map.d.ts +2 -6
  30. package/dist/cjs/data-structures/hash/hash-map.js +5 -8
  31. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  32. package/dist/cjs/data-structures/heap/heap.d.ts +19 -21
  33. package/dist/cjs/data-structures/heap/heap.js +52 -34
  34. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  35. package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -5
  36. package/dist/cjs/data-structures/heap/max-heap.js +2 -2
  37. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -5
  39. package/dist/cjs/data-structures/heap/min-heap.js +2 -2
  40. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  41. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  42. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +9 -1
  43. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  44. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  45. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +8 -1
  46. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  47. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -5
  48. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +2 -2
  49. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  50. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -5
  51. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +2 -2
  52. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -5
  54. package/dist/cjs/data-structures/priority-queue/priority-queue.js +2 -2
  55. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/queue/deque.d.ts +1 -0
  57. package/dist/cjs/data-structures/queue/deque.js +3 -0
  58. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  59. package/dist/cjs/data-structures/queue/queue.d.ts +1 -0
  60. package/dist/cjs/data-structures/queue/queue.js +3 -0
  61. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  62. package/dist/cjs/data-structures/stack/stack.d.ts +2 -1
  63. package/dist/cjs/data-structures/stack/stack.js +10 -2
  64. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +3 -0
  66. package/dist/cjs/data-structures/trie/trie.js +19 -4
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/interfaces/binary-tree.d.ts +4 -2
  69. package/dist/cjs/types/common.d.ts +7 -0
  70. package/dist/cjs/types/common.js.map +1 -1
  71. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  72. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +2 -2
  73. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +1 -2
  74. package/dist/cjs/types/data-structures/heap/heap.d.ts +4 -1
  75. package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +2 -1
  76. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +36 -18
  77. package/dist/mjs/data-structures/binary-tree/avl-tree.js +49 -30
  78. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +158 -129
  79. package/dist/mjs/data-structures/binary-tree/binary-tree.js +182 -194
  80. package/dist/mjs/data-structures/binary-tree/bst.d.ts +73 -63
  81. package/dist/mjs/data-structures/binary-tree/bst.js +171 -170
  82. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +54 -17
  83. package/dist/mjs/data-structures/binary-tree/rb-tree.js +81 -33
  84. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +29 -40
  85. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +70 -138
  86. package/dist/mjs/data-structures/graph/abstract-graph.js +1 -1
  87. package/dist/mjs/data-structures/hash/hash-map.d.ts +2 -6
  88. package/dist/mjs/data-structures/hash/hash-map.js +5 -8
  89. package/dist/mjs/data-structures/heap/heap.d.ts +19 -21
  90. package/dist/mjs/data-structures/heap/heap.js +53 -35
  91. package/dist/mjs/data-structures/heap/max-heap.d.ts +2 -5
  92. package/dist/mjs/data-structures/heap/max-heap.js +2 -2
  93. package/dist/mjs/data-structures/heap/min-heap.d.ts +2 -5
  94. package/dist/mjs/data-structures/heap/min-heap.js +2 -2
  95. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  96. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +9 -1
  97. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  98. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +8 -1
  99. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -5
  100. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +2 -2
  101. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -5
  102. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +2 -2
  103. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +2 -5
  104. package/dist/mjs/data-structures/priority-queue/priority-queue.js +2 -2
  105. package/dist/mjs/data-structures/queue/deque.d.ts +1 -0
  106. package/dist/mjs/data-structures/queue/deque.js +3 -0
  107. package/dist/mjs/data-structures/queue/queue.d.ts +1 -0
  108. package/dist/mjs/data-structures/queue/queue.js +3 -0
  109. package/dist/mjs/data-structures/stack/stack.d.ts +2 -1
  110. package/dist/mjs/data-structures/stack/stack.js +10 -2
  111. package/dist/mjs/data-structures/trie/trie.d.ts +3 -0
  112. package/dist/mjs/data-structures/trie/trie.js +20 -4
  113. package/dist/mjs/interfaces/binary-tree.d.ts +4 -2
  114. package/dist/mjs/types/common.d.ts +7 -0
  115. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  116. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +2 -2
  117. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +1 -2
  118. package/dist/mjs/types/data-structures/heap/heap.d.ts +4 -1
  119. package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +2 -1
  120. package/dist/umd/data-structure-typed.js +629 -595
  121. package/dist/umd/data-structure-typed.min.js +2 -2
  122. package/dist/umd/data-structure-typed.min.js.map +1 -1
  123. package/package.json +1 -1
  124. package/src/data-structures/binary-tree/avl-tree.ts +61 -31
  125. package/src/data-structures/binary-tree/binary-tree.ts +283 -254
  126. package/src/data-structures/binary-tree/bst.ts +193 -170
  127. package/src/data-structures/binary-tree/rb-tree.ts +87 -32
  128. package/src/data-structures/binary-tree/tree-multimap.ts +76 -136
  129. package/src/data-structures/graph/abstract-graph.ts +1 -1
  130. package/src/data-structures/hash/hash-map.ts +8 -8
  131. package/src/data-structures/heap/heap.ts +57 -39
  132. package/src/data-structures/heap/max-heap.ts +5 -5
  133. package/src/data-structures/heap/min-heap.ts +5 -5
  134. package/src/data-structures/linked-list/doubly-linked-list.ts +10 -1
  135. package/src/data-structures/linked-list/singly-linked-list.ts +9 -1
  136. package/src/data-structures/priority-queue/max-priority-queue.ts +4 -3
  137. package/src/data-structures/priority-queue/min-priority-queue.ts +12 -12
  138. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  139. package/src/data-structures/queue/deque.ts +4 -0
  140. package/src/data-structures/queue/queue.ts +4 -0
  141. package/src/data-structures/stack/stack.ts +12 -3
  142. package/src/data-structures/trie/trie.ts +23 -4
  143. package/src/interfaces/binary-tree.ts +14 -2
  144. package/src/types/common.ts +15 -1
  145. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  146. package/src/types/data-structures/binary-tree/bst.ts +2 -3
  147. package/src/types/data-structures/hash/hash-map.ts +1 -2
  148. package/src/types/data-structures/heap/heap.ts +3 -1
  149. package/src/types/data-structures/priority-queue/priority-queue.ts +3 -1
  150. package/test/integration/{all-in-one.ts → all-in-one.test.ts} +1 -1
  151. package/test/integration/index.html +87 -0
  152. package/test/performance/data-structures/comparison/comparison.test.ts +7 -6
  153. package/test/performance/data-structures/heap/heap.test.ts +2 -2
  154. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +1 -1
  155. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +20 -20
  156. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -57
  157. package/test/unit/data-structures/binary-tree/bst.test.ts +49 -54
  158. package/test/unit/data-structures/binary-tree/overall.test.ts +17 -18
  159. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +3 -3
  160. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +118 -66
  161. package/test/unit/data-structures/heap/heap.test.ts +2 -2
  162. package/test/unit/data-structures/heap/max-heap.test.ts +1 -1
  163. package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
  164. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +4 -3
  165. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +9 -10
  166. package/test/unit/data-structures/stack/stack.test.ts +2 -2
  167. package/test/unit/unrestricted-interconversion.test.ts +156 -0
  168. package/tsconfig-cjs.json +1 -1
  169. package/test/integration/conversion.test.ts +0 -0
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RBTreeOptions, 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> {
@@ -21,35 +21,54 @@ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N>
21
21
  */
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
- options: RBTreeOptions;
25
24
  /**
26
- * The constructor function initializes a Red-Black Tree with an optional set of options.
27
- * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
28
- * passed to the constructor. It is used to configure the RBTree object with specific options.
29
- */
30
- constructor(options?: 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>);
31
36
  protected _root: N;
32
37
  get root(): N;
33
38
  protected _size: number;
34
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
+ */
35
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
+ */
36
60
  createTree(options?: RBTreeOptions): TREE;
37
61
  /**
38
62
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
39
63
  * Space Complexity: O(1)
40
64
  */
41
65
  /**
42
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
43
- * Space Complexity: O(1)
44
- *
45
- * The `add` function adds a new node to a Red-Black Tree data structure.
46
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
47
- * following types:
48
- * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
49
- * key in the node being added to the Red-Black Tree.
50
- * @returns The method returns either a node (`N`) or `undefined`.
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`.
51
70
  */
52
- add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
71
+ add(keyOrNodeOrEntry: BTNodeExemplar<V, N>): N | undefined;
53
72
  /**
54
73
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
55
74
  * Space Complexity: O(1)
@@ -70,6 +89,10 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
70
89
  * @returns an array of `BiTreeDeleteResult<N>`.
71
90
  */
72
91
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback?: C): BiTreeDeleteResult<N>[];
92
+ /**
93
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
94
+ * Space Complexity: O(1)
95
+ */
73
96
  isRealNode(node: N | undefined): node is N;
74
97
  getNode<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
75
98
  getNode<C extends BTNCallback<N, N>>(identifier: N | undefined, callback?: C, beginRoot?: N | undefined, iterationType?: IterationType): N | undefined;
@@ -101,6 +124,10 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
101
124
  * @returns the predecessor of the given RedBlackTreeNode 'x'.
102
125
  */
103
126
  getPredecessor(x: N): N;
127
+ /**
128
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
129
+ * Space Complexity: O(1)
130
+ */
104
131
  clear(): void;
105
132
  protected _setRoot(v: N): void;
106
133
  /**
@@ -166,4 +193,14 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
166
193
  * red-black tree.
167
194
  */
168
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;
169
206
  }
@@ -27,21 +27,23 @@ 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
- constructor(options) {
35
- super(options);
40
+ constructor(elements, options) {
41
+ super([], options);
36
42
  this.Sentinel = new RedBlackTreeNode(NaN);
37
43
  this._size = 0;
38
- if (options) {
39
- this.options = Object.assign({ iterationType: types_1.IterationType.ITERATIVE, comparator: (a, b) => a - b }, options);
40
- }
41
- else {
42
- this.options = { iterationType: types_1.IterationType.ITERATIVE, comparator: (a, b) => a - b };
43
- }
44
44
  this._root = this.Sentinel;
45
+ if (elements)
46
+ super.addMany(elements);
45
47
  }
46
48
  get root() {
47
49
  return this._root;
@@ -49,40 +51,60 @@ class RedBlackTree extends bst_1.BST {
49
51
  get size() {
50
52
  return this._size;
51
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
+ */
52
66
  createNode(key, value, color = types_1.RBTNColor.BLACK) {
53
67
  return new RedBlackTreeNode(key, value, color);
54
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
+ */
55
76
  createTree(options) {
56
- return new RedBlackTree(Object.assign(Object.assign({}, this.options), options));
77
+ return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options));
57
78
  }
58
79
  /**
59
80
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
60
81
  * Space Complexity: O(1)
61
82
  */
62
83
  /**
63
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
64
- * Space Complexity: O(1)
65
- *
66
- * The `add` function adds a new node to a Red-Black Tree data structure.
67
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
68
- * following types:
69
- * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
70
- * key in the node being added to the Red-Black Tree.
71
- * @returns The method returns either a node (`N`) or `undefined`.
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`.
72
88
  */
73
- add(keyOrNode, value) {
89
+ add(keyOrNodeOrEntry) {
74
90
  let node;
75
- if (this.isNodeKey(keyOrNode)) {
76
- node = this.createNode(keyOrNode, value, types_1.RBTNColor.RED);
91
+ if (this.isNodeKey(keyOrNodeOrEntry)) {
92
+ node = this.createNode(keyOrNodeOrEntry, undefined, types_1.RBTNColor.RED);
77
93
  }
78
- else if (keyOrNode instanceof RedBlackTreeNode) {
79
- node = keyOrNode;
94
+ else if (keyOrNodeOrEntry instanceof RedBlackTreeNode) {
95
+ node = keyOrNodeOrEntry;
80
96
  }
81
- else if (keyOrNode === null) {
97
+ else if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) {
82
98
  return;
83
99
  }
84
- else if (keyOrNode === undefined) {
85
- 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
+ }
86
108
  }
87
109
  else {
88
110
  return;
@@ -101,6 +123,9 @@ class RedBlackTree extends bst_1.BST {
101
123
  x = x === null || x === void 0 ? void 0 : x.right;
102
124
  }
103
125
  else {
126
+ if (node !== x) {
127
+ this._replaceNode(x, node);
128
+ }
104
129
  return;
105
130
  }
106
131
  }
@@ -204,6 +229,10 @@ class RedBlackTree extends bst_1.BST {
204
229
  // TODO
205
230
  return ans;
206
231
  }
232
+ /**
233
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
234
+ * Space Complexity: O(1)
235
+ */
207
236
  isRealNode(node) {
208
237
  return node !== this.Sentinel && node !== undefined;
209
238
  }
@@ -232,11 +261,11 @@ class RedBlackTree extends bst_1.BST {
232
261
  * `getNodes` method, which is called within the `getNode` method.
233
262
  * @returns a value of type `N`, `null`, or `undefined`.
234
263
  */
235
- getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.options.iterationType) {
264
+ getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
236
265
  var _a;
237
266
  if (identifier instanceof binary_tree_1.BinaryTreeNode)
238
267
  callback = (node => node);
239
- beginRoot = this.ensureNotKey(beginRoot);
268
+ beginRoot = this.ensureNode(beginRoot);
240
269
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
241
270
  }
242
271
  /**
@@ -287,6 +316,10 @@ class RedBlackTree extends bst_1.BST {
287
316
  }
288
317
  return y;
289
318
  }
319
+ /**
320
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
321
+ * Space Complexity: O(1)
322
+ */
290
323
  clear() {
291
324
  this._root = this.Sentinel;
292
325
  this._size = 0;
@@ -520,6 +553,19 @@ class RedBlackTree extends bst_1.BST {
520
553
  }
521
554
  this.root.color = types_1.RBTNColor.BLACK;
522
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
+ }
523
569
  }
524
570
  exports.RedBlackTree = RedBlackTree;
525
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,uCASqB;AACrB,+BAAqC;AAErC,+CAA+C;AAE/C,MAAa,gBAAwF,SAAQ,aAG5G;IAGC,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;AAVD,4CAUC;AAED;;;;;;GAMG;AACH,MAAa,YACX,SAAQ,SAAe;IAKvB;;;;OAIG;IACH,YAAY,OAAuB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QATjB,aAAQ,GAAM,IAAI,gBAAgB,CAAI,GAAG,CAAiB,CAAC;QAwBjD,UAAK,GAAW,CAAC,CAAC;QAd1B,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,mBAAK,aAAa,EAAE,qBAAa,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAK,OAAO,CAAE,CAAA;SACnG;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,EAAE,aAAa,EAAE,qBAAa,CAAC,SAAS,EAAE,UAAU,EAAE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* @license MIT License
7
7
  */
8
- import type { BTNKey, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
8
+ import type { BSTNodeKeyOrNode, BTNKey, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
9
9
  import { BiTreeDeleteResult, BTNCallback, IterationType, TreeMultimapNested } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
@@ -27,14 +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
- options: TreeMultimapOptions;
31
- /**
32
- * The constructor function for a TreeMultimap class in TypeScript, which extends another class and sets an option to
33
- * merge duplicated values.
34
- * @param {TreeMultimapOptions} [options] - An optional object that contains additional configuration options for the
35
- * TreeMultimap.
36
- */
37
- constructor(options?: TreeMultimapOptions);
30
+ constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<TreeMultimapOptions>);
38
31
  private _count;
39
32
  get count(): number;
40
33
  /**
@@ -56,38 +49,33 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
56
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.
57
50
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
58
51
  *
59
- * The `add` function adds a new node to the tree multimap, updating the count if the key already
60
- * exists, and balances the tree if necessary.
61
- * @param {BTNKey | N | null | undefined} keyOrNode - The `keyOrNode` parameter can be one of the
62
- * following types:
63
- * @param {V} [value] - The `value` parameter represents the value associated with the key that is
64
- * 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:
65
55
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
66
- * times the key-value pair should be added to the multimap. If not provided, the default value is 1.
67
- * @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`.
68
59
  */
69
- add(keyOrNode: BTNKey | N | null | undefined, value?: V, count?: number): N | undefined;
60
+ add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count?: number): N | undefined;
70
61
  /**
71
- * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
72
- * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
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.
63
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
73
64
  */
74
65
  /**
75
- * 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.
76
67
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
77
68
  *
78
- * The function `addMany` takes an array of keys or nodes and adds them to the TreeMultimap,
79
- * returning an array of the inserted nodes.
80
- * @param {(BTNKey | N | undefined)[]} keysOrNodes - An array of keys or nodes. Each element can be
81
- * of type BTNKey, N, or undefined.
82
- * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond to the
83
- * keys or nodes being added. It is used to associate data with each key or node being added to the
84
- * TreeMultimap. If provided, the length of the `data` array should be the same as the length of the
85
- * @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`.
86
74
  */
87
- addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: V[]): (N | undefined)[];
75
+ addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<V, N>>): (N | undefined)[];
88
76
  /**
89
- * 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.
90
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
77
+ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
78
+ * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
91
79
  */
92
80
  /**
93
81
  * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
@@ -100,10 +88,10 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
100
88
  * values:
101
89
  * @returns a boolean value.
102
90
  */
103
- perfectlyBalance(iterationType?: IterationType | undefined): boolean;
91
+ perfectlyBalance(iterationType?: IterationType): boolean;
104
92
  /**
105
- * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
106
- * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
93
+ * 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.
94
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
107
95
  */
108
96
  /**
109
97
  * 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.
@@ -126,8 +114,8 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
126
114
  */
127
115
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BiTreeDeleteResult<N>[];
128
116
  /**
129
- * 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.
130
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
117
+ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
118
+ * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
131
119
  */
132
120
  /**
133
121
  * The clear() function clears the contents of a data structure and sets the count to zero.
@@ -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
  }