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
@@ -5,30 +5,60 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { TreeMultiMapOptions } from '../../types';
8
+ import type { ElemOf, EntryCallback, RedBlackTreeOptions, TreeMultiMapOptions } from '../../types';
9
9
  import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
10
10
  import { IBinaryTree } from '../../interfaces';
11
+ /**
12
+ * Node used by TreeMultiMap; stores the key with a bucket of values (array).
13
+ * @remarks Time O(1), Space O(1)
14
+ * @template K
15
+ * @template V
16
+ */
11
17
  export declare class TreeMultiMapNode<K = any, V = any> extends RedBlackTreeNode<K, V[]> {
12
18
  parent?: TreeMultiMapNode<K, V>;
13
19
  /**
14
- * This TypeScript constructor initializes an object with a key of type K and an array of values of
15
- * type V.
16
- * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
17
- * data being stored in the data structure. It helps in quickly accessing or retrieving the
18
- * associated value in the data structure.
19
- * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
20
- * type `V`.
20
+ * Create a TreeMultiMap node with an optional value bucket.
21
+ * @remarks Time O(1), Space O(1)
22
+ * @param key - Key of the node.
23
+ * @param [value] - Initial array of values.
24
+ * @returns New TreeMultiMapNode instance.
21
25
  */
22
26
  constructor(key: K, value?: V[]);
23
27
  _left?: TreeMultiMapNode<K, V> | null | undefined;
28
+ /**
29
+ * Get the left child pointer.
30
+ * @remarks Time O(1), Space O(1)
31
+ * @returns Left child node, or null/undefined.
32
+ */
24
33
  get left(): TreeMultiMapNode<K, V> | null | undefined;
34
+ /**
35
+ * Set the left child and update its parent pointer.
36
+ * @remarks Time O(1), Space O(1)
37
+ * @param v - New left child node, or null/undefined.
38
+ * @returns void
39
+ */
25
40
  set left(v: TreeMultiMapNode<K, V> | null | undefined);
26
41
  _right?: TreeMultiMapNode<K, V> | null | undefined;
42
+ /**
43
+ * Get the right child pointer.
44
+ * @remarks Time O(1), Space O(1)
45
+ * @returns Right child node, or null/undefined.
46
+ */
27
47
  get right(): TreeMultiMapNode<K, V> | null | undefined;
48
+ /**
49
+ * Set the right child and update its parent pointer.
50
+ * @remarks Time O(1), Space O(1)
51
+ * @param v - New right child node, or null/undefined.
52
+ * @returns void
53
+ */
28
54
  set right(v: TreeMultiMapNode<K, V> | null | undefined);
29
55
  }
30
56
  /**
31
- *
57
+ * Red-Black Tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
58
+ * @remarks Time O(1), Space O(1)
59
+ * @template K
60
+ * @template V
61
+ * @template R
32
62
  * @example
33
63
  * // players ranked by score with their equipment
34
64
  * type Equipment = {
@@ -194,74 +224,47 @@ export declare class TreeMultiMapNode<K = any, V = any> extends RedBlackTreeNode
194
224
  * // ]
195
225
  * // ]
196
226
  */
197
- export declare class TreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends RedBlackTree<K, V[], R, MK, MV[], MR> implements IBinaryTree<K, V[], R, MK, MV, MR> {
227
+ export declare class TreeMultiMap<K = any, V = any, R extends object = object> extends RedBlackTree<K, V[], R> implements IBinaryTree<K, V[], R> {
198
228
  /**
199
- * The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
200
- * and options.
201
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
202
- * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
203
- * TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
204
- * the RedBlackTreeMulti
205
- * @param [options] - The `options` parameter in the constructor is of type
206
- * `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
207
- * additional options for configuring the TreeMultiMap instance.
229
+ * Create a TreeMultiMap and optionally bulk-insert items.
230
+ * @remarks Time O(N log N), Space O(N)
231
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
232
+ * @param [options] - Options for TreeMultiMap (comparator, reverse, map mode).
233
+ * @returns New TreeMultiMap instance.
208
234
  */
209
235
  constructor(keysNodesEntriesOrRaws?: Iterable<K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: TreeMultiMapOptions<K, V[], R>);
210
- /**
211
- * Time Complexity: O(1)
212
- * Space Complexity: O(1)
213
- *
214
- * The `createTree` function in TypeScript overrides the default implementation to create a new
215
- * TreeMultiMap with specified options.
216
- * @param [options] - The `options` parameter in the `createTree` method is of type
217
- * `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
218
- * options when creating a new `TreeMultiMap` instance. It includes properties such as
219
- * `iterationType`, `specifyComparable
220
- * @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
221
- * data and the provided options merged with the existing properties of the current object.
222
- */
223
- createTree(options?: TreeMultiMapOptions<K, V[], R>): TreeMultiMap<K, V, R, MK, MV, MR>;
224
- /**
225
- * Time Complexity: O(1)
226
- * Space Complexity: O(1)
227
- *
228
- * The function `createNode` overrides the creation of a new TreeMultiMapNode with a specified key
229
- * and value array.
230
- * @param {K} key - The `key` parameter represents the key of the node being created in the
231
- * `TreeMultiMap`.
232
- * @param {V[]} value - The `value` parameter in the `createNode` method represents an array of
233
- * values associated with a specific key in the TreeMultiMap data structure.
234
- * @returns A new instance of `TreeMultiMapNode<K, V>` is being returned with the specified key and
235
- * value. If `_isMapMode` is true, an empty array is passed as the value, otherwise the provided
236
- * value is used.
237
- */
238
- createNode(key: K, value?: V[]): TreeMultiMapNode<K, V>;
236
+ _createNode(key: K, value?: V[]): TreeMultiMapNode<K, V>;
239
237
  add(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
240
238
  add(key: K, value: V): boolean;
241
239
  /**
242
- * Time Complexity: O(log n)
243
- * Space Complexity: O(log n)
244
- *
245
- * The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
246
- * and deletes the entire node if no values are left for that key.
247
- * @param {K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined} keyNodeOrEntry - The `keyNodeOrEntry`
248
- * parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
249
- * array of values, or just a key itself.
250
- * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
251
- * value that you want to remove from the multi-map data structure associated with a particular key.
252
- * The function checks if the value exists in the array of values associated with the key, and if
253
- * found, removes it from the array.
254
- * @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
255
- * successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
240
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
241
+ * @remarks Time O(log N), Space O(1)
242
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
243
+ * @param value - Value to remove from the bucket.
244
+ * @returns True if the value was removed; false if not found.
256
245
  */
257
246
  deleteValue(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined, value: V): boolean;
247
+ map<MK = K, MVArr extends unknown[] = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<RedBlackTreeOptions<MK, MVArr, MR>>, thisArg?: unknown): TreeMultiMap<MK, ElemOf<MVArr>, MR>;
248
+ map<MK = K, MV = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<RedBlackTreeOptions<MK, MV, MR>>, thisArg?: unknown): RedBlackTree<MK, MV, MR>;
249
+ /**
250
+ * (Protected) Create an empty instance of the same concrete class.
251
+ * @remarks Time O(1), Space O(1)
252
+ * @template TK
253
+ * @template TV
254
+ * @template TR
255
+ * @param [options] - Optional constructor options for the like-kind instance.
256
+ * @returns An empty like-kind instance.
257
+ */
258
+ protected _createInstance<TK = K, TV = V, TR extends object = R>(options?: Partial<RedBlackTreeOptions<TK, TV, TR>>): this;
258
259
  /**
259
- * Time Complexity: O(n)
260
- * Space Complexity: O(n)
261
- *
262
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
263
- * structure.
264
- * @returns The `cloned` object is being returned.
260
+ * (Protected) Create a like-kind instance and seed it from an iterable.
261
+ * @remarks Time O(N log N), Space O(N)
262
+ * @template TK
263
+ * @template TV
264
+ * @template TR
265
+ * @param iter - Iterable used to seed the new tree.
266
+ * @param [options] - Options merged with the current snapshot.
267
+ * @returns A like-kind RedBlackTree built from the iterable.
265
268
  */
266
- clone(): TreeMultiMap<K, V, R, MK, MV, MR>;
269
+ protected _createLike<TK = K, TV = V, TR extends object = R>(iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<RedBlackTreeOptions<TK, TV, TR>>): RedBlackTree<TK, TV, TR>;
267
270
  }
@@ -1,22 +1,44 @@
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
+ * Node used by TreeMultiMap; stores the key with a bucket of values (array).
11
+ * @remarks Time O(1), Space O(1)
12
+ * @template K
13
+ * @template V
14
+ */
2
15
  export class TreeMultiMapNode extends RedBlackTreeNode {
3
16
  parent = undefined;
4
17
  /**
5
- * This TypeScript constructor initializes an object with a key of type K and an array of values of
6
- * type V.
7
- * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
8
- * data being stored in the data structure. It helps in quickly accessing or retrieving the
9
- * associated value in the data structure.
10
- * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
11
- * type `V`.
18
+ * Create a TreeMultiMap node with an optional value bucket.
19
+ * @remarks Time O(1), Space O(1)
20
+ * @param key - Key of the node.
21
+ * @param [value] - Initial array of values.
22
+ * @returns New TreeMultiMapNode instance.
12
23
  */
13
24
  constructor(key, value) {
14
25
  super(key, value);
15
26
  }
16
27
  _left = undefined;
28
+ /**
29
+ * Get the left child pointer.
30
+ * @remarks Time O(1), Space O(1)
31
+ * @returns Left child node, or null/undefined.
32
+ */
17
33
  get left() {
18
34
  return this._left;
19
35
  }
36
+ /**
37
+ * Set the left child and update its parent pointer.
38
+ * @remarks Time O(1), Space O(1)
39
+ * @param v - New left child node, or null/undefined.
40
+ * @returns void
41
+ */
20
42
  set left(v) {
21
43
  if (v) {
22
44
  v.parent = this;
@@ -24,9 +46,20 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
24
46
  this._left = v;
25
47
  }
26
48
  _right = undefined;
49
+ /**
50
+ * Get the right child pointer.
51
+ * @remarks Time O(1), Space O(1)
52
+ * @returns Right child node, or null/undefined.
53
+ */
27
54
  get right() {
28
55
  return this._right;
29
56
  }
57
+ /**
58
+ * Set the right child and update its parent pointer.
59
+ * @remarks Time O(1), Space O(1)
60
+ * @param v - New right child node, or null/undefined.
61
+ * @returns void
62
+ */
30
63
  set right(v) {
31
64
  if (v) {
32
65
  v.parent = this;
@@ -35,7 +68,11 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
35
68
  }
36
69
  }
37
70
  /**
38
- *
71
+ * Red-Black Tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
72
+ * @remarks Time O(1), Space O(1)
73
+ * @template K
74
+ * @template V
75
+ * @template R
39
76
  * @example
40
77
  * // players ranked by score with their equipment
41
78
  * type Equipment = {
@@ -203,15 +240,11 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
203
240
  */
204
241
  export class TreeMultiMap extends RedBlackTree {
205
242
  /**
206
- * The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
207
- * and options.
208
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
209
- * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
210
- * TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
211
- * the RedBlackTreeMulti
212
- * @param [options] - The `options` parameter in the constructor is of type
213
- * `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
214
- * additional options for configuring the TreeMultiMap instance.
243
+ * Create a TreeMultiMap and optionally bulk-insert items.
244
+ * @remarks Time O(N log N), Space O(N)
245
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
246
+ * @param [options] - Options for TreeMultiMap (comparator, reverse, map mode).
247
+ * @returns New TreeMultiMap instance.
215
248
  */
216
249
  constructor(keysNodesEntriesOrRaws = [], options) {
217
250
  super([], { ...options });
@@ -219,59 +252,15 @@ export class TreeMultiMap extends RedBlackTree {
219
252
  this.addMany(keysNodesEntriesOrRaws);
220
253
  }
221
254
  }
222
- /**
223
- * Time Complexity: O(1)
224
- * Space Complexity: O(1)
225
- *
226
- * The `createTree` function in TypeScript overrides the default implementation to create a new
227
- * TreeMultiMap with specified options.
228
- * @param [options] - The `options` parameter in the `createTree` method is of type
229
- * `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
230
- * options when creating a new `TreeMultiMap` instance. It includes properties such as
231
- * `iterationType`, `specifyComparable
232
- * @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
233
- * data and the provided options merged with the existing properties of the current object.
234
- */
235
- createTree(options) {
236
- return new TreeMultiMap([], {
237
- iterationType: this.iterationType,
238
- specifyComparable: this._specifyComparable,
239
- toEntryFn: this._toEntryFn,
240
- isReverse: this._isReverse,
241
- isMapMode: this._isMapMode,
242
- ...options
243
- });
244
- }
245
- /**
246
- * Time Complexity: O(1)
247
- * Space Complexity: O(1)
248
- *
249
- * The function `createNode` overrides the creation of a new TreeMultiMapNode with a specified key
250
- * and value array.
251
- * @param {K} key - The `key` parameter represents the key of the node being created in the
252
- * `TreeMultiMap`.
253
- * @param {V[]} value - The `value` parameter in the `createNode` method represents an array of
254
- * values associated with a specific key in the TreeMultiMap data structure.
255
- * @returns A new instance of `TreeMultiMapNode<K, V>` is being returned with the specified key and
256
- * value. If `_isMapMode` is true, an empty array is passed as the value, otherwise the provided
257
- * value is used.
258
- */
259
- createNode(key, value = []) {
255
+ _createNode(key, value = []) {
260
256
  return new TreeMultiMapNode(key, this._isMapMode ? [] : value);
261
257
  }
262
258
  /**
263
- * Time Complexity: O(log n)
264
- * Space Complexity: O(log n)
265
- *
266
- * The function overrides the add method to handle different types of input for a TreeMultiMap data
267
- * structure.
268
- * @param [key] - The `key` parameter in the `override add` method represents the key of the entry to
269
- * be added to the TreeMultiMap. It can be of type `K`, which is the key type of the TreeMultiMap, or
270
- * it can be a TreeMultiMapNode containing the key and its
271
- * @param {V[]} [values] - The `values` parameter in the `add` method represents an array of values
272
- * that you want to add to the TreeMultiMap. It can contain one or more values of type `V`.
273
- * @returns The `add` method is returning a boolean value, which indicates whether the operation was
274
- * successful or not.
259
+ * Insert a value or a list of values into the multimap. If the key exists, values are appended.
260
+ * @remarks Time O(log N + M), Space O(1)
261
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry.
262
+ * @param [value] - Single value to add when a bare key is provided.
263
+ * @returns True if inserted or appended; false if ignored.
275
264
  */
276
265
  add(keyNodeOrEntry, value) {
277
266
  if (this.isRealNode(keyNodeOrEntry))
@@ -321,20 +310,11 @@ export class TreeMultiMap extends RedBlackTree {
321
310
  return _commonAdd(keyNodeOrEntry, value !== undefined ? [value] : undefined);
322
311
  }
323
312
  /**
324
- * Time Complexity: O(log n)
325
- * Space Complexity: O(log n)
326
- *
327
- * The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
328
- * and deletes the entire node if no values are left for that key.
329
- * @param {K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined} keyNodeOrEntry - The `keyNodeOrEntry`
330
- * parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
331
- * array of values, or just a key itself.
332
- * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
333
- * value that you want to remove from the multi-map data structure associated with a particular key.
334
- * The function checks if the value exists in the array of values associated with the key, and if
335
- * found, removes it from the array.
336
- * @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
337
- * successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
313
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
314
+ * @remarks Time O(log N), Space O(1)
315
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
316
+ * @param value - Value to remove from the bucket.
317
+ * @returns True if the value was removed; false if not found.
338
318
  */
339
319
  deleteValue(keyNodeOrEntry, value) {
340
320
  const values = this.get(keyNodeOrEntry);
@@ -343,7 +323,6 @@ export class TreeMultiMap extends RedBlackTree {
343
323
  if (index === -1)
344
324
  return false;
345
325
  values.splice(index, 1);
346
- // If no values left, remove the entire node
347
326
  if (values.length === 0)
348
327
  this.delete(keyNodeOrEntry);
349
328
  return true;
@@ -351,17 +330,49 @@ export class TreeMultiMap extends RedBlackTree {
351
330
  return false;
352
331
  }
353
332
  /**
354
- * Time Complexity: O(n)
355
- * Space Complexity: O(n)
356
- *
357
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
358
- * structure.
359
- * @returns The `cloned` object is being returned.
333
+ * Create a new tree by mapping each [key, values] bucket.
334
+ * @remarks Time O(N log N), Space O(N)
335
+ * @template MK
336
+ * @template MV
337
+ * @template MR
338
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
339
+ * @param [options] - Options for the output tree.
340
+ * @param [thisArg] - Value for `this` inside the callback.
341
+ * @returns A new RedBlackTree (or TreeMultiMap when mapping to array values; see overloads).
342
+ */
343
+ map(callback, options, thisArg) {
344
+ const out = this._createLike([], options);
345
+ let i = 0;
346
+ for (const [k, v] of this)
347
+ out.add(callback.call(thisArg, k, v, i++, this));
348
+ return out;
349
+ }
350
+ /**
351
+ * (Protected) Create an empty instance of the same concrete class.
352
+ * @remarks Time O(1), Space O(1)
353
+ * @template TK
354
+ * @template TV
355
+ * @template TR
356
+ * @param [options] - Optional constructor options for the like-kind instance.
357
+ * @returns An empty like-kind instance.
358
+ */
359
+ _createInstance(options) {
360
+ const Ctor = this.constructor;
361
+ return new Ctor([], { ...(this._snapshotOptions?.() ?? {}), ...(options ?? {}) });
362
+ }
363
+ /**
364
+ * (Protected) Create a like-kind instance and seed it from an iterable.
365
+ * @remarks Time O(N log N), Space O(N)
366
+ * @template TK
367
+ * @template TV
368
+ * @template TR
369
+ * @param iter - Iterable used to seed the new tree.
370
+ * @param [options] - Options merged with the current snapshot.
371
+ * @returns A like-kind RedBlackTree built from the iterable.
360
372
  */
361
- clone() {
362
- const cloned = this.createTree();
363
- this._clone(cloned);
364
- return cloned;
373
+ _createLike(iter = [], options) {
374
+ const Ctor = this.constructor;
375
+ return new Ctor(iter, { ...(this._snapshotOptions?.() ?? {}), ...(options ?? {}) });
365
376
  }
366
377
  }
367
378
  //# sourceMappingURL=tree-multi-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGlE,MAAM,OAAO,gBAAmC,SAAQ,gBAAwB;IACrE,MAAM,GAA4B,SAAS,CAAC;IAErD;;;;;;;;OAQG;IACH,YAAY,GAAM,EAAE,KAAW;QAC7B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAEQ,KAAK,GAA+C,SAAS,CAAC;IAEvE,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAA4C;QAC5D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM,GAA+C,SAAS,CAAC;IAExE,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAa,KAAK,CAAC,CAA4C;QAC7D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsKG;AACH,MAAM,OAAO,YACX,SAAQ,YAAqC;IAG7C;;;;;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AC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,UAAU,CAAC,cAAc,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACT,cAAuG,EACvG,KAAQ;QAER,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAExB,4CAA4C;YAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAErD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACM,KAAK;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
1
+ {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGlE;;;;;GAKG;AACH,MAAM,OAAO,gBAAmC,SAAQ,gBAAwB;IACrE,MAAM,GAA4B,SAAS,CAAC;IAErD;;;;;;OAMG;IACH,YAAY,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