data-structure-typed 2.0.5 → 2.1.0

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 (260) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/COMMANDS.md +17 -0
  3. package/benchmark/report.html +13 -77
  4. package/benchmark/report.json +145 -177
  5. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +186 -83
  6. package/dist/cjs/data-structures/base/iterable-element-base.js +149 -107
  7. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  8. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +95 -119
  9. package/dist/cjs/data-structures/base/iterable-entry-base.js +59 -116
  10. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  11. package/dist/cjs/data-structures/base/linear-base.d.ts +250 -192
  12. package/dist/cjs/data-structures/base/linear-base.js +137 -274
  13. package/dist/cjs/data-structures/base/linear-base.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +171 -205
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
  18. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +135 -87
  19. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +138 -149
  21. package/dist/cjs/data-structures/binary-tree/avl-tree.js +208 -195
  22. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +476 -632
  24. package/dist/cjs/data-structures/binary-tree/binary-tree.js +594 -865
  25. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/bst.d.ts +258 -306
  27. package/dist/cjs/data-structures/binary-tree/bst.js +505 -481
  28. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +107 -179
  30. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +114 -209
  31. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  32. package/dist/cjs/data-structures/binary-tree/tree-counter.d.ts +132 -154
  33. package/dist/cjs/data-structures/binary-tree/tree-counter.js +172 -203
  34. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -1
  35. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  36. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -85
  37. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  38. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +238 -233
  39. package/dist/cjs/data-structures/graph/abstract-graph.js +267 -237
  40. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/directed-graph.d.ts +108 -224
  42. package/dist/cjs/data-structures/graph/directed-graph.js +146 -233
  43. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  44. package/dist/cjs/data-structures/graph/map-graph.d.ts +49 -55
  45. package/dist/cjs/data-structures/graph/map-graph.js +56 -59
  46. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  47. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +103 -146
  48. package/dist/cjs/data-structures/graph/undirected-graph.js +129 -149
  49. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  50. package/dist/cjs/data-structures/hash/hash-map.d.ts +164 -338
  51. package/dist/cjs/data-structures/hash/hash-map.js +270 -457
  52. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  53. package/dist/cjs/data-structures/heap/heap.d.ts +214 -289
  54. package/dist/cjs/data-structures/heap/heap.js +340 -349
  55. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  56. package/dist/cjs/data-structures/heap/max-heap.d.ts +11 -47
  57. package/dist/cjs/data-structures/heap/max-heap.js +11 -66
  58. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  59. package/dist/cjs/data-structures/heap/min-heap.d.ts +12 -47
  60. package/dist/cjs/data-structures/heap/min-heap.js +11 -66
  61. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  62. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
  63. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +368 -494
  64. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  65. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +261 -310
  66. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +447 -466
  67. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  68. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +0 -107
  69. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -100
  70. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  71. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
  72. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +11 -78
  73. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  74. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
  75. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +10 -79
  76. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  77. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -61
  78. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -83
  79. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  80. package/dist/cjs/data-structures/queue/deque.d.ts +227 -254
  81. package/dist/cjs/data-structures/queue/deque.js +309 -348
  82. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  83. package/dist/cjs/data-structures/queue/queue.d.ts +180 -201
  84. package/dist/cjs/data-structures/queue/queue.js +265 -248
  85. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  86. package/dist/cjs/data-structures/stack/stack.d.ts +124 -102
  87. package/dist/cjs/data-structures/stack/stack.js +181 -125
  88. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  89. package/dist/cjs/data-structures/trie/trie.d.ts +164 -165
  90. package/dist/cjs/data-structures/trie/trie.js +189 -172
  91. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  92. package/dist/cjs/interfaces/binary-tree.d.ts +56 -6
  93. package/dist/cjs/interfaces/graph.d.ts +16 -0
  94. package/dist/cjs/types/data-structures/base/base.d.ts +1 -1
  95. package/dist/cjs/types/data-structures/graph/abstract-graph.d.ts +4 -0
  96. package/dist/cjs/types/utils/utils.d.ts +1 -0
  97. package/dist/cjs/utils/utils.d.ts +1 -1
  98. package/dist/cjs/utils/utils.js +2 -1
  99. package/dist/cjs/utils/utils.js.map +1 -1
  100. package/dist/esm/data-structures/base/iterable-element-base.d.ts +186 -83
  101. package/dist/esm/data-structures/base/iterable-element-base.js +155 -107
  102. package/dist/esm/data-structures/base/iterable-element-base.js.map +1 -1
  103. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +95 -119
  104. package/dist/esm/data-structures/base/iterable-entry-base.js +59 -116
  105. package/dist/esm/data-structures/base/iterable-entry-base.js.map +1 -1
  106. package/dist/esm/data-structures/base/linear-base.d.ts +250 -192
  107. package/dist/esm/data-structures/base/linear-base.js +137 -274
  108. package/dist/esm/data-structures/base/linear-base.js.map +1 -1
  109. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
  110. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +171 -212
  111. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
  112. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
  113. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +133 -94
  114. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  115. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +138 -149
  116. package/dist/esm/data-structures/binary-tree/avl-tree.js +206 -200
  117. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
  118. package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +476 -632
  119. package/dist/esm/data-structures/binary-tree/binary-tree.js +598 -874
  120. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
  121. package/dist/esm/data-structures/binary-tree/bst.d.ts +258 -306
  122. package/dist/esm/data-structures/binary-tree/bst.js +507 -487
  123. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
  124. package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +107 -179
  125. package/dist/esm/data-structures/binary-tree/red-black-tree.js +114 -215
  126. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
  127. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +132 -154
  128. package/dist/esm/data-structures/binary-tree/tree-counter.js +175 -209
  129. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -1
  130. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  131. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +103 -92
  132. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  133. package/dist/esm/data-structures/graph/abstract-graph.d.ts +238 -233
  134. package/dist/esm/data-structures/graph/abstract-graph.js +267 -237
  135. package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
  136. package/dist/esm/data-structures/graph/directed-graph.d.ts +108 -224
  137. package/dist/esm/data-structures/graph/directed-graph.js +145 -233
  138. package/dist/esm/data-structures/graph/directed-graph.js.map +1 -1
  139. package/dist/esm/data-structures/graph/map-graph.d.ts +49 -55
  140. package/dist/esm/data-structures/graph/map-graph.js +56 -59
  141. package/dist/esm/data-structures/graph/map-graph.js.map +1 -1
  142. package/dist/esm/data-structures/graph/undirected-graph.d.ts +103 -146
  143. package/dist/esm/data-structures/graph/undirected-graph.js +128 -149
  144. package/dist/esm/data-structures/graph/undirected-graph.js.map +1 -1
  145. package/dist/esm/data-structures/hash/hash-map.d.ts +164 -338
  146. package/dist/esm/data-structures/hash/hash-map.js +270 -457
  147. package/dist/esm/data-structures/hash/hash-map.js.map +1 -1
  148. package/dist/esm/data-structures/heap/heap.d.ts +214 -289
  149. package/dist/esm/data-structures/heap/heap.js +329 -349
  150. package/dist/esm/data-structures/heap/heap.js.map +1 -1
  151. package/dist/esm/data-structures/heap/max-heap.d.ts +11 -47
  152. package/dist/esm/data-structures/heap/max-heap.js +11 -66
  153. package/dist/esm/data-structures/heap/max-heap.js.map +1 -1
  154. package/dist/esm/data-structures/heap/min-heap.d.ts +12 -47
  155. package/dist/esm/data-structures/heap/min-heap.js +11 -66
  156. package/dist/esm/data-structures/heap/min-heap.js.map +1 -1
  157. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
  158. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +368 -495
  159. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  160. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +261 -310
  161. package/dist/esm/data-structures/linked-list/singly-linked-list.js +448 -467
  162. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
  163. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -107
  164. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -100
  165. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +1 -1
  166. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
  167. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +11 -78
  168. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  169. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
  170. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +10 -79
  171. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  172. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +2 -61
  173. package/dist/esm/data-structures/priority-queue/priority-queue.js +8 -83
  174. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +1 -1
  175. package/dist/esm/data-structures/queue/deque.d.ts +227 -254
  176. package/dist/esm/data-structures/queue/deque.js +313 -348
  177. package/dist/esm/data-structures/queue/deque.js.map +1 -1
  178. package/dist/esm/data-structures/queue/queue.d.ts +180 -201
  179. package/dist/esm/data-structures/queue/queue.js +263 -248
  180. package/dist/esm/data-structures/queue/queue.js.map +1 -1
  181. package/dist/esm/data-structures/stack/stack.d.ts +124 -102
  182. package/dist/esm/data-structures/stack/stack.js +181 -125
  183. package/dist/esm/data-structures/stack/stack.js.map +1 -1
  184. package/dist/esm/data-structures/trie/trie.d.ts +164 -165
  185. package/dist/esm/data-structures/trie/trie.js +193 -172
  186. package/dist/esm/data-structures/trie/trie.js.map +1 -1
  187. package/dist/esm/interfaces/binary-tree.d.ts +56 -6
  188. package/dist/esm/interfaces/graph.d.ts +16 -0
  189. package/dist/esm/types/data-structures/base/base.d.ts +1 -1
  190. package/dist/esm/types/data-structures/graph/abstract-graph.d.ts +4 -0
  191. package/dist/esm/types/utils/utils.d.ts +1 -0
  192. package/dist/esm/utils/utils.d.ts +1 -1
  193. package/dist/esm/utils/utils.js +2 -1
  194. package/dist/esm/utils/utils.js.map +1 -1
  195. package/dist/umd/data-structure-typed.js +4685 -6477
  196. package/dist/umd/data-structure-typed.min.js +8 -6
  197. package/dist/umd/data-structure-typed.min.js.map +1 -1
  198. package/package.json +3 -4
  199. package/src/data-structures/base/iterable-element-base.ts +238 -115
  200. package/src/data-structures/base/iterable-entry-base.ts +96 -120
  201. package/src/data-structures/base/linear-base.ts +271 -277
  202. package/src/data-structures/binary-tree/avl-tree-counter.ts +198 -216
  203. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +192 -101
  204. package/src/data-structures/binary-tree/avl-tree.ts +239 -206
  205. package/src/data-structures/binary-tree/binary-tree.ts +660 -889
  206. package/src/data-structures/binary-tree/bst.ts +568 -570
  207. package/src/data-structures/binary-tree/red-black-tree.ts +161 -222
  208. package/src/data-structures/binary-tree/tree-counter.ts +199 -218
  209. package/src/data-structures/binary-tree/tree-multi-map.ts +131 -97
  210. package/src/data-structures/graph/abstract-graph.ts +339 -264
  211. package/src/data-structures/graph/directed-graph.ts +146 -236
  212. package/src/data-structures/graph/map-graph.ts +63 -60
  213. package/src/data-structures/graph/undirected-graph.ts +129 -152
  214. package/src/data-structures/hash/hash-map.ts +274 -496
  215. package/src/data-structures/heap/heap.ts +389 -402
  216. package/src/data-structures/heap/max-heap.ts +12 -76
  217. package/src/data-structures/heap/min-heap.ts +13 -76
  218. package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
  219. package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
  220. package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
  221. package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
  222. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
  223. package/src/data-structures/priority-queue/priority-queue.ts +3 -92
  224. package/src/data-structures/queue/deque.ts +381 -357
  225. package/src/data-structures/queue/queue.ts +310 -264
  226. package/src/data-structures/stack/stack.ts +217 -131
  227. package/src/data-structures/trie/trie.ts +240 -175
  228. package/src/interfaces/binary-tree.ts +240 -6
  229. package/src/interfaces/graph.ts +37 -0
  230. package/src/types/data-structures/base/base.ts +5 -5
  231. package/src/types/data-structures/graph/abstract-graph.ts +5 -0
  232. package/src/types/utils/utils.ts +2 -0
  233. package/src/utils/utils.ts +9 -14
  234. package/test/integration/index.html +1 -1
  235. package/test/performance/benchmark-runner.ts +528 -0
  236. package/test/performance/reportor.mjs +43 -43
  237. package/test/performance/runner-config.json +39 -0
  238. package/test/performance/single-suite-runner.ts +69 -0
  239. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +3 -3
  240. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +5 -5
  241. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
  242. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +350 -90
  243. package/test/unit/data-structures/binary-tree/bst.test.ts +12 -9
  244. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +2 -2
  245. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +25 -24
  246. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +3 -3
  247. package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -4
  248. package/test/unit/data-structures/graph/directed-graph.test.ts +1 -1
  249. package/test/unit/data-structures/heap/heap.test.ts +14 -21
  250. package/test/unit/data-structures/heap/max-heap.test.ts +5 -9
  251. package/test/unit/data-structures/heap/min-heap.test.ts +1 -4
  252. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +14 -14
  253. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -7
  254. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +8 -11
  255. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -4
  256. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +1 -4
  257. package/test/unit/data-structures/queue/queue.test.ts +4 -5
  258. package/test/unit/utils/utils.test.ts +0 -1
  259. package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +0 -71
  260. package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +0 -81
@@ -1,26 +1,47 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
1
8
  import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
9
+ /**
10
+ * RB-tree node with an extra 'count' field; keeps parent/child links.
11
+ * @remarks Time O(1), Space O(1)
12
+ * @template K
13
+ * @template V
14
+ */
2
15
  export class TreeCounterNode extends RedBlackTreeNode {
3
16
  parent = undefined;
4
17
  /**
5
- * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
6
- * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
7
- * used to identify and locate the node within the tree.
8
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
9
- * associated with the key in the Red-Black Tree node. It is not required and can be omitted when
10
- * creating a new node.
11
- * @param [count=1] - The `count` parameter represents the number of occurrences of a particular key
12
- * in the Red-Black Tree. It is an optional parameter with a default value of 1.
13
- * @param {RBTNColor} [color=BLACK] - The `color` parameter is used to specify the color of the node
14
- * in a Red-Black Tree. It is optional and has a default value of `'BLACK'`.
18
+ * Create a tree counter node.
19
+ * @remarks Time O(1), Space O(1)
20
+ * @param key - Key of the node.
21
+ * @param [value] - Value associated with the key (ignored in map mode).
22
+ * @param [count] - Initial count for this node (default 1).
23
+ * @param color - Initial color ('RED' or 'BLACK').
24
+ * @returns New TreeCounterNode instance.
15
25
  */
16
26
  constructor(key, value, count = 1, color = 'BLACK') {
17
27
  super(key, value, color);
18
28
  this.count = count;
19
29
  }
20
30
  _left = undefined;
31
+ /**
32
+ * Get the left child pointer.
33
+ * @remarks Time O(1), Space O(1)
34
+ * @returns Left child node, or null/undefined.
35
+ */
21
36
  get left() {
22
37
  return this._left;
23
38
  }
39
+ /**
40
+ * Set the left child and update its parent pointer.
41
+ * @remarks Time O(1), Space O(1)
42
+ * @param v - New left child node, or null/undefined.
43
+ * @returns void
44
+ */
24
45
  set left(v) {
25
46
  if (v) {
26
47
  v.parent = this;
@@ -28,9 +49,20 @@ export class TreeCounterNode extends RedBlackTreeNode {
28
49
  this._left = v;
29
50
  }
30
51
  _right = undefined;
52
+ /**
53
+ * Get the right child pointer.
54
+ * @remarks Time O(1), Space O(1)
55
+ * @returns Right child node, or null/undefined.
56
+ */
31
57
  get right() {
32
58
  return this._right;
33
59
  }
60
+ /**
61
+ * Set the right child and update its parent pointer.
62
+ * @remarks Time O(1), Space O(1)
63
+ * @param v - New right child node, or null/undefined.
64
+ * @returns void
65
+ */
34
66
  set right(v) {
35
67
  if (v) {
36
68
  v.parent = this;
@@ -39,17 +71,19 @@ export class TreeCounterNode extends RedBlackTreeNode {
39
71
  }
40
72
  }
41
73
  /**
42
- *
74
+ * Red-Black Tree–based counter map (key → value with per-node count). Supports O(log N) updates and map-like mode.
75
+ * @remarks Time O(1), Space O(1)
76
+ * @template K
77
+ * @template V
78
+ * @template R
43
79
  */
44
80
  export class TreeCounter extends RedBlackTree {
45
81
  /**
46
- * The constructor function initializes a TreeCounter object with optional initial data.
47
- * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
48
- * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
49
- * TreeCounter with initial data.
50
- * @param [options] - The `options` parameter is an optional object that can be used to customize the
51
- * behavior of the `TreeCounter` constructor. It can include properties such as `compareKeys` and
52
- * `compareValues`, which are functions used to compare keys and values respectively.
82
+ * Create a TreeCounter and optionally bulk-insert items.
83
+ * @remarks Time O(N log N), Space O(N)
84
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
85
+ * @param [options] - Options for TreeCounter (comparator, reverse, map mode).
86
+ * @returns New TreeCounter instance.
53
87
  */
54
88
  constructor(keysNodesEntriesOrRaws = [], options) {
55
89
  super([], options);
@@ -57,85 +91,42 @@ export class TreeCounter extends RedBlackTree {
57
91
  this.addMany(keysNodesEntriesOrRaws);
58
92
  }
59
93
  _count = 0;
60
- // TODO the _count is not accurate after nodes count modified
61
94
  /**
62
- * The function calculates the sum of the count property of all nodes in a tree structure.
63
- * @returns the sum of the count property of all nodes in the tree.
95
+ * Get the total aggregate count across all nodes.
96
+ * @remarks Time O(1), Space O(1)
97
+ * @returns Total count.
64
98
  */
65
99
  get count() {
66
100
  return this._count;
67
101
  }
68
102
  /**
69
- * Time Complexity: O(n)
70
- * Space Complexity: O(1)
71
- *
72
- * The function calculates the sum of the count property of all nodes in a tree using depth-first
73
- * search.
74
- * @returns the sum of the count property of all nodes in the tree.
103
+ * Compute the total count by traversing the tree (sums node.count).
104
+ * @remarks Time O(N), Space O(H)
105
+ * @returns Total count recomputed from nodes.
75
106
  */
76
107
  getComputedCount() {
77
108
  let sum = 0;
78
109
  this.dfs(node => (sum += node ? node.count : 0));
79
110
  return sum;
80
111
  }
81
- /**
82
- * The function creates a new TreeCounterNode with the specified key, value, color, and count.
83
- * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
84
- * which is a generic type representing the type of keys in the tree.
85
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
86
- * associated with the key in the node. It is of type `V`, which can be any data type.
87
- * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
88
- * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
89
- * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
90
- * the tree. It is an optional parameter and is used to keep track of the number of values associated
91
- * with a key in the tree.
92
- * @returns A new instance of the TreeCounterNode class, casted as TreeCounterNode<K, V>.
93
- */
94
- createNode(key, value, color = 'BLACK', count) {
112
+ _createNode(key, value, color = 'BLACK', count) {
95
113
  return new TreeCounterNode(key, this._isMapMode ? undefined : value, count, color);
96
114
  }
97
115
  /**
98
- * The function creates a new instance of a TreeCounter with the specified options and returns it.
99
- * @param [options] - The `options` parameter is an optional object that contains additional
100
- * configuration options for creating the `TreeCounter`. It is of type `TreeCounterOptions<K, V,
101
- * R>`.
102
- * @returns a new instance of the `TreeCounter` class, with the provided options merged with the
103
- * existing `iterationType` property. The returned value is casted as `TREE`.
104
- */
105
- createTree(options) {
106
- return new TreeCounter([], {
107
- iterationType: this.iterationType,
108
- specifyComparable: this._specifyComparable,
109
- isMapMode: this._isMapMode,
110
- toEntryFn: this._toEntryFn,
111
- ...options
112
- });
113
- }
114
- /**
115
- * The function checks if the input is an instance of the TreeCounterNode class.
116
- * @param {K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
117
- * `keyNodeOrEntry` can be of type `R` or `K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
118
- * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
119
- * an instance of the `TreeCounterNode` class.
116
+ * Type guard: check whether the input is a TreeCounterNode.
117
+ * @remarks Time O(1), Space O(1)
118
+ * @returns True if the value is a TreeCounterNode.
120
119
  */
121
120
  isNode(keyNodeOrEntry) {
122
121
  return keyNodeOrEntry instanceof TreeCounterNode;
123
122
  }
124
123
  /**
125
- * Time Complexity: O(log n)
126
- * Space Complexity: O(1)
127
- *
128
- * The function overrides the add method of a class and adds a new node to a data structure, updating
129
- * the count and returning a boolean indicating success.
130
- * @param {K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
131
- * `keyNodeOrEntry` parameter can accept one of the following types:
132
- * @param {V} [value] - The `value` parameter represents the value associated with the key in the
133
- * data structure. It is an optional parameter, so it can be omitted if not needed.
134
- * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
135
- * be added to the data structure. By default, it is set to 1, meaning that if no value is provided
136
- * for `count`, the key-value pair will be added once.
137
- * @returns The method is returning a boolean value. It returns true if the addition of the new node
138
- * was successful, and false otherwise.
124
+ * Insert or increment a node and update aggregate count.
125
+ * @remarks Time O(log N), Space O(1)
126
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
127
+ * @param [value] - Value when a bare key is provided (ignored in map mode).
128
+ * @param [count] - How much to increase the node's count (default 1).
129
+ * @returns True if inserted/updated; false if ignored.
139
130
  */
140
131
  add(keyNodeOrEntry, value, count = 1) {
141
132
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
@@ -150,19 +141,11 @@ export class TreeCounter extends RedBlackTree {
150
141
  }
151
142
  }
152
143
  /**
153
- * Time Complexity: O(log n)
154
- * Space Complexity: O(1)
155
- *
156
- * The function `delete` in TypeScript overrides the deletion operation in a binary tree data
157
- * structure, handling cases where nodes have children and maintaining balance in the tree.
158
- * @param {K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `predicate`
159
- * parameter in the `delete` method is used to specify the condition or key based on which a node
160
- * should be deleted from the binary tree. It can be a key, a node, or an entry.
161
- * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
162
- * boolean flag that determines whether to ignore the count of nodes when performing deletion. If
163
- * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
164
- * `ignoreCount` is `false
165
- * @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<TreeCounterNode<K, V>>` objects.
144
+ * Delete a node (or decrement its count) and rebalance if needed.
145
+ * @remarks Time O(log N), Space O(1)
146
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
147
+ * @param [ignoreCount] - If true, remove the node regardless of its count.
148
+ * @returns Array of deletion results including deleted node and a rebalance hint when present.
166
149
  */
167
150
  delete(keyNodeOrEntry, ignoreCount = false) {
168
151
  if (keyNodeOrEntry === null)
@@ -254,7 +237,6 @@ export class TreeCounter extends RedBlackTree {
254
237
  }
255
238
  }
256
239
  this._size--;
257
- // If the original color was black, fix the tree
258
240
  if (originalColor === 'BLACK') {
259
241
  this._deleteFixup(replacementNode);
260
242
  }
@@ -262,119 +244,114 @@ export class TreeCounter extends RedBlackTree {
262
244
  return results;
263
245
  }
264
246
  /**
265
- * Time Complexity: O(1)
266
- * Space Complexity: O(1)
267
- *
268
- * The "clear" function overrides the parent class's "clear" function and also resets the count to
269
- * zero.
247
+ * Remove all nodes and reset aggregate counters.
248
+ * @remarks Time O(N), Space O(1)
249
+ * @returns void
270
250
  */
271
251
  clear() {
272
252
  super.clear();
273
253
  this._count = 0;
274
254
  }
275
255
  /**
276
- * Time Complexity: O(n log n)
277
- * Space Complexity: O(log n)
278
- *
279
- * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
280
- * tree using either a recursive or iterative approach.
281
- * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
282
- * specifies the type of iteration to use when building the balanced binary search tree. It has a
283
- * default value of `this.iterationType`, which means it will use the iteration type specified by the
284
- * `iterationType` property of the current object.
285
- * @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
286
- * balancing operation is successful, and `false` if there are no nodes to balance.
256
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
257
+ * @remarks Time O(N), Space O(N)
258
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
259
+ * @returns True if rebalancing succeeded (tree not empty).
287
260
  */
288
261
  perfectlyBalance(iterationType = this.iterationType) {
289
- const sorted = this.dfs(node => node, 'IN'), n = sorted.length;
290
- if (sorted.length < 1)
262
+ const nodes = this.dfs(node => node, 'IN', false, this._root, iterationType);
263
+ const n = nodes.length;
264
+ if (n < 1)
291
265
  return false;
292
- this.clear();
293
- if (iterationType === 'RECURSIVE') {
294
- const buildBalanceBST = (l, r) => {
295
- if (l > r)
296
- return;
297
- const m = l + Math.floor((r - l) / 2);
298
- const midNode = sorted[m];
299
- if (this._isMapMode && midNode !== null)
300
- this.add(midNode.key, undefined, midNode.count);
301
- else if (midNode !== null)
302
- this.add(midNode.key, midNode.value, midNode.count);
303
- buildBalanceBST(l, m - 1);
304
- buildBalanceBST(m + 1, r);
305
- };
306
- buildBalanceBST(0, n - 1);
307
- return true;
308
- }
309
- else {
310
- const stack = [[0, n - 1]];
311
- while (stack.length > 0) {
312
- const popped = stack.pop();
313
- if (popped) {
314
- const [l, r] = popped;
315
- if (l <= r) {
316
- const m = l + Math.floor((r - l) / 2);
317
- const midNode = sorted[m];
318
- if (this._isMapMode && midNode !== null)
319
- this.add(midNode.key, undefined, midNode.count);
320
- else if (midNode !== null)
321
- this.add(midNode.key, midNode.value, midNode.count);
322
- stack.push([m + 1, r]);
323
- stack.push([l, m - 1]);
324
- }
325
- }
326
- }
327
- return true;
266
+ let total = 0;
267
+ for (const nd of nodes)
268
+ total += nd ? nd.count : 0;
269
+ this._clearNodes();
270
+ const build = (l, r, parent) => {
271
+ if (l > r)
272
+ return undefined;
273
+ const m = l + ((r - l) >> 1);
274
+ const root = nodes[m];
275
+ const leftChild = build(l, m - 1, root);
276
+ const rightChild = build(m + 1, r, root);
277
+ root.left = leftChild;
278
+ root.right = rightChild;
279
+ root.parent = parent;
280
+ return root;
281
+ };
282
+ const newRoot = build(0, n - 1, undefined);
283
+ this._setRoot(newRoot);
284
+ this._size = n;
285
+ this._count = total;
286
+ return true;
287
+ }
288
+ /**
289
+ * Create a new TreeCounter by mapping each [key, value] entry.
290
+ * @remarks Time O(N log N), Space O(N)
291
+ * @template MK
292
+ * @template MV
293
+ * @template MR
294
+ * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
295
+ * @param [options] - Options for the output tree.
296
+ * @param [thisArg] - Value for `this` inside the callback.
297
+ * @returns A new TreeCounter with mapped entries.
298
+ */
299
+ map(callback, options, thisArg) {
300
+ const out = this._createLike([], options);
301
+ let index = 0;
302
+ for (const [key, value] of this) {
303
+ out.add(callback.call(thisArg, key, value, index++, this));
328
304
  }
305
+ return out;
329
306
  }
330
307
  /**
331
- * Time complexity: O(n)
332
- * Space complexity: O(n)
333
- *
334
- * The function overrides the clone method to create a deep copy of a tree object.
335
- * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
308
+ * Deep copy this tree, preserving map mode and aggregate counts.
309
+ * @remarks Time O(N), Space O(N)
310
+ * @returns A deep copy of this tree.
336
311
  */
337
312
  clone() {
338
- const cloned = this.createTree();
339
- this.bfs(node => cloned.add(node === null ? null : node.key, undefined, node === null ? 0 : node.count));
340
- if (this._isMapMode)
341
- cloned._store = this._store;
342
- return cloned;
313
+ const out = this._createInstance();
314
+ this._clone(out);
315
+ out._count = this._count;
316
+ return out;
343
317
  }
344
318
  /**
345
- * The `map` function in TypeScript overrides the default behavior to create a new TreeCounter with
346
- * modified entries based on a provided callback.
347
- * @param callback - The `callback` parameter is a function that will be called for each entry in the
348
- * map. It takes four arguments:
349
- * @param [options] - The `options` parameter in the `override map` function is of type
350
- * `TreeCounterOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
351
- * options when creating a new `TreeCounter` instance within the `map` function. These options could
352
- * include things like
353
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
354
- * the value of `this` when executing the `callback` function. It allows you to set the context
355
- * (value of `this`) for the callback function when it is called within the `map` function. This
356
- * @returns A new TreeCounter instance is being returned, which is populated with entries generated
357
- * by the provided callback function.
319
+ * (Protected) Create an empty instance of the same concrete class.
320
+ * @remarks Time O(1), Space O(1)
321
+ * @template TK
322
+ * @template TV
323
+ * @template TR
324
+ * @param [options] - Optional constructor options for the like-kind instance.
325
+ * @returns An empty like-kind instance.
358
326
  */
359
- map(callback, options, thisArg) {
360
- const newTree = new TreeCounter([], options);
361
- let index = 0;
362
- for (const [key, value] of this) {
363
- newTree.add(callback.call(thisArg, key, value, index++, this));
364
- }
365
- return newTree;
327
+ _createInstance(options) {
328
+ const Ctor = this.constructor;
329
+ return new Ctor([], { ...this._snapshotOptions(), ...(options ?? {}) });
330
+ }
331
+ /**
332
+ * (Protected) Create a like-kind instance and seed it from an iterable.
333
+ * @remarks Time O(N log N), Space O(N)
334
+ * @template TK
335
+ * @template TV
336
+ * @template TR
337
+ * @param iter - Iterable used to seed the new tree.
338
+ * @param [options] - Options merged with the current snapshot.
339
+ * @returns A like-kind TreeCounter built from the iterable.
340
+ */
341
+ _createLike(iter = [], options) {
342
+ const Ctor = this.constructor;
343
+ return new Ctor(iter, {
344
+ ...this._snapshotOptions(),
345
+ ...(options ?? {})
346
+ });
366
347
  }
367
348
  /**
368
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
369
- * node based on the input.
370
- * @param {K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
371
- * `keyNodeOrEntry` can be of type `R` or `K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
372
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
373
- * associated with the key in the node. It is used when creating a new node or updating the value of
374
- * an existing node.
375
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
376
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
377
- * @returns either a TreeCounterNode<K, V> object or undefined.
349
+ * (Protected) Normalize input into a node plus its effective value and count.
350
+ * @remarks Time O(1), Space O(1)
351
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry.
352
+ * @param [value] - Value used when a bare key is provided.
353
+ * @param [count] - Count increment to apply (default 1).
354
+ * @returns Tuple [node, value] where node may be undefined.
378
355
  */
379
356
  _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
380
357
  if (keyNodeOrEntry === undefined || keyNodeOrEntry === null)
@@ -386,30 +363,23 @@ export class TreeCounter extends RedBlackTree {
386
363
  if (key === undefined || key === null)
387
364
  return [undefined, undefined];
388
365
  const finalValue = value ?? entryValue;
389
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
366
+ return [this._createNode(key, finalValue, 'BLACK', count), finalValue];
390
367
  }
391
- return [this.createNode(keyNodeOrEntry, value, 'BLACK', count), value];
368
+ return [this._createNode(keyNodeOrEntry, value, 'BLACK', count), value];
392
369
  }
393
370
  /**
394
- * Time Complexity: O(1)
395
- * Space Complexity: O(1)
396
- *
397
- * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
398
- * in a binary search tree.
399
- * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} srcNode - The `srcNode` parameter represents the source node
400
- * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
401
- * instance of the `BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>` class.
402
- * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} destNode - The `destNode` parameter represents the destination
403
- * node where the properties will be swapped with the source node.
404
- * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
405
- * If either `srcNode` or `destNode` is undefined, it returns undefined.
371
+ * (Protected) Swap keys/values/counters between the source and destination nodes.
372
+ * @remarks Time O(1), Space O(1)
373
+ * @param srcNode - Source node (or key) whose properties will be moved.
374
+ * @param destNode - Destination node (or key) to receive properties.
375
+ * @returns Destination node after swap, or undefined.
406
376
  */
407
377
  _swapProperties(srcNode, destNode) {
408
378
  srcNode = this.ensureNode(srcNode);
409
379
  destNode = this.ensureNode(destNode);
410
380
  if (srcNode && destNode) {
411
381
  const { key, value, count, color } = destNode;
412
- const tempNode = this.createNode(key, value, color, count);
382
+ const tempNode = this._createNode(key, value, color, count);
413
383
  if (tempNode) {
414
384
  tempNode.color = color;
415
385
  destNode.key = srcNode.key;
@@ -428,15 +398,11 @@ export class TreeCounter extends RedBlackTree {
428
398
  return undefined;
429
399
  }
430
400
  /**
431
- * Time Complexity: O(1)
432
- * Space Complexity: O(1)
433
- *
434
- * The function replaces an old node with a new node and updates the count property of the new node.
435
- * @param {TreeCounterNode<K, V>} oldNode - The `oldNode` parameter is the node that you want to replace in the data
436
- * structure.
437
- * @param {TreeCounterNode<K, V>} newNode - The `newNode` parameter is an instance of the `TreeCounterNode<K, V>` class.
438
- * @returns The method is returning the result of calling the `_replaceNode` method from the
439
- * superclass, which is of type `TreeCounterNode<K, V>`.
401
+ * (Protected) Replace one node by another and adjust counters accordingly.
402
+ * @remarks Time O(1), Space O(1)
403
+ * @param oldNode - Node being replaced.
404
+ * @param newNode - Replacement node.
405
+ * @returns The new node after replacement.
440
406
  */
441
407
  _replaceNode(oldNode, newNode) {
442
408
  newNode.count = oldNode.count + newNode.count;
@@ -1 +1 @@
1
- {"version":3,"file":"tree-counter.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-counter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,eAAkC,SAAQ,gBAAsB;IAClE,MAAM,GAA2B,SAAS,CAAC;IAEpD;;;;;;;;;;;OAWG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC,EAA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