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,100 +5,131 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { AVLTreeMultiMapOptions } from '../../types';
8
+ import type { AVLTreeMultiMapOptions, AVLTreeOptions, ElemOf, EntryCallback, IterationType } from '../../types';
9
9
  import { AVLTree, AVLTreeNode } from './avl-tree';
10
10
  import { IBinaryTree } from '../../interfaces';
11
+ /**
12
+ * Node used by AVLTreeMultiMap; 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 AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K, V[]> {
12
18
  parent?: AVLTreeMultiMapNode<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 an AVLTreeMultiMap node with a 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 AVLTreeMultiMapNode instance.
21
25
  */
22
26
  constructor(key: K, value: V[]);
23
27
  _left?: AVLTreeMultiMapNode<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(): AVLTreeMultiMapNode<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: AVLTreeMultiMapNode<K, V> | null | undefined);
26
41
  _right?: AVLTreeMultiMapNode<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(): AVLTreeMultiMapNode<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: AVLTreeMultiMapNode<K, V> | null | undefined);
29
55
  }
30
56
  /**
31
- *
57
+ * AVL-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
  */
33
- export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends AVLTree<K, V[], R, MK, MV[], MR> implements IBinaryTree<K, V[], R, MK, MV, MR> {
63
+ export declare class AVLTreeMultiMap<K = any, V = any, R extends object = object> extends AVLTree<K, V[], R> implements IBinaryTree<K, V[], R> {
34
64
  /**
35
- * The constructor initializes an AVLTreeMultiMap with the provided keys, nodes, entries, or raw data
36
- * and options.
37
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
38
- * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
39
- * AVLTreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
40
- * the AVLTreeMulti
41
- * @param [options] - The `options` parameter in the constructor is of type
42
- * `AVLTreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
43
- * additional options for configuring the AVLTreeMultiMap instance.
65
+ * Create an AVLTreeMultiMap and optionally bulk-insert items.
66
+ * @remarks Time O(N log N), Space O(N)
67
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
68
+ * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
69
+ * @returns New AVLTreeMultiMap instance.
44
70
  */
45
71
  constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
72
+ _createNode(key: K, value?: V[]): AVLTreeMultiMapNode<K, V>;
73
+ add(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
74
+ add(key: K, value: V): boolean;
46
75
  /**
47
- * Time Complexity: O(1)
48
- * Space Complexity: O(1)
49
- *
50
- * The function `createTree` in TypeScript overrides the creation of an AVLTreeMultiMap with
51
- * specified options.
52
- * @param [options] - The `options` parameter in the `createTree` function is of type
53
- * `AVLTreeMultiMapOptions<K, V[], R>`. This means it is an object that can have properties of type
54
- * `K`, `V[]`, and `R`. The function creates a new `AVL
55
- * @returns The `createTree` method is returning a new instance of `AVLTreeMultiMap` with the
56
- * provided options.
76
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
77
+ * @remarks Time O(log N), Space O(1)
78
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
79
+ * @param value - Value to remove from the bucket.
80
+ * @returns True if the value was removed; false if not found.
57
81
  */
58
- createTree(options?: AVLTreeMultiMapOptions<K, V[], R>): AVLTreeMultiMap<K, V, R, MK, MV, MR>;
82
+ deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined, value: V): boolean;
59
83
  /**
60
- * Time Complexity: O(1)
61
- * Space Complexity: O(1)
62
- *
63
- * The `createNode` function in TypeScript overrides the default implementation to create a new
64
- * AVLTreeMultiMapNode with a specified key and value array.
65
- * @param {K} key - The `key` parameter represents the key of the node being created in the
66
- * AVLTreeMultiMap.
67
- * @param {V[]} value - The `value` parameter in the `createNode` method represents an array of
68
- * values associated with a specific key in the AVLTreeMultiMapNode. If no value is provided when
69
- * calling the method, an empty array `[]` is used as the default value.
70
- * @returns An AVLTreeMultiMapNode object is being returned, with the specified key and value. If the
71
- * AVLTreeMultiMap is in map mode, an empty array is used as the value, otherwise the provided value
72
- * array is used.
84
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
85
+ * @remarks Time O(N), Space O(N)
86
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
87
+ * @returns True if rebalancing succeeded (tree not empty).
73
88
  */
74
- createNode(key: K, value?: V[]): AVLTreeMultiMapNode<K, V>;
75
- add(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
76
- add(key: K, value: V): boolean;
89
+ perfectlyBalance(iterationType?: IterationType): boolean;
90
+ /**
91
+ * Create a new tree by mapping each [key, values] bucket.
92
+ * @remarks Time O(N log N), Space O(N)
93
+ * @template MK
94
+ * @template MVArr
95
+ * @template MR
96
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
97
+ * @param [options] - Options for the output tree.
98
+ * @param [thisArg] - Value for `this` inside the callback.
99
+ * @returns A new AVLTreeMultiMap when mapping to array values; see overloads.
100
+ */
101
+ map<MK = K, MVArr extends unknown[] = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<AVLTreeOptions<MK, MVArr, MR>>, thisArg?: unknown): AVLTreeMultiMap<MK, ElemOf<MVArr>, MR>;
102
+ /**
103
+ * Create a new tree by mapping each [key, values] bucket.
104
+ * @remarks Time O(N log N), Space O(N)
105
+ * @template MK
106
+ * @template MV
107
+ * @template MR
108
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
109
+ * @param [options] - Options for the output tree.
110
+ * @param [thisArg] - Value for `this` inside the callback.
111
+ * @returns A new AVLTree when mapping to non-array values; see overloads.
112
+ */
113
+ map<MK = K, MV = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<AVLTreeOptions<MK, MV, MR>>, thisArg?: unknown): AVLTree<MK, MV, MR>;
77
114
  /**
78
- * Time Complexity: O(log n)
79
- * Space Complexity: O(log n)
80
- *
81
- * The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
82
- * structure and deletes the entire node if no values are left for that key.
83
- * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
84
- * parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
85
- * pair in the AVLTreeMultiMapNode, or just the key itself.
86
- * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
87
- * value that you want to delete from the multi-map data structure associated with a particular key.
88
- * The function checks if the value exists in the array of values associated with the key, and if
89
- * found, removes it from the array.
90
- * @returns The `deleteValue` function returns a boolean value. It returns `true` if the specified
91
- * `value` was successfully deleted from the array of values associated with the `keyNodeOrEntry`. If
92
- * the value was not found in the array, it returns `false`.
115
+ * (Protected) Create an empty instance of the same concrete class.
116
+ * @remarks Time O(1), Space O(1)
117
+ * @template TK
118
+ * @template TV
119
+ * @template TR
120
+ * @param [options] - Optional constructor options for the like-kind instance.
121
+ * @returns An empty like-kind instance.
93
122
  */
94
- deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K, value: V): boolean;
123
+ protected _createInstance<TK = K, TV = V, TR extends object = R>(options?: Partial<AVLTreeOptions<TK, TV, TR>>): this;
95
124
  /**
96
- * Time Complexity: O(n)
97
- * Space Complexity: O(n)
98
- *
99
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
100
- * structure.
101
- * @returns A cloned tree object is being returned.
125
+ * (Protected) Create a like-kind instance and seed it from an iterable.
126
+ * @remarks Time O(N log N), Space O(N)
127
+ * @template TK
128
+ * @template TV
129
+ * @template TR
130
+ * @param iter - Iterable used to seed the new tree.
131
+ * @param [options] - Options merged with the current snapshot.
132
+ * @returns A like-kind AVLTree built from the iterable.
102
133
  */
103
- clone(): AVLTreeMultiMap<K, V, R, MK, MV, MR>;
134
+ protected _createLike<TK = K, TV = V, TR extends object = R>(iter?: Iterable<TK | AVLTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<AVLTreeOptions<TK, TV, TR>>): AVLTree<TK, TV, TR>;
104
135
  }
@@ -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 { AVLTree, AVLTreeNode } from './avl-tree';
9
+ /**
10
+ * Node used by AVLTreeMultiMap; 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 AVLTreeMultiMapNode extends AVLTreeNode {
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 an AVLTreeMultiMap node with a 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 AVLTreeMultiMapNode 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 AVLTreeMultiMapNode extends AVLTreeNode {
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,19 +68,19 @@ export class AVLTreeMultiMapNode extends AVLTreeNode {
35
68
  }
36
69
  }
37
70
  /**
38
- *
71
+ * AVL-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
  */
40
77
  export class AVLTreeMultiMap extends AVLTree {
41
78
  /**
42
- * The constructor initializes an AVLTreeMultiMap with the provided keys, nodes, entries, or raw data
43
- * and options.
44
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
45
- * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
46
- * AVLTreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
47
- * the AVLTreeMulti
48
- * @param [options] - The `options` parameter in the constructor is of type
49
- * `AVLTreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
50
- * additional options for configuring the AVLTreeMultiMap instance.
79
+ * Create an AVLTreeMultiMap and optionally bulk-insert items.
80
+ * @remarks Time O(N log N), Space O(N)
81
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
82
+ * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
83
+ * @returns New AVLTreeMultiMap instance.
51
84
  */
52
85
  constructor(keysNodesEntriesOrRaws = [], options) {
53
86
  super([], { ...options, isMapMode: true });
@@ -55,60 +88,15 @@ export class AVLTreeMultiMap extends AVLTree {
55
88
  this.addMany(keysNodesEntriesOrRaws);
56
89
  }
57
90
  }
58
- /**
59
- * Time Complexity: O(1)
60
- * Space Complexity: O(1)
61
- *
62
- * The function `createTree` in TypeScript overrides the creation of an AVLTreeMultiMap with
63
- * specified options.
64
- * @param [options] - The `options` parameter in the `createTree` function is of type
65
- * `AVLTreeMultiMapOptions<K, V[], R>`. This means it is an object that can have properties of type
66
- * `K`, `V[]`, and `R`. The function creates a new `AVL
67
- * @returns The `createTree` method is returning a new instance of `AVLTreeMultiMap` with the
68
- * provided options.
69
- */
70
- createTree(options) {
71
- return new AVLTreeMultiMap([], {
72
- iterationType: this.iterationType,
73
- specifyComparable: this._specifyComparable,
74
- toEntryFn: this._toEntryFn,
75
- isReverse: this._isReverse,
76
- isMapMode: this._isMapMode,
77
- ...options
78
- });
79
- }
80
- /**
81
- * Time Complexity: O(1)
82
- * Space Complexity: O(1)
83
- *
84
- * The `createNode` function in TypeScript overrides the default implementation to create a new
85
- * AVLTreeMultiMapNode with a specified key and value array.
86
- * @param {K} key - The `key` parameter represents the key of the node being created in the
87
- * AVLTreeMultiMap.
88
- * @param {V[]} value - The `value` parameter in the `createNode` method represents an array of
89
- * values associated with a specific key in the AVLTreeMultiMapNode. If no value is provided when
90
- * calling the method, an empty array `[]` is used as the default value.
91
- * @returns An AVLTreeMultiMapNode object is being returned, with the specified key and value. If the
92
- * AVLTreeMultiMap is in map mode, an empty array is used as the value, otherwise the provided value
93
- * array is used.
94
- */
95
- createNode(key, value = []) {
91
+ _createNode(key, value = []) {
96
92
  return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
97
93
  }
98
94
  /**
99
- * Time Complexity: O(log n)
100
- * Space Complexity: O(log n)
101
- *
102
- * The function `add` in this TypeScript code overrides the superclass method to add key-value pairs
103
- * to an AVLTreeMultiMap, handling different input types and scenarios.
104
- * @param [key] - The `key` parameter in the `override add` method represents the key of the entry to
105
- * be added to the AVLTreeMultiMap. It can be of type `K`, which is the key type of the map. The key
106
- * can be a single key value, a node of the AVLTree
107
- * @param {V[]} [values] - The `values` parameter in the `add` method represents an array of values
108
- * that you want to add to the AVLTreeMultiMap. It can contain one or more values associated with a
109
- * specific key.
110
- * @returns The `add` method is returning a boolean value, which indicates whether the operation was
111
- * successful or not.
95
+ * Insert a value or a list of values into the multimap. If the key exists, values are appended.
96
+ * @remarks Time O(log N + M), Space O(1)
97
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry.
98
+ * @param [value] - Single value to add when a bare key is provided.
99
+ * @returns True if inserted or appended; false if ignored.
112
100
  */
113
101
  add(keyNodeOrEntry, value) {
114
102
  if (this.isRealNode(keyNodeOrEntry))
@@ -158,21 +146,11 @@ export class AVLTreeMultiMap extends AVLTree {
158
146
  return _commonAdd(keyNodeOrEntry, value !== undefined ? [value] : undefined);
159
147
  }
160
148
  /**
161
- * Time Complexity: O(log n)
162
- * Space Complexity: O(log n)
163
- *
164
- * The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
165
- * structure and deletes the entire node if no values are left for that key.
166
- * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
167
- * parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
168
- * pair in the AVLTreeMultiMapNode, or just the key itself.
169
- * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
170
- * value that you want to delete from the multi-map data structure associated with a particular key.
171
- * The function checks if the value exists in the array of values associated with the key, and if
172
- * found, removes it from the array.
173
- * @returns The `deleteValue` function returns a boolean value. It returns `true` if the specified
174
- * `value` was successfully deleted from the array of values associated with the `keyNodeOrEntry`. If
175
- * the value was not found in the array, it returns `false`.
149
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
150
+ * @remarks Time O(log N), Space O(1)
151
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
152
+ * @param value - Value to remove from the bucket.
153
+ * @returns True if the value was removed; false if not found.
176
154
  */
177
155
  deleteValue(keyNodeOrEntry, value) {
178
156
  const values = this.get(keyNodeOrEntry);
@@ -181,7 +159,6 @@ export class AVLTreeMultiMap extends AVLTree {
181
159
  if (index === -1)
182
160
  return false;
183
161
  values.splice(index, 1);
184
- // If no values left, remove the entire node
185
162
  if (values.length === 0)
186
163
  this.delete(keyNodeOrEntry);
187
164
  return true;
@@ -189,17 +166,79 @@ export class AVLTreeMultiMap extends AVLTree {
189
166
  return false;
190
167
  }
191
168
  /**
192
- * Time Complexity: O(n)
193
- * Space Complexity: O(n)
194
- *
195
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
196
- * structure.
197
- * @returns A cloned tree object is being returned.
169
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
170
+ * @remarks Time O(N), Space O(N)
171
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
172
+ * @returns True if rebalancing succeeded (tree not empty).
173
+ */
174
+ perfectlyBalance(iterationType = this.iterationType) {
175
+ const nodes = this.dfs(node => node, 'IN', false, this._root, iterationType);
176
+ const n = nodes.length;
177
+ if (n === 0)
178
+ return false;
179
+ this._clearNodes();
180
+ const build = (l, r, parent) => {
181
+ if (l > r)
182
+ return undefined;
183
+ const m = l + ((r - l) >> 1);
184
+ const root = nodes[m];
185
+ root.left = build(l, m - 1, root);
186
+ root.right = build(m + 1, r, root);
187
+ root.parent = parent;
188
+ const lh = root.left ? root.left.height : -1;
189
+ const rh = root.right ? root.right.height : -1;
190
+ root.height = Math.max(lh, rh) + 1;
191
+ return root;
192
+ };
193
+ const newRoot = build(0, n - 1, undefined);
194
+ this._setRoot(newRoot);
195
+ this._size = n;
196
+ return true;
197
+ }
198
+ /**
199
+ * Create a new tree by mapping each [key, values] bucket.
200
+ * @remarks Time O(N log N), Space O(N)
201
+ * @template MK
202
+ * @template MV
203
+ * @template MR
204
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
205
+ * @param [options] - Options for the output tree.
206
+ * @param [thisArg] - Value for `this` inside the callback.
207
+ * @returns The mapped AVLTree or AVLTreeMultiMap depending on MV; see overloads.
208
+ */
209
+ map(callback, options, thisArg) {
210
+ const out = this._createLike([], options);
211
+ let i = 0;
212
+ for (const [k, v] of this)
213
+ out.add(callback.call(thisArg, k, v, i++, this));
214
+ return out;
215
+ }
216
+ /**
217
+ * (Protected) Create an empty instance of the same concrete class.
218
+ * @remarks Time O(1), Space O(1)
219
+ * @template TK
220
+ * @template TV
221
+ * @template TR
222
+ * @param [options] - Optional constructor options for the like-kind instance.
223
+ * @returns An empty like-kind instance.
224
+ */
225
+ _createInstance(options) {
226
+ const Ctor = this.constructor;
227
+ return new Ctor([], { ...(this._snapshotOptions?.() ?? {}), ...(options ?? {}) });
228
+ }
229
+ /**
230
+ * (Protected) Create a like-kind instance and seed it from an iterable.
231
+ * @remarks Time O(N log N), Space O(N)
232
+ * @template TK
233
+ * @template TV
234
+ * @template TR
235
+ * @param iter - Iterable used to seed the new tree.
236
+ * @param [options] - Options merged with the current snapshot.
237
+ * @returns A like-kind AVLTree built from the iterable.
198
238
  */
199
- clone() {
200
- const cloned = this.createTree();
201
- this._clone(cloned);
202
- return cloned;
239
+ _createLike(iter = [], options) {
240
+ const Ctor = this.constructor;
241
+ return new Ctor(iter, { ...(this._snapshotOptions?.() ?? {}), ...(options ?? {}) });
203
242
  }
204
243
  }
205
244
  //# sourceMappingURL=avl-tree-multi-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avl-tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-multi-map.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,OAAO,mBAAsC,SAAQ,WAAmB;IACnE,MAAM,GAA+B,SAAS,CAAC;IAExD;;;;;;;;OAQG;IACH,YAAY,GAAM,EAAE,KAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAEQ,KAAK,GAAkD,SAAS,CAAC;IAE1E,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAA+C;QAC/D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM,GAAkD,SAAS,CAAC;IAE3E,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAa,KAAK,CAAC,CAA+C;QAChE,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAA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C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC;YACrC,OAAO,UAAU,CAAC,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,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;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CACT,cAA8G,EAC9G,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":"avl-tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-multi-map.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,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