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,16 +1,27 @@
1
1
  "use strict";
2
+ /**
3
+ * data-structure-typed
4
+ *
5
+ * @author Pablo Zeng
6
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
7
+ * @license MIT License
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.AVLTreeMultiMap = exports.AVLTreeMultiMapNode = void 0;
4
11
  const avl_tree_1 = require("./avl-tree");
12
+ /**
13
+ * Node used by AVLTreeMultiMap; stores the key with a bucket of values (array).
14
+ * @remarks Time O(1), Space O(1)
15
+ * @template K
16
+ * @template V
17
+ */
5
18
  class AVLTreeMultiMapNode extends avl_tree_1.AVLTreeNode {
6
19
  /**
7
- * This TypeScript constructor initializes an object with a key of type K and an array of values of
8
- * type V.
9
- * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
10
- * data being stored in the data structure. It helps in quickly accessing or retrieving the
11
- * associated value in the data structure.
12
- * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
13
- * 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.
14
25
  */
15
26
  constructor(key, value) {
16
27
  super(key, value);
@@ -18,18 +29,40 @@ class AVLTreeMultiMapNode extends avl_tree_1.AVLTreeNode {
18
29
  this._left = undefined;
19
30
  this._right = undefined;
20
31
  }
32
+ /**
33
+ * Get the left child pointer.
34
+ * @remarks Time O(1), Space O(1)
35
+ * @returns Left child node, or null/undefined.
36
+ */
21
37
  get left() {
22
38
  return this._left;
23
39
  }
40
+ /**
41
+ * Set the left child and update its parent pointer.
42
+ * @remarks Time O(1), Space O(1)
43
+ * @param v - New left child node, or null/undefined.
44
+ * @returns void
45
+ */
24
46
  set left(v) {
25
47
  if (v) {
26
48
  v.parent = this;
27
49
  }
28
50
  this._left = v;
29
51
  }
52
+ /**
53
+ * Get the right child pointer.
54
+ * @remarks Time O(1), Space O(1)
55
+ * @returns Right child node, or null/undefined.
56
+ */
30
57
  get right() {
31
58
  return this._right;
32
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
+ */
33
66
  set right(v) {
34
67
  if (v) {
35
68
  v.parent = this;
@@ -39,19 +72,19 @@ class AVLTreeMultiMapNode extends avl_tree_1.AVLTreeNode {
39
72
  }
40
73
  exports.AVLTreeMultiMapNode = AVLTreeMultiMapNode;
41
74
  /**
42
- *
75
+ * AVL-tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
76
+ * @remarks Time O(1), Space O(1)
77
+ * @template K
78
+ * @template V
79
+ * @template R
43
80
  */
44
81
  class AVLTreeMultiMap extends avl_tree_1.AVLTree {
45
82
  /**
46
- * The constructor initializes an AVLTreeMultiMap with the provided keys, nodes, entries, or raw data
47
- * and options.
48
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
49
- * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
50
- * AVLTreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
51
- * the AVLTreeMulti
52
- * @param [options] - The `options` parameter in the constructor is of type
53
- * `AVLTreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
54
- * additional options for configuring the AVLTreeMultiMap instance.
83
+ * Create an AVLTreeMultiMap and optionally bulk-insert items.
84
+ * @remarks Time O(N log N), Space O(N)
85
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
86
+ * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
87
+ * @returns New AVLTreeMultiMap instance.
55
88
  */
56
89
  constructor(keysNodesEntriesOrRaws = [], options) {
57
90
  super([], Object.assign(Object.assign({}, options), { isMapMode: true }));
@@ -59,53 +92,15 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
59
92
  this.addMany(keysNodesEntriesOrRaws);
60
93
  }
61
94
  }
62
- /**
63
- * Time Complexity: O(1)
64
- * Space Complexity: O(1)
65
- *
66
- * The function `createTree` in TypeScript overrides the creation of an AVLTreeMultiMap with
67
- * specified options.
68
- * @param [options] - The `options` parameter in the `createTree` function is of type
69
- * `AVLTreeMultiMapOptions<K, V[], R>`. This means it is an object that can have properties of type
70
- * `K`, `V[]`, and `R`. The function creates a new `AVL
71
- * @returns The `createTree` method is returning a new instance of `AVLTreeMultiMap` with the
72
- * provided options.
73
- */
74
- createTree(options) {
75
- return new AVLTreeMultiMap([], Object.assign({ iterationType: this.iterationType, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn, isReverse: this._isReverse, isMapMode: this._isMapMode }, options));
76
- }
77
- /**
78
- * Time Complexity: O(1)
79
- * Space Complexity: O(1)
80
- *
81
- * The `createNode` function in TypeScript overrides the default implementation to create a new
82
- * AVLTreeMultiMapNode with a specified key and value array.
83
- * @param {K} key - The `key` parameter represents the key of the node being created in the
84
- * AVLTreeMultiMap.
85
- * @param {V[]} value - The `value` parameter in the `createNode` method represents an array of
86
- * values associated with a specific key in the AVLTreeMultiMapNode. If no value is provided when
87
- * calling the method, an empty array `[]` is used as the default value.
88
- * @returns An AVLTreeMultiMapNode object is being returned, with the specified key and value. If the
89
- * AVLTreeMultiMap is in map mode, an empty array is used as the value, otherwise the provided value
90
- * array is used.
91
- */
92
- createNode(key, value = []) {
95
+ _createNode(key, value = []) {
93
96
  return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
94
97
  }
95
98
  /**
96
- * Time Complexity: O(log n)
97
- * Space Complexity: O(log n)
98
- *
99
- * The function `add` in this TypeScript code overrides the superclass method to add key-value pairs
100
- * to an AVLTreeMultiMap, handling different input types and scenarios.
101
- * @param [key] - The `key` parameter in the `override add` method represents the key of the entry to
102
- * be added to the AVLTreeMultiMap. It can be of type `K`, which is the key type of the map. The key
103
- * can be a single key value, a node of the AVLTree
104
- * @param {V[]} [values] - The `values` parameter in the `add` method represents an array of values
105
- * that you want to add to the AVLTreeMultiMap. It can contain one or more values associated with a
106
- * specific key.
107
- * @returns The `add` method is returning a boolean value, which indicates whether the operation was
108
- * successful or not.
99
+ * Insert a value or a list of values into the multimap. If the key exists, values are appended.
100
+ * @remarks Time O(log N + M), Space O(1)
101
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry.
102
+ * @param [value] - Single value to add when a bare key is provided.
103
+ * @returns True if inserted or appended; false if ignored.
109
104
  */
110
105
  add(keyNodeOrEntry, value) {
111
106
  if (this.isRealNode(keyNodeOrEntry))
@@ -155,21 +150,11 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
155
150
  return _commonAdd(keyNodeOrEntry, value !== undefined ? [value] : undefined);
156
151
  }
157
152
  /**
158
- * Time Complexity: O(log n)
159
- * Space Complexity: O(log n)
160
- *
161
- * The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
162
- * structure and deletes the entire node if no values are left for that key.
163
- * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
164
- * parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
165
- * pair in the AVLTreeMultiMapNode, or just the key itself.
166
- * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
167
- * value that you want to delete from the multi-map data structure associated with a particular key.
168
- * The function checks if the value exists in the array of values associated with the key, and if
169
- * found, removes it from the array.
170
- * @returns The `deleteValue` function returns a boolean value. It returns `true` if the specified
171
- * `value` was successfully deleted from the array of values associated with the `keyNodeOrEntry`. If
172
- * the value was not found in the array, it returns `false`.
153
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
154
+ * @remarks Time O(log N), Space O(1)
155
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
156
+ * @param value - Value to remove from the bucket.
157
+ * @returns True if the value was removed; false if not found.
173
158
  */
174
159
  deleteValue(keyNodeOrEntry, value) {
175
160
  const values = this.get(keyNodeOrEntry);
@@ -178,7 +163,6 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
178
163
  if (index === -1)
179
164
  return false;
180
165
  values.splice(index, 1);
181
- // If no values left, remove the entire node
182
166
  if (values.length === 0)
183
167
  this.delete(keyNodeOrEntry);
184
168
  return true;
@@ -186,17 +170,81 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
186
170
  return false;
187
171
  }
188
172
  /**
189
- * Time Complexity: O(n)
190
- * Space Complexity: O(n)
191
- *
192
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
193
- * structure.
194
- * @returns A cloned tree object is being returned.
173
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
174
+ * @remarks Time O(N), Space O(N)
175
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
176
+ * @returns True if rebalancing succeeded (tree not empty).
177
+ */
178
+ perfectlyBalance(iterationType = this.iterationType) {
179
+ const nodes = this.dfs(node => node, 'IN', false, this._root, iterationType);
180
+ const n = nodes.length;
181
+ if (n === 0)
182
+ return false;
183
+ this._clearNodes();
184
+ const build = (l, r, parent) => {
185
+ if (l > r)
186
+ return undefined;
187
+ const m = l + ((r - l) >> 1);
188
+ const root = nodes[m];
189
+ root.left = build(l, m - 1, root);
190
+ root.right = build(m + 1, r, root);
191
+ root.parent = parent;
192
+ const lh = root.left ? root.left.height : -1;
193
+ const rh = root.right ? root.right.height : -1;
194
+ root.height = Math.max(lh, rh) + 1;
195
+ return root;
196
+ };
197
+ const newRoot = build(0, n - 1, undefined);
198
+ this._setRoot(newRoot);
199
+ this._size = n;
200
+ return true;
201
+ }
202
+ /**
203
+ * Create a new tree by mapping each [key, values] bucket.
204
+ * @remarks Time O(N log N), Space O(N)
205
+ * @template MK
206
+ * @template MV
207
+ * @template MR
208
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
209
+ * @param [options] - Options for the output tree.
210
+ * @param [thisArg] - Value for `this` inside the callback.
211
+ * @returns The mapped AVLTree or AVLTreeMultiMap depending on MV; see overloads.
212
+ */
213
+ map(callback, options, thisArg) {
214
+ const out = this._createLike([], options);
215
+ let i = 0;
216
+ for (const [k, v] of this)
217
+ out.add(callback.call(thisArg, k, v, i++, this));
218
+ return out;
219
+ }
220
+ /**
221
+ * (Protected) Create an empty instance of the same concrete class.
222
+ * @remarks Time O(1), Space O(1)
223
+ * @template TK
224
+ * @template TV
225
+ * @template TR
226
+ * @param [options] - Optional constructor options for the like-kind instance.
227
+ * @returns An empty like-kind instance.
228
+ */
229
+ _createInstance(options) {
230
+ var _a, _b;
231
+ const Ctor = this.constructor;
232
+ return new Ctor([], Object.assign(Object.assign({}, ((_b = (_a = this._snapshotOptions) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : {})), (options !== null && options !== void 0 ? options : {})));
233
+ }
234
+ /**
235
+ * (Protected) Create a like-kind instance and seed it from an iterable.
236
+ * @remarks Time O(N log N), Space O(N)
237
+ * @template TK
238
+ * @template TV
239
+ * @template TR
240
+ * @param iter - Iterable used to seed the new tree.
241
+ * @param [options] - Options merged with the current snapshot.
242
+ * @returns A like-kind AVLTree built from the iterable.
195
243
  */
196
- clone() {
197
- const cloned = this.createTree();
198
- this._clone(cloned);
199
- return cloned;
244
+ _createLike(iter = [], options) {
245
+ var _a, _b;
246
+ const Ctor = this.constructor;
247
+ return new Ctor(iter, Object.assign(Object.assign({}, ((_b = (_a = this._snapshotOptions) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : {})), (options !== null && options !== void 0 ? options : {})));
200
248
  }
201
249
  }
202
250
  exports.AVLTreeMultiMap = AVLTreeMultiMap;
@@ -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,yCAAkD;AAGlD,MAAa,mBAAsC,SAAQ,sBAAmB;IAG5E;;;;;;;;OAQG;IACH,YAAY,GAAM,EAAE,KAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAZX,WAAM,GAA+B,SAAS,CAAC;QAe/C,UAAK,GAAkD,SAAS,CAAC;QAajE,WAAM,GAAkD,SAAS,CAAC;IAf3E,CAAC;IAID,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAA+C;QAC/D,IAAI,CAAC,EA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G,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA7LD,0CA6LC"}
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,yCAAkD;AAGlD;;;;;GAKG;AACH,MAAa,mBAAsC,SAAQ,sBAAmB;IAG5E;;;;;;OAMG;IACH,YAAY,GAAM,EAAE,KAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAVX,WAAM,GAA+B,SAAS,CAAC;QAa/C,UAAK,GAAkD,SAAS,CAAC;QAwBjE,WAAM,GAAkD,SAAS,CAAC;IA1B3E,CAAC;IAID;;;;OAIG;IACH,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,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;IAID;;;;OAIG;IACH,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACH,IAAa,KAAK,CAAC,CAA+C;QAChE,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA7DD,kDA6DC;AAED;;;;;;GAMG;AACH,MAAa,eACX,SAAQ,kBAAkB;IAG1B;;;;;;OAMG;IACH,YACE,yBAEI,EAAE,EACN,OAA2C;QAE3C,KAAK,CAAC,EAAE,kCAAO,OAAO,KAAE,SAAS,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