data-structure-typed 1.50.1 → 1.50.3

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 (196) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/README.md +30 -28
  3. package/README_zh-CN.md +1 -1
  4. package/SPECIFICATION.md +56 -0
  5. package/SPONSOR-zh-CN.md +90 -0
  6. package/SPONSOR.md +54 -0
  7. package/benchmark/report.html +13 -13
  8. package/benchmark/report.json +149 -161
  9. package/dist/cjs/data-structures/base/iterable-base.d.ts +120 -9
  10. package/dist/cjs/data-structures/base/iterable-base.js +143 -7
  11. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js +101 -72
  14. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  17. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js +484 -376
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/bst.d.ts +92 -79
  22. package/dist/cjs/data-structures/binary-tree/bst.js +68 -76
  23. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
  25. package/dist/cjs/data-structures/binary-tree/rb-tree.js +152 -99
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  28. package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
  29. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  30. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  31. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +102 -85
  32. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -78
  34. package/dist/cjs/data-structures/graph/abstract-graph.js +3 -189
  35. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/graph/directed-graph.d.ts +73 -0
  37. package/dist/cjs/data-structures/graph/directed-graph.js +131 -0
  38. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  39. package/dist/cjs/data-structures/graph/map-graph.d.ts +8 -0
  40. package/dist/cjs/data-structures/graph/map-graph.js +14 -0
  41. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  42. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +76 -7
  43. package/dist/cjs/data-structures/graph/undirected-graph.js +151 -18
  44. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  45. package/dist/cjs/data-structures/hash/hash-map.d.ts +254 -28
  46. package/dist/cjs/data-structures/hash/hash-map.js +347 -78
  47. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  48. package/dist/cjs/data-structures/heap/heap.d.ts +95 -25
  49. package/dist/cjs/data-structures/heap/heap.js +95 -26
  50. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  51. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  52. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +141 -77
  53. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  54. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  55. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +164 -115
  56. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  57. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  58. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +63 -36
  59. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  60. package/dist/cjs/data-structures/matrix/matrix.d.ts +35 -4
  61. package/dist/cjs/data-structures/matrix/matrix.js +50 -11
  62. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  63. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  64. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  65. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  66. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  67. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  68. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  69. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  70. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
  71. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  72. package/dist/cjs/data-structures/queue/deque.d.ts +139 -35
  73. package/dist/cjs/data-structures/queue/deque.js +200 -62
  74. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  75. package/dist/cjs/data-structures/queue/queue.d.ts +103 -49
  76. package/dist/cjs/data-structures/queue/queue.js +111 -49
  77. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  78. package/dist/cjs/data-structures/stack/stack.d.ts +51 -21
  79. package/dist/cjs/data-structures/stack/stack.js +58 -22
  80. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  81. package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
  82. package/dist/cjs/data-structures/tree/tree.js +77 -11
  83. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  84. package/dist/cjs/data-structures/trie/trie.d.ts +135 -34
  85. package/dist/cjs/data-structures/trie/trie.js +153 -33
  86. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  87. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  88. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +4 -3
  89. package/dist/cjs/types/utils/utils.d.ts +1 -0
  90. package/dist/mjs/data-structures/base/iterable-base.d.ts +120 -9
  91. package/dist/mjs/data-structures/base/iterable-base.js +143 -7
  92. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
  93. package/dist/mjs/data-structures/binary-tree/avl-tree.js +102 -73
  94. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  95. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  96. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
  97. package/dist/mjs/data-structures/binary-tree/binary-tree.js +483 -375
  98. package/dist/mjs/data-structures/binary-tree/bst.d.ts +92 -79
  99. package/dist/mjs/data-structures/binary-tree/bst.js +68 -76
  100. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
  101. package/dist/mjs/data-structures/binary-tree/rb-tree.js +153 -100
  102. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
  103. package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
  104. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  105. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +102 -86
  106. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -78
  107. package/dist/mjs/data-structures/graph/abstract-graph.js +3 -188
  108. package/dist/mjs/data-structures/graph/directed-graph.d.ts +73 -0
  109. package/dist/mjs/data-structures/graph/directed-graph.js +131 -0
  110. package/dist/mjs/data-structures/graph/map-graph.d.ts +8 -0
  111. package/dist/mjs/data-structures/graph/map-graph.js +14 -0
  112. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +76 -7
  113. package/dist/mjs/data-structures/graph/undirected-graph.js +152 -19
  114. package/dist/mjs/data-structures/hash/hash-map.d.ts +254 -28
  115. package/dist/mjs/data-structures/hash/hash-map.js +353 -84
  116. package/dist/mjs/data-structures/heap/heap.d.ts +95 -25
  117. package/dist/mjs/data-structures/heap/heap.js +95 -26
  118. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  119. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +144 -80
  120. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  121. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +166 -117
  122. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  123. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +63 -36
  124. package/dist/mjs/data-structures/matrix/matrix.d.ts +35 -4
  125. package/dist/mjs/data-structures/matrix/matrix.js +50 -11
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  127. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  129. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
  131. package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
  132. package/dist/mjs/data-structures/queue/deque.d.ts +139 -35
  133. package/dist/mjs/data-structures/queue/deque.js +205 -67
  134. package/dist/mjs/data-structures/queue/queue.d.ts +103 -49
  135. package/dist/mjs/data-structures/queue/queue.js +111 -49
  136. package/dist/mjs/data-structures/stack/stack.d.ts +51 -21
  137. package/dist/mjs/data-structures/stack/stack.js +58 -22
  138. package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
  139. package/dist/mjs/data-structures/tree/tree.js +80 -14
  140. package/dist/mjs/data-structures/trie/trie.d.ts +135 -34
  141. package/dist/mjs/data-structures/trie/trie.js +156 -36
  142. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  143. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +4 -3
  144. package/dist/mjs/types/utils/utils.d.ts +1 -0
  145. package/dist/umd/data-structure-typed.js +3121 -1583
  146. package/dist/umd/data-structure-typed.min.js +3 -3
  147. package/dist/umd/data-structure-typed.min.js.map +1 -1
  148. package/package.json +61 -55
  149. package/src/data-structures/base/iterable-base.ts +184 -19
  150. package/src/data-structures/binary-tree/avl-tree.ts +134 -100
  151. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  152. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  153. package/src/data-structures/binary-tree/bst.ts +127 -136
  154. package/src/data-structures/binary-tree/rb-tree.ts +199 -166
  155. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  156. package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
  157. package/src/data-structures/graph/abstract-graph.ts +4 -211
  158. package/src/data-structures/graph/directed-graph.ts +152 -0
  159. package/src/data-structures/graph/map-graph.ts +15 -0
  160. package/src/data-structures/graph/undirected-graph.ts +171 -19
  161. package/src/data-structures/hash/hash-map.ts +389 -96
  162. package/src/data-structures/heap/heap.ts +97 -26
  163. package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
  164. package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
  165. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  166. package/src/data-structures/matrix/matrix.ts +52 -12
  167. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  168. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  169. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  170. package/src/data-structures/queue/deque.ts +225 -70
  171. package/src/data-structures/queue/queue.ts +118 -49
  172. package/src/data-structures/stack/stack.ts +63 -23
  173. package/src/data-structures/tree/tree.ts +89 -15
  174. package/src/data-structures/trie/trie.ts +173 -38
  175. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  176. package/src/types/data-structures/hash/hash-map.ts +4 -3
  177. package/src/types/utils/utils.ts +2 -0
  178. package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
  179. package/test/performance/data-structures/queue/deque.test.ts +26 -25
  180. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +37 -0
  181. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -17
  182. package/test/unit/data-structures/binary-tree/bst.test.ts +65 -1
  183. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +38 -1
  184. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -32
  185. package/test/unit/data-structures/graph/abstract-graph.test.ts +11 -0
  186. package/test/unit/data-structures/graph/directed-graph.test.ts +190 -5
  187. package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
  188. package/test/unit/data-structures/hash/hash-map.test.ts +376 -353
  189. package/test/unit/data-structures/heap/heap.test.ts +18 -1
  190. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +24 -5
  191. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +20 -2
  192. package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
  193. package/test/unit/data-structures/queue/deque.test.ts +65 -5
  194. package/test/unit/data-structures/queue/queue.test.ts +24 -5
  195. package/test/unit/data-structures/stack/stack.test.ts +17 -0
  196. package/test/unit/data-structures/trie/trie.test.ts +17 -0
@@ -6,17 +6,118 @@
6
6
  * @license MIT License
7
7
  */
8
8
  export class SegmentTreeNode {
9
- start = 0;
10
- end = 0;
11
- value = undefined;
12
- sum = 0;
13
- left = undefined;
14
- right = undefined;
9
+ /**
10
+ * The constructor initializes the properties of a SegmentTreeNode object.
11
+ * @param {number} start - The `start` parameter represents the starting index of the segment covered
12
+ * by this node in a segment tree.
13
+ * @param {number} end - The `end` parameter represents the end index of the segment covered by this
14
+ * node in a segment tree.
15
+ * @param {number} sum - The `sum` parameter represents the sum of the values in the range covered by
16
+ * the segment tree node.
17
+ * @param {SegmentTreeNodeVal | undefined} [value] - The `value` parameter is an optional parameter
18
+ * of type `SegmentTreeNodeVal`. It represents the value associated with the segment tree node.
19
+ */
15
20
  constructor(start, end, sum, value) {
16
- this.start = start;
17
- this.end = end;
18
- this.sum = sum;
19
- this.value = value || undefined;
21
+ this._start = start;
22
+ this._end = end;
23
+ this._sum = sum;
24
+ this._value = value || undefined;
25
+ }
26
+ _start = 0;
27
+ /**
28
+ * The function returns the value of the protected variable _start.
29
+ * @returns The start value, which is of type number.
30
+ */
31
+ get start() {
32
+ return this._start;
33
+ }
34
+ /**
35
+ * The above function sets the value of the "start" property.
36
+ * @param {number} value - The value parameter is of type number.
37
+ */
38
+ set start(value) {
39
+ this._start = value;
40
+ }
41
+ _end = 0;
42
+ /**
43
+ * The function returns the value of the protected variable `_end`.
44
+ * @returns The value of the protected property `_end`.
45
+ */
46
+ get end() {
47
+ return this._end;
48
+ }
49
+ /**
50
+ * The above function sets the value of the "end" property.
51
+ * @param {number} value - The value parameter is a number that represents the new value for the end
52
+ * property.
53
+ */
54
+ set end(value) {
55
+ this._end = value;
56
+ }
57
+ _value = undefined;
58
+ /**
59
+ * The function returns the value of a segment tree node.
60
+ * @returns The value being returned is either a `SegmentTreeNodeVal` object or `undefined`.
61
+ */
62
+ get value() {
63
+ return this._value;
64
+ }
65
+ /**
66
+ * The function sets the value of a segment tree node.
67
+ * @param {SegmentTreeNodeVal | undefined} value - The `value` parameter is of type
68
+ * `SegmentTreeNodeVal` or `undefined`.
69
+ */
70
+ set value(value) {
71
+ this._value = value;
72
+ }
73
+ _sum = 0;
74
+ /**
75
+ * The function returns the value of the sum property.
76
+ * @returns The method is returning the value of the variable `_sum`.
77
+ */
78
+ get sum() {
79
+ return this._sum;
80
+ }
81
+ /**
82
+ * The above function sets the value of the sum property.
83
+ * @param {number} value - The parameter "value" is of type "number".
84
+ */
85
+ set sum(value) {
86
+ this._sum = value;
87
+ }
88
+ _left = undefined;
89
+ /**
90
+ * The function returns the left child of a segment tree node.
91
+ * @returns The `left` property of the `SegmentTreeNode` object is being returned. It is of type
92
+ * `SegmentTreeNode` or `undefined`.
93
+ */
94
+ get left() {
95
+ return this._left;
96
+ }
97
+ /**
98
+ * The function sets the value of the left property of a SegmentTreeNode object.
99
+ * @param {SegmentTreeNode | undefined} value - The value parameter is of type SegmentTreeNode or
100
+ * undefined.
101
+ */
102
+ set left(value) {
103
+ this._left = value;
104
+ }
105
+ _right = undefined;
106
+ /**
107
+ * The function returns the right child of a segment tree node.
108
+ * @returns The `getRight()` method is returning a value of type `SegmentTreeNode` or `undefined`.
109
+ */
110
+ get right() {
111
+ return this._right;
112
+ }
113
+ /**
114
+ * The function sets the right child of a segment tree node.
115
+ * @param {SegmentTreeNode | undefined} value - The `value` parameter is of type `SegmentTreeNode |
116
+ * undefined`. This means that it can accept either a `SegmentTreeNode` object or `undefined` as its
117
+ * value.
118
+ */
119
+ set right(value) {
120
+ this._right = value;
20
121
  }
21
122
  }
22
123
  export class SegmentTree {
@@ -44,18 +145,34 @@ export class SegmentTree {
44
145
  }
45
146
  }
46
147
  _values = [];
148
+ /**
149
+ * The function returns an array of numbers.
150
+ * @returns An array of numbers is being returned.
151
+ */
47
152
  get values() {
48
153
  return this._values;
49
154
  }
50
155
  _start = 0;
156
+ /**
157
+ * The function returns the value of the protected variable _start.
158
+ * @returns The start value, which is of type number.
159
+ */
51
160
  get start() {
52
161
  return this._start;
53
162
  }
54
163
  _end;
164
+ /**
165
+ * The function returns the value of the protected variable `_end`.
166
+ * @returns The value of the protected property `_end`.
167
+ */
55
168
  get end() {
56
169
  return this._end;
57
170
  }
58
171
  _root;
172
+ /**
173
+ * The function returns the root node of a segment tree.
174
+ * @returns The `root` property of the class `SegmentTreeNode` or `undefined` if it is not defined.
175
+ */
59
176
  get root() {
60
177
  return this._root;
61
178
  }
@@ -9,8 +9,7 @@ import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEnt
9
9
  import { IterationType } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
- export declare class TreeMultimapNode<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNodeNested<K, V>> extends AVLTreeNode<K, V, N> {
13
- count: number;
12
+ export declare class TreeMultimapNode<K = any, V = any, NODE extends TreeMultimapNode<K, V, NODE> = TreeMultimapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
14
13
  /**
15
14
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
16
15
  * @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
@@ -22,48 +21,73 @@ export declare class TreeMultimapNode<K = any, V = any, N extends TreeMultimapNo
22
21
  * parameter when creating a new instance of the `BinaryTreeNode` class.
23
22
  */
24
23
  constructor(key: K, value?: V, count?: number);
24
+ protected _count: number;
25
+ /**
26
+ * The function returns the value of the protected variable _count.
27
+ * @returns The count property of the object, which is of type number.
28
+ */
29
+ get count(): number;
30
+ /**
31
+ * The above function sets the value of the count property.
32
+ * @param {number} value - The value parameter is of type number, which means it can accept any
33
+ * numeric value.
34
+ */
35
+ set count(value: number);
25
36
  }
26
37
  /**
27
38
  * 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
39
  */
29
- export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>, TREE extends TreeMultimap<K, V, N, TREE> = TreeMultimap<K, V, N, TreeMultimapNested<K, V, N>>> extends AVLTree<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
30
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, N>>, options?: TreeMultimapOptions<K>);
31
- private _count;
40
+ export declare class TreeMultimap<K = any, V = any, NODE extends TreeMultimapNode<K, V, NODE> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>, TREE extends TreeMultimap<K, V, NODE, TREE> = TreeMultimap<K, V, NODE, TreeMultimapNested<K, V, NODE>>> extends AVLTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
41
+ constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultimapOptions<K>);
42
+ protected _count: number;
43
+ /**
44
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
45
+ * search.
46
+ * @returns the sum of the count property of all nodes in the tree.
47
+ */
32
48
  get count(): number;
33
49
  /**
34
50
  * The function creates a new BSTNode with the given key, value, and count.
35
51
  * @param {K} key - The key parameter is the unique identifier for the binary tree node. It is used to
36
52
  * distinguish one node from another in the tree.
37
- * @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
53
+ * @param {NODE} value - The `value` parameter represents the value that will be stored in the binary search tree node.
38
54
  * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
39
55
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
40
56
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
41
57
  */
42
- createNode(key: K, value?: V, count?: number): N;
58
+ createNode(key: K, value?: V, count?: number): NODE;
59
+ /**
60
+ * The function creates a new TreeMultimap object with the specified options and returns it.
61
+ * @param [options] - The `options` parameter is an optional object that contains additional
62
+ * configuration options for creating the `TreeMultimap` object. It can include properties such as
63
+ * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
64
+ * the tree, respectively. These properties can be
65
+ * @returns a new instance of the `TreeMultimap` class, with the provided options merged with the
66
+ * default options. The returned value is casted as `TREE`.
67
+ */
43
68
  createTree(options?: TreeMultimapOptions<K>): TREE;
44
69
  /**
45
- * The function `exemplarToNode` converts an keyOrNodeOrEntry object into a node object.
46
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`, which means it
70
+ * The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object.
71
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`, which means it
47
72
  * can be one of the following:
48
73
  * @param {V} [value] - The `value` parameter is an optional argument that represents the value
49
74
  * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
50
75
  * it defaults to `undefined`.
51
76
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
52
77
  * times the value should be added to the node. If not provided, it defaults to 1.
53
- * @returns a node of type `N` or `undefined`.
78
+ * @returns a node of type `NODE` or `undefined`.
54
79
  */
55
- exemplarToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): N | undefined;
80
+ keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
56
81
  /**
57
82
  * The function checks if an keyOrNodeOrEntry is an instance of the TreeMultimapNode class.
58
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
83
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
59
84
  * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the TreeMultimapNode
60
85
  * class.
61
86
  */
62
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is N;
87
+ isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
63
88
  /**
64
89
  * Time Complexity: O(log n)
65
90
  * Space Complexity: O(1)
66
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
67
91
  */
68
92
  /**
69
93
  * Time Complexity: O(log n)
@@ -81,47 +105,13 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
81
105
  * @returns The method is returning either the newly inserted node or `undefined` if the insertion
82
106
  * was not successful.
83
107
  */
84
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): boolean;
85
- /**
86
- * Time Complexity: O(k log n)
87
- * Space Complexity: O(1)
88
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
89
- */
90
- /**
91
- * Time Complexity: O(k log n)
92
- * Space Complexity: O(1)
93
- *
94
- * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
95
- * structure.
96
- * @param keysOrNodesOrEntries - The parameter `keysOrNodesOrEntries` is an iterable that can contain
97
- * either keys, nodes, or entries.
98
- * @returns The method is returning an array of type `N | undefined`.
99
- */
100
- addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, N>>): boolean[];
101
- /**
102
- * Time Complexity: O(n log n)
103
- * Space Complexity: O(n)
104
- * 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. linear space, as it creates an array to store the sorted nodes.
105
- */
106
- /**
107
- * Time Complexity: O(n log n)
108
- * Space Complexity: O(n)
109
- *
110
- * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
111
- * tree using either a recursive or iterative approach.
112
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
113
- * type of iteration to use when building the balanced binary search tree. It can have two possible
114
- * values:
115
- * @returns a boolean value.
116
- */
117
- perfectlyBalance(iterationType?: IterationType): boolean;
108
+ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
118
109
  /**
119
- * Time Complexity: O(k log n)
110
+ * Time Complexity: O(log n)
120
111
  * Space Complexity: O(1)
121
- * 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. constant space, as it doesn't use additional data structures that scale with input size.
122
112
  */
123
113
  /**
124
- * Time Complexity: O(k log n)
114
+ * Time Complexity: O(log n)
125
115
  * Space Complexity: O(1)
126
116
  *
127
117
  * The `delete` function in TypeScript is used to remove a node from a binary tree, taking into
@@ -137,9 +127,9 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
137
127
  * being deleted. If set to true, the count of the node will not be considered and the node will be
138
128
  * deleted regardless of its count. If set to false (default), the count of the node will be
139
129
  * decremented by 1 and
140
- * @returns an array of `BinaryTreeDeleteResult<N>`.
130
+ * @returns an array of `BinaryTreeDeleteResult<NODE>`.
141
131
  */
142
- delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<N>[];
132
+ delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
143
133
  /**
144
134
  * Time Complexity: O(1)
145
135
  * Space Complexity: O(1)
@@ -151,6 +141,22 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
151
141
  * The clear() function clears the contents of a data structure and sets the count to zero.
152
142
  */
153
143
  clear(): void;
144
+ /**
145
+ * Time Complexity: O(n log n)
146
+ * Space Complexity: O(log n)
147
+ */
148
+ /**
149
+ * Time Complexity: O(n log n)
150
+ * Space Complexity: O(log n)
151
+ *
152
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
153
+ * tree using either a recursive or iterative approach.
154
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
155
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
156
+ * values:
157
+ * @returns a boolean value.
158
+ */
159
+ perfectlyBalance(iterationType?: IterationType): boolean;
154
160
  /**
155
161
  * Time complexity: O(n)
156
162
  * Space complexity: O(n)
@@ -165,13 +171,21 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
165
171
  clone(): TREE;
166
172
  /**
167
173
  * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
168
- * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node from
169
- * which the values will be swapped. It can be of type `K`, `N`, or `undefined`.
170
- * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
174
+ * @param {K | NODE | undefined} srcNode - The `srcNode` parameter represents the source node from
175
+ * which the values will be swapped. It can be of type `K`, `NODE`, or `undefined`.
176
+ * @param {K | NODE | undefined} destNode - The `destNode` parameter represents the destination
171
177
  * node where the values from the source node will be swapped to.
172
178
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
173
179
  * if either `srcNode` or `destNode` is undefined.
174
180
  */
175
- protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
176
- protected _replaceNode(oldNode: N, newNode: N): N;
181
+ protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
182
+ /**
183
+ * The function replaces an old node with a new node and updates the count property of the new node.
184
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
185
+ * needs to be replaced in a data structure.
186
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
187
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
188
+ * superclass, after updating the `count` property of the `newNode` object.
189
+ */
190
+ protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
177
191
  }
@@ -1,7 +1,6 @@
1
1
  import { FamilyPosition, IterationType } from '../../types';
2
2
  import { AVLTree, AVLTreeNode } from './avl-tree';
3
3
  export class TreeMultimapNode extends AVLTreeNode {
4
- count;
5
4
  /**
6
5
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
7
6
  * @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
@@ -16,6 +15,22 @@ export class TreeMultimapNode extends AVLTreeNode {
16
15
  super(key, value);
17
16
  this.count = count;
18
17
  }
18
+ _count = 1;
19
+ /**
20
+ * The function returns the value of the protected variable _count.
21
+ * @returns The count property of the object, which is of type number.
22
+ */
23
+ get count() {
24
+ return this._count;
25
+ }
26
+ /**
27
+ * The above function sets the value of the count property.
28
+ * @param {number} value - The value parameter is of type number, which means it can accept any
29
+ * numeric value.
30
+ */
31
+ set count(value) {
32
+ this._count = value;
33
+ }
19
34
  }
20
35
  /**
21
36
  * 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,6 +43,11 @@ export class TreeMultimap extends AVLTree {
28
43
  }
29
44
  _count = 0;
30
45
  // TODO the _count is not accurate after nodes count modified
46
+ /**
47
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
48
+ * search.
49
+ * @returns the sum of the count property of all nodes in the tree.
50
+ */
31
51
  get count() {
32
52
  let sum = 0;
33
53
  this.dfs(node => (sum += node.count));
@@ -37,7 +57,7 @@ export class TreeMultimap extends AVLTree {
37
57
  * The function creates a new BSTNode with the given key, value, and count.
38
58
  * @param {K} key - The key parameter is the unique identifier for the binary tree node. It is used to
39
59
  * distinguish one node from another in the tree.
40
- * @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
60
+ * @param {NODE} value - The `value` parameter represents the value that will be stored in the binary search tree node.
41
61
  * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
42
62
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
43
63
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
@@ -45,6 +65,15 @@ export class TreeMultimap extends AVLTree {
45
65
  createNode(key, value, count) {
46
66
  return new TreeMultimapNode(key, value, count);
47
67
  }
68
+ /**
69
+ * The function creates a new TreeMultimap object with the specified options and returns it.
70
+ * @param [options] - The `options` parameter is an optional object that contains additional
71
+ * configuration options for creating the `TreeMultimap` object. It can include properties such as
72
+ * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
73
+ * the tree, respectively. These properties can be
74
+ * @returns a new instance of the `TreeMultimap` class, with the provided options merged with the
75
+ * default options. The returned value is casted as `TREE`.
76
+ */
48
77
  createTree(options) {
49
78
  return new TreeMultimap([], {
50
79
  iterationType: this.iterationType,
@@ -53,17 +82,17 @@ export class TreeMultimap extends AVLTree {
53
82
  });
54
83
  }
55
84
  /**
56
- * The function `exemplarToNode` converts an keyOrNodeOrEntry object into a node object.
57
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`, which means it
85
+ * The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object.
86
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`, which means it
58
87
  * can be one of the following:
59
88
  * @param {V} [value] - The `value` parameter is an optional argument that represents the value
60
89
  * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
61
90
  * it defaults to `undefined`.
62
91
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
63
92
  * times the value should be added to the node. If not provided, it defaults to 1.
64
- * @returns a node of type `N` or `undefined`.
93
+ * @returns a node of type `NODE` or `undefined`.
65
94
  */
66
- exemplarToNode(keyOrNodeOrEntry, value, count = 1) {
95
+ keyValueOrEntryToNode(keyOrNodeOrEntry, value, count = 1) {
67
96
  let node;
68
97
  if (keyOrNodeOrEntry === undefined || keyOrNodeOrEntry === null) {
69
98
  return;
@@ -90,7 +119,7 @@ export class TreeMultimap extends AVLTree {
90
119
  }
91
120
  /**
92
121
  * The function checks if an keyOrNodeOrEntry is an instance of the TreeMultimapNode class.
93
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
122
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
94
123
  * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the TreeMultimapNode
95
124
  * class.
96
125
  */
@@ -100,7 +129,6 @@ export class TreeMultimap extends AVLTree {
100
129
  /**
101
130
  * Time Complexity: O(log n)
102
131
  * Space Complexity: O(1)
103
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
104
132
  */
105
133
  /**
106
134
  * Time Complexity: O(log n)
@@ -119,7 +147,7 @@ export class TreeMultimap extends AVLTree {
119
147
  * was not successful.
120
148
  */
121
149
  add(keyOrNodeOrEntry, value, count = 1) {
122
- const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
150
+ const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value, count);
123
151
  if (newNode === undefined)
124
152
  return false;
125
153
  const orgNodeCount = newNode?.count || 0;
@@ -130,82 +158,11 @@ export class TreeMultimap extends AVLTree {
130
158
  return true;
131
159
  }
132
160
  /**
133
- * Time Complexity: O(k log n)
134
- * Space Complexity: O(1)
135
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
136
- */
137
- /**
138
- * Time Complexity: O(k log n)
139
- * Space Complexity: O(1)
140
- *
141
- * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
142
- * structure.
143
- * @param keysOrNodesOrEntries - The parameter `keysOrNodesOrEntries` is an iterable that can contain
144
- * either keys, nodes, or entries.
145
- * @returns The method is returning an array of type `N | undefined`.
146
- */
147
- addMany(keysOrNodesOrEntries) {
148
- return super.addMany(keysOrNodesOrEntries);
149
- }
150
- /**
151
- * Time Complexity: O(n log n)
152
- * Space Complexity: O(n)
153
- * 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. linear space, as it creates an array to store the sorted nodes.
154
- */
155
- /**
156
- * Time Complexity: O(n log n)
157
- * Space Complexity: O(n)
158
- *
159
- * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
160
- * tree using either a recursive or iterative approach.
161
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
162
- * type of iteration to use when building the balanced binary search tree. It can have two possible
163
- * values:
164
- * @returns a boolean value.
165
- */
166
- perfectlyBalance(iterationType = this.iterationType) {
167
- const sorted = this.dfs(node => node, 'in'), n = sorted.length;
168
- if (sorted.length < 1)
169
- return false;
170
- this.clear();
171
- if (iterationType === IterationType.RECURSIVE) {
172
- const buildBalanceBST = (l, r) => {
173
- if (l > r)
174
- return;
175
- const m = l + Math.floor((r - l) / 2);
176
- const midNode = sorted[m];
177
- this.add(midNode.key, midNode.value, midNode.count);
178
- buildBalanceBST(l, m - 1);
179
- buildBalanceBST(m + 1, r);
180
- };
181
- buildBalanceBST(0, n - 1);
182
- return true;
183
- }
184
- else {
185
- const stack = [[0, n - 1]];
186
- while (stack.length > 0) {
187
- const popped = stack.pop();
188
- if (popped) {
189
- const [l, r] = popped;
190
- if (l <= r) {
191
- const m = l + Math.floor((r - l) / 2);
192
- const midNode = sorted[m];
193
- this.add(midNode.key, midNode.value, midNode.count);
194
- stack.push([m + 1, r]);
195
- stack.push([l, m - 1]);
196
- }
197
- }
198
- }
199
- return true;
200
- }
201
- }
202
- /**
203
- * Time Complexity: O(k log n)
161
+ * Time Complexity: O(log n)
204
162
  * Space Complexity: O(1)
205
- * 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. constant space, as it doesn't use additional data structures that scale with input size.
206
163
  */
207
164
  /**
208
- * Time Complexity: O(k log n)
165
+ * Time Complexity: O(log n)
209
166
  * Space Complexity: O(1)
210
167
  *
211
168
  * The `delete` function in TypeScript is used to remove a node from a binary tree, taking into
@@ -221,7 +178,7 @@ export class TreeMultimap extends AVLTree {
221
178
  * being deleted. If set to true, the count of the node will not be considered and the node will be
222
179
  * deleted regardless of its count. If set to false (default), the count of the node will be
223
180
  * decremented by 1 and
224
- * @returns an array of `BinaryTreeDeleteResult<N>`.
181
+ * @returns an array of `BinaryTreeDeleteResult<NODE>`.
225
182
  */
226
183
  delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {
227
184
  const deletedResult = [];
@@ -294,6 +251,57 @@ export class TreeMultimap extends AVLTree {
294
251
  super.clear();
295
252
  this._count = 0;
296
253
  }
254
+ /**
255
+ * Time Complexity: O(n log n)
256
+ * Space Complexity: O(log n)
257
+ */
258
+ /**
259
+ * Time Complexity: O(n log n)
260
+ * Space Complexity: O(log n)
261
+ *
262
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
263
+ * tree using either a recursive or iterative approach.
264
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
265
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
266
+ * values:
267
+ * @returns a boolean value.
268
+ */
269
+ perfectlyBalance(iterationType = this.iterationType) {
270
+ const sorted = this.dfs(node => node, 'in'), n = sorted.length;
271
+ if (sorted.length < 1)
272
+ return false;
273
+ this.clear();
274
+ if (iterationType === IterationType.RECURSIVE) {
275
+ const buildBalanceBST = (l, r) => {
276
+ if (l > r)
277
+ return;
278
+ const m = l + Math.floor((r - l) / 2);
279
+ const midNode = sorted[m];
280
+ this.add(midNode.key, midNode.value, midNode.count);
281
+ buildBalanceBST(l, m - 1);
282
+ buildBalanceBST(m + 1, r);
283
+ };
284
+ buildBalanceBST(0, n - 1);
285
+ return true;
286
+ }
287
+ else {
288
+ const stack = [[0, n - 1]];
289
+ while (stack.length > 0) {
290
+ const popped = stack.pop();
291
+ if (popped) {
292
+ const [l, r] = popped;
293
+ if (l <= r) {
294
+ const m = l + Math.floor((r - l) / 2);
295
+ const midNode = sorted[m];
296
+ this.add(midNode.key, midNode.value, midNode.count);
297
+ stack.push([m + 1, r]);
298
+ stack.push([l, m - 1]);
299
+ }
300
+ }
301
+ }
302
+ return true;
303
+ }
304
+ }
297
305
  /**
298
306
  * Time complexity: O(n)
299
307
  * Space complexity: O(n)
@@ -312,9 +320,9 @@ export class TreeMultimap extends AVLTree {
312
320
  }
313
321
  /**
314
322
  * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
315
- * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node from
316
- * which the values will be swapped. It can be of type `K`, `N`, or `undefined`.
317
- * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
323
+ * @param {K | NODE | undefined} srcNode - The `srcNode` parameter represents the source node from
324
+ * which the values will be swapped. It can be of type `K`, `NODE`, or `undefined`.
325
+ * @param {K | NODE | undefined} destNode - The `destNode` parameter represents the destination
318
326
  * node where the values from the source node will be swapped to.
319
327
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
320
328
  * if either `srcNode` or `destNode` is undefined.
@@ -340,6 +348,14 @@ export class TreeMultimap extends AVLTree {
340
348
  }
341
349
  return undefined;
342
350
  }
351
+ /**
352
+ * The function replaces an old node with a new node and updates the count property of the new node.
353
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
354
+ * needs to be replaced in a data structure.
355
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
356
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
357
+ * superclass, after updating the `count` property of the `newNode` object.
358
+ */
343
359
  _replaceNode(oldNode, newNode) {
344
360
  newNode.count = oldNode.count + newNode.count;
345
361
  return super._replaceNode(oldNode, newNode);