tree-multimap-typed 2.1.1 → 2.2.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 (288) hide show
  1. package/dist/cjs/index.cjs +4298 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs-legacy/index.cjs +4300 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -0
  5. package/dist/esm/index.mjs +4287 -0
  6. package/dist/esm/index.mjs.map +1 -0
  7. package/dist/esm-legacy/index.mjs +4289 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -0
  9. package/dist/types/data-structures/base/index.d.ts +2 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -2
  11. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -2
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +345 -2
  13. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
  14. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
  15. package/dist/types/data-structures/binary-tree/bst.d.ts +467 -12
  16. package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
  17. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +262 -3
  18. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
  19. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +244 -2
  20. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +332 -2
  21. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
  22. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
  23. package/dist/types/data-structures/graph/index.d.ts +2 -1
  24. package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
  25. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
  26. package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
  27. package/dist/types/data-structures/hash/index.d.ts +0 -1
  28. package/dist/types/data-structures/heap/heap.d.ts +503 -5
  29. package/dist/types/data-structures/heap/index.d.ts +2 -0
  30. package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
  31. package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
  32. package/dist/types/data-structures/index.d.ts +7 -7
  33. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
  34. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
  35. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
  36. package/dist/types/data-structures/matrix/index.d.ts +1 -1
  37. package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
  38. package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
  39. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
  40. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
  41. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
  42. package/dist/types/data-structures/queue/deque.d.ts +431 -4
  43. package/dist/types/data-structures/queue/queue.d.ts +308 -4
  44. package/dist/types/data-structures/stack/stack.d.ts +306 -2
  45. package/dist/types/data-structures/tree/tree.d.ts +62 -1
  46. package/dist/types/data-structures/trie/trie.d.ts +350 -4
  47. package/dist/types/index.d.ts +17 -2
  48. package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +1 -1
  49. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  50. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  51. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  52. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  53. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  54. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  55. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  56. package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
  57. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  58. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  59. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  60. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  61. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  62. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  63. package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
  64. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  65. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  66. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  67. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  68. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  69. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  70. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  71. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  72. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  73. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  74. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  75. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  76. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  77. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  78. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  79. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  80. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  81. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  82. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  83. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  84. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  85. package/dist/types/types/index.d.ts +3 -0
  86. package/dist/types/types/utils/index.d.ts +2 -0
  87. package/dist/types/types/utils/utils.d.ts +22 -0
  88. package/dist/types/utils/index.d.ts +1 -1
  89. package/dist/types/utils/utils.d.ts +209 -22
  90. package/dist/umd/tree-multimap-typed.js +4289 -0
  91. package/dist/umd/tree-multimap-typed.js.map +1 -0
  92. package/dist/umd/tree-multimap-typed.min.js +13 -0
  93. package/dist/umd/tree-multimap-typed.min.js.map +1 -0
  94. package/package.json +43 -5
  95. package/src/data-structures/binary-tree/avl-tree-counter.ts +106 -15
  96. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +116 -12
  97. package/src/data-structures/binary-tree/avl-tree.ts +107 -16
  98. package/src/data-structures/binary-tree/binary-tree.ts +4 -4
  99. package/src/data-structures/binary-tree/bst.ts +103 -12
  100. package/src/data-structures/binary-tree/red-black-tree.ts +110 -20
  101. package/src/data-structures/binary-tree/tree-counter.ts +105 -14
  102. package/src/data-structures/binary-tree/tree-multi-map.ts +123 -12
  103. package/src/data-structures/graph/abstract-graph.ts +5 -5
  104. package/src/data-structures/graph/directed-graph.ts +5 -5
  105. package/src/data-structures/graph/undirected-graph.ts +5 -5
  106. package/src/data-structures/heap/heap.ts +5 -5
  107. package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
  108. package/src/interfaces/binary-tree.ts +1 -1
  109. package/tsconfig.base.json +23 -0
  110. package/tsconfig.json +8 -34
  111. package/tsconfig.test.json +8 -0
  112. package/tsconfig.types.json +15 -0
  113. package/tsup.config.js +28 -0
  114. package/tsup.node.config.js +71 -0
  115. package/dist/common/index.js +0 -28
  116. package/dist/constants/index.js +0 -8
  117. package/dist/data-structures/base/index.d.ts +0 -2
  118. package/dist/data-structures/base/index.js +0 -18
  119. package/dist/data-structures/base/iterable-element-base.js +0 -243
  120. package/dist/data-structures/base/iterable-entry-base.js +0 -183
  121. package/dist/data-structures/base/linear-base.js +0 -415
  122. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  123. package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
  124. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  125. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
  126. package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
  127. package/dist/data-structures/binary-tree/avl-tree.js +0 -611
  128. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  129. package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
  130. package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
  131. package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
  132. package/dist/data-structures/binary-tree/bst.d.ts +0 -413
  133. package/dist/data-structures/binary-tree/bst.js +0 -903
  134. package/dist/data-structures/binary-tree/index.js +0 -26
  135. package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  136. package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
  137. package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
  138. package/dist/data-structures/binary-tree/segment-tree.js +0 -297
  139. package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
  140. package/dist/data-structures/binary-tree/tree-counter.js +0 -413
  141. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  142. package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
  143. package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
  144. package/dist/data-structures/graph/abstract-graph.js +0 -896
  145. package/dist/data-structures/graph/directed-graph.d.ts +0 -207
  146. package/dist/data-structures/graph/directed-graph.js +0 -525
  147. package/dist/data-structures/graph/index.js +0 -20
  148. package/dist/data-structures/graph/map-graph.d.ts +0 -78
  149. package/dist/data-structures/graph/map-graph.js +0 -107
  150. package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
  151. package/dist/data-structures/graph/undirected-graph.js +0 -424
  152. package/dist/data-structures/hash/hash-map.d.ts +0 -345
  153. package/dist/data-structures/hash/hash-map.js +0 -692
  154. package/dist/data-structures/hash/index.d.ts +0 -1
  155. package/dist/data-structures/hash/index.js +0 -17
  156. package/dist/data-structures/heap/heap.d.ts +0 -503
  157. package/dist/data-structures/heap/heap.js +0 -901
  158. package/dist/data-structures/heap/index.d.ts +0 -3
  159. package/dist/data-structures/heap/index.js +0 -19
  160. package/dist/data-structures/heap/max-heap.d.ts +0 -32
  161. package/dist/data-structures/heap/max-heap.js +0 -40
  162. package/dist/data-structures/heap/min-heap.d.ts +0 -33
  163. package/dist/data-structures/heap/min-heap.js +0 -31
  164. package/dist/data-structures/index.js +0 -28
  165. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  166. package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
  167. package/dist/data-structures/linked-list/index.js +0 -19
  168. package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  169. package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
  170. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  171. package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
  172. package/dist/data-structures/matrix/index.js +0 -18
  173. package/dist/data-structures/matrix/matrix.d.ts +0 -168
  174. package/dist/data-structures/matrix/matrix.js +0 -448
  175. package/dist/data-structures/matrix/navigator.d.ts +0 -55
  176. package/dist/data-structures/matrix/navigator.js +0 -111
  177. package/dist/data-structures/priority-queue/index.js +0 -19
  178. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  179. package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
  180. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  181. package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
  182. package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
  183. package/dist/data-structures/priority-queue/priority-queue.js +0 -20
  184. package/dist/data-structures/queue/deque.d.ts +0 -431
  185. package/dist/data-structures/queue/deque.js +0 -879
  186. package/dist/data-structures/queue/index.js +0 -18
  187. package/dist/data-structures/queue/queue.d.ts +0 -308
  188. package/dist/data-structures/queue/queue.js +0 -473
  189. package/dist/data-structures/stack/index.js +0 -17
  190. package/dist/data-structures/stack/stack.d.ts +0 -306
  191. package/dist/data-structures/stack/stack.js +0 -401
  192. package/dist/data-structures/tree/index.js +0 -17
  193. package/dist/data-structures/tree/tree.d.ts +0 -62
  194. package/dist/data-structures/tree/tree.js +0 -107
  195. package/dist/data-structures/trie/index.js +0 -17
  196. package/dist/data-structures/trie/trie.d.ts +0 -350
  197. package/dist/data-structures/trie/trie.js +0 -610
  198. package/dist/index.d.ts +0 -18
  199. package/dist/index.js +0 -34
  200. package/dist/interfaces/binary-tree.js +0 -2
  201. package/dist/interfaces/doubly-linked-list.js +0 -2
  202. package/dist/interfaces/graph.js +0 -2
  203. package/dist/interfaces/heap.js +0 -2
  204. package/dist/interfaces/index.js +0 -24
  205. package/dist/interfaces/navigator.js +0 -2
  206. package/dist/interfaces/priority-queue.js +0 -2
  207. package/dist/interfaces/segment-tree.js +0 -2
  208. package/dist/interfaces/singly-linked-list.js +0 -2
  209. package/dist/types/common.js +0 -2
  210. package/dist/types/data-structures/base/base.js +0 -2
  211. package/dist/types/data-structures/base/index.js +0 -17
  212. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  213. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  214. package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
  215. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  216. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
  217. package/dist/types/data-structures/binary-tree/bst.js +0 -2
  218. package/dist/types/data-structures/binary-tree/index.js +0 -25
  219. package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
  220. package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
  221. package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
  222. package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  223. package/dist/types/data-structures/graph/abstract-graph.js +0 -2
  224. package/dist/types/data-structures/graph/directed-graph.js +0 -2
  225. package/dist/types/data-structures/graph/index.js +0 -19
  226. package/dist/types/data-structures/graph/map-graph.js +0 -2
  227. package/dist/types/data-structures/graph/undirected-graph.js +0 -2
  228. package/dist/types/data-structures/hash/hash-map.js +0 -2
  229. package/dist/types/data-structures/hash/index.js +0 -17
  230. package/dist/types/data-structures/heap/heap.js +0 -2
  231. package/dist/types/data-structures/heap/index.js +0 -17
  232. package/dist/types/data-structures/heap/max-heap.js +0 -2
  233. package/dist/types/data-structures/heap/min-heap.js +0 -2
  234. package/dist/types/data-structures/index.js +0 -28
  235. package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  236. package/dist/types/data-structures/linked-list/index.js +0 -19
  237. package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
  238. package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
  239. package/dist/types/data-structures/matrix/index.js +0 -18
  240. package/dist/types/data-structures/matrix/matrix.js +0 -2
  241. package/dist/types/data-structures/matrix/navigator.js +0 -2
  242. package/dist/types/data-structures/priority-queue/index.js +0 -19
  243. package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  244. package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  245. package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
  246. package/dist/types/data-structures/queue/deque.js +0 -2
  247. package/dist/types/data-structures/queue/index.js +0 -18
  248. package/dist/types/data-structures/queue/queue.js +0 -2
  249. package/dist/types/data-structures/stack/index.js +0 -17
  250. package/dist/types/data-structures/stack/stack.js +0 -2
  251. package/dist/types/data-structures/tree/index.js +0 -17
  252. package/dist/types/data-structures/tree/tree.js +0 -2
  253. package/dist/types/data-structures/trie/index.js +0 -17
  254. package/dist/types/data-structures/trie/trie.js +0 -2
  255. package/dist/types/index.js +0 -19
  256. package/dist/types/utils/index.js +0 -18
  257. package/dist/types/utils/utils.js +0 -2
  258. package/dist/types/utils/validate-type.js +0 -2
  259. package/dist/utils/index.d.ts +0 -2
  260. package/dist/utils/index.js +0 -18
  261. package/dist/utils/number.js +0 -24
  262. package/dist/utils/utils.d.ts +0 -209
  263. package/dist/utils/utils.js +0 -353
  264. package/dist/{common → types/common}/index.d.ts +0 -0
  265. package/dist/{constants → types/constants}/index.d.ts +0 -0
  266. package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
  267. package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
  268. package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
  269. package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
  270. package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
  271. package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
  272. package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
  273. package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
  274. package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
  275. package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
  276. package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
  277. package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
  278. package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
  279. package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
  280. package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
  281. package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
  282. /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
  283. /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
  284. /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
  285. /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
  286. /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
  287. /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
  288. /package/dist/{utils → types/utils}/number.d.ts +0 -0
@@ -1 +1,2 @@
1
- export * from './base';
1
+ export * from './iterable-entry-base';
2
+ export * from './iterable-element-base';
@@ -1,2 +1,236 @@
1
- import { AVLTreeOptions } from './avl-tree';
2
- export type AVLTreeCounterOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
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
+ */
8
+ import type { AVLTreeCounterOptions, BinaryTreeDeleteResult, BinaryTreeOptions, BSTNOptKeyOrNode, EntryCallback, FamilyPosition, IterationType, RBTNColor } from '../../types';
9
+ import { IBinaryTree } from '../../interfaces';
10
+ import { AVLTree } from './avl-tree';
11
+ /**
12
+ * AVL node with an extra 'count' field; keeps parent/child links.
13
+ * @remarks Time O(1), Space O(1)
14
+ * @template K
15
+ * @template V
16
+ */
17
+ export declare class AVLTreeCounterNode<K = any, V = any> {
18
+ key: K;
19
+ value?: V;
20
+ parent?: AVLTreeCounterNode<K, V>;
21
+ /**
22
+ * Create an AVL counter node.
23
+ * @remarks Time O(1), Space O(1)
24
+ * @param key - Key of the node.
25
+ * @param [value] - Associated value (ignored in map mode).
26
+ * @param [count] - Initial count for this node (default 1).
27
+ * @returns New AVLTreeCounterNode instance.
28
+ */
29
+ constructor(key: K, value?: V, count?: number);
30
+ _left?: AVLTreeCounterNode<K, V> | null | undefined;
31
+ /**
32
+ * Get the left child pointer.
33
+ * @remarks Time O(1), Space O(1)
34
+ * @returns Left child node, or null/undefined.
35
+ */
36
+ get left(): AVLTreeCounterNode<K, V> | null | undefined;
37
+ /**
38
+ * Set the left child and update its parent pointer.
39
+ * @remarks Time O(1), Space O(1)
40
+ * @param v - New left child node, or null/undefined.
41
+ * @returns void
42
+ */
43
+ set left(v: AVLTreeCounterNode<K, V> | null | undefined);
44
+ _right?: AVLTreeCounterNode<K, V> | null | undefined;
45
+ /**
46
+ * Get the right child pointer.
47
+ * @remarks Time O(1), Space O(1)
48
+ * @returns Right child node, or null/undefined.
49
+ */
50
+ get right(): AVLTreeCounterNode<K, V> | null | undefined;
51
+ /**
52
+ * Set the right child and update its parent pointer.
53
+ * @remarks Time O(1), Space O(1)
54
+ * @param v - New right child node, or null/undefined.
55
+ * @returns void
56
+ */
57
+ set right(v: AVLTreeCounterNode<K, V> | null | undefined);
58
+ _height: number;
59
+ /**
60
+ * Gets the height of the node (used in self-balancing trees).
61
+ * @remarks Time O(1), Space O(1)
62
+ *
63
+ * @returns The height.
64
+ */
65
+ get height(): number;
66
+ /**
67
+ * Sets the height of the node.
68
+ * @remarks Time O(1), Space O(1)
69
+ *
70
+ * @param value - The new height.
71
+ */
72
+ set height(value: number);
73
+ _color: RBTNColor;
74
+ /**
75
+ * Gets the color of the node (used in Red-Black trees).
76
+ * @remarks Time O(1), Space O(1)
77
+ *
78
+ * @returns The node's color.
79
+ */
80
+ get color(): RBTNColor;
81
+ /**
82
+ * Sets the color of the node.
83
+ * @remarks Time O(1), Space O(1)
84
+ *
85
+ * @param value - The new color.
86
+ */
87
+ set color(value: RBTNColor);
88
+ _count: number;
89
+ /**
90
+ * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
91
+ * @remarks Time O(1), Space O(1)
92
+ *
93
+ * @returns The subtree node count.
94
+ */
95
+ get count(): number;
96
+ /**
97
+ * Sets the count of nodes in the subtree.
98
+ * @remarks Time O(1), Space O(1)
99
+ *
100
+ * @param value - The new count.
101
+ */
102
+ set count(value: number);
103
+ /**
104
+ * Gets the position of the node relative to its parent.
105
+ * @remarks Time O(1), Space O(1)
106
+ *
107
+ * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
108
+ */
109
+ get familyPosition(): FamilyPosition;
110
+ }
111
+ /**
112
+ * AVL tree that tracks an aggregate 'count' across nodes; supports balanced insert/delete and map-like mode.
113
+ * @remarks Time O(1), Space O(1)
114
+ * @template K
115
+ * @template V
116
+ * @template R
117
+ */
118
+ export declare class AVLTreeCounter<K = any, V = any, R = any> extends AVLTree<K, V, R> implements IBinaryTree<K, V, R> {
119
+ /**
120
+ * Create a AVLTreeCounter instance
121
+ * @remarks Time O(n), Space O(n)
122
+ * @param keysNodesEntriesOrRaws
123
+ * @param options
124
+ * @returns New AVLTreeCounterNode instance.
125
+ */
126
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: AVLTreeCounterOptions<K, V, R>);
127
+ protected _count: number;
128
+ get count(): number;
129
+ /**
130
+ * Compute the total count by traversing the tree (sums node.count).
131
+ * @remarks Time O(N), Space O(H)
132
+ * @returns Total count recomputed from nodes.
133
+ */
134
+ getComputedCount(): number;
135
+ createNode(key: K, value?: V, count?: number): AVLTreeCounterNode<K, V>;
136
+ /**
137
+ * Type guard: check whether the input is an AVLTreeCounterNode.
138
+ * @remarks Time O(1), Space O(1)
139
+ * @returns True if the value is an AVLTreeCounterNode.
140
+ */
141
+ isNode(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is AVLTreeCounterNode<K, V>;
142
+ /**
143
+ * Insert or increment a node and update aggregate count.
144
+ * @remarks Time O(log N), Space O(1)
145
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
146
+ * @param [value] - Value when a bare key is provided (ignored in map mode).
147
+ * @param [count] - How much to increase the node's count (default 1).
148
+ * @returns True if inserted/updated; false if ignored.
149
+ */
150
+ add(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
151
+ /**
152
+ * Delete a node (or decrement its count) and rebalance if needed.
153
+ * @remarks Time O(log N), Space O(1)
154
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
155
+ * @param [ignoreCount] - If true, remove the node regardless of its count.
156
+ * @returns Array of deletion results including deleted node and a rebalance hint when present.
157
+ */
158
+ delete(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, ignoreCount?: boolean): BinaryTreeDeleteResult<AVLTreeCounterNode<K, V>>[];
159
+ /**
160
+ * Remove all nodes and reset aggregate counters.
161
+ * @remarks Time O(N), Space O(1)
162
+ * @returns void
163
+ */
164
+ clear(): void;
165
+ /**
166
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
167
+ * @remarks Time O(N), Space O(N)
168
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
169
+ * @returns True if rebalancing succeeded (tree not empty).
170
+ */
171
+ perfectlyBalance(iterationType?: IterationType): boolean;
172
+ /**
173
+ * Deep copy this tree, preserving map mode and aggregate counts.
174
+ * @remarks Time O(N), Space O(N)
175
+ * @returns A deep copy of this tree.
176
+ */
177
+ clone(): this;
178
+ /**
179
+ * Create a new AVLTreeCounter by mapping each [key, value] entry.
180
+ * @remarks Time O(N log N), Space O(N)
181
+ * @template MK
182
+ * @template MV
183
+ * @template MR
184
+ * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
185
+ * @param [options] - Options for the output tree.
186
+ * @param [thisArg] - Value for `this` inside the callback.
187
+ * @returns A new AVLTreeCounter with mapped entries.
188
+ */
189
+ map<MK = K, MV = V, MR = any>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: Partial<BinaryTreeOptions<MK, MV, MR>>, thisArg?: unknown): AVLTreeCounter<MK, MV, MR>;
190
+ /**
191
+ * (Protected) Create an empty instance of the same concrete class.
192
+ * @remarks Time O(1), Space O(1)
193
+ * @template TK
194
+ * @template TV
195
+ * @template TR
196
+ * @param [options] - Optional constructor options for the like-kind instance.
197
+ * @returns An empty like-kind instance.
198
+ */
199
+ protected _createInstance<TK = K, TV = V, TR = R>(options?: Partial<AVLTreeCounterOptions<TK, TV, TR>>): this;
200
+ /**
201
+ * (Protected) Create a like-kind instance and seed it from an iterable.
202
+ * @remarks Time O(N log N), Space O(N)
203
+ * @template TK
204
+ * @template TV
205
+ * @template TR
206
+ * @param iter - Iterable used to seed the new tree.
207
+ * @param [options] - Options merged with the current snapshot.
208
+ * @returns A like-kind AVLTreeCounter built from the iterable.
209
+ */
210
+ protected _createLike<TK = K, TV = V, TR = R>(iter?: Iterable<TK | AVLTreeCounterNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<AVLTreeCounterOptions<TK, TV, TR>>): AVLTreeCounter<TK, TV, TR>;
211
+ /**
212
+ * (Protected) Normalize input into a node plus its effective value and count.
213
+ * @remarks Time O(1), Space O(1)
214
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry.
215
+ * @param [value] - Value used when a bare key is provided.
216
+ * @param [count] - Count increment to apply (default 1).
217
+ * @returns Tuple [node, value] where node may be undefined.
218
+ */
219
+ protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): [AVLTreeCounterNode<K, V> | undefined, V | undefined];
220
+ /**
221
+ * (Protected) Swap keys/values/counters between the source and destination nodes.
222
+ * @remarks Time O(1), Space O(1)
223
+ * @param srcNode - Source node (or key) whose properties will be moved.
224
+ * @param destNode - Destination node (or key) to receive properties.
225
+ * @returns Destination node after swap, or undefined.
226
+ */
227
+ protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, AVLTreeCounterNode<K, V>>, destNode: BSTNOptKeyOrNode<K, AVLTreeCounterNode<K, V>>): AVLTreeCounterNode<K, V> | undefined;
228
+ /**
229
+ * (Protected) Replace one node by another and adjust counters accordingly.
230
+ * @remarks Time O(1), Space O(1)
231
+ * @param oldNode - Node being replaced.
232
+ * @param newNode - Replacement node.
233
+ * @returns The new node after replacement.
234
+ */
235
+ protected _replaceNode(oldNode: AVLTreeCounterNode<K, V>, newNode: AVLTreeCounterNode<K, V>): AVLTreeCounterNode<K, V>;
236
+ }
@@ -1,2 +1,197 @@
1
- import type { AVLTreeOptions } from './avl-tree';
2
- export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
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
+ */
8
+ import type { AVLTreeMultiMapOptions, AVLTreeOptions, ElemOf, EntryCallback, FamilyPosition, IterationType, RBTNColor } from '../../types';
9
+ import { AVLTree, AVLTreeNode } from './avl-tree';
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
+ */
17
+ export declare class AVLTreeMultiMapNode<K = any, V = any> {
18
+ key: K;
19
+ value?: V[];
20
+ parent?: AVLTreeMultiMapNode<K, V>;
21
+ /**
22
+ * Create an AVLTreeMultiMap node with a value bucket.
23
+ * @remarks Time O(1), Space O(1)
24
+ * @param key - Key of the node.
25
+ * @param value - Initial array of values.
26
+ * @returns New AVLTreeMultiMapNode instance.
27
+ */
28
+ constructor(key: K, value?: V[]);
29
+ _left?: AVLTreeMultiMapNode<K, V> | null | undefined;
30
+ /**
31
+ * Get the left child pointer.
32
+ * @remarks Time O(1), Space O(1)
33
+ * @returns Left child node, or null/undefined.
34
+ */
35
+ get left(): AVLTreeMultiMapNode<K, V> | null | undefined;
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
+ */
42
+ set left(v: AVLTreeMultiMapNode<K, V> | null | undefined);
43
+ _right?: AVLTreeMultiMapNode<K, V> | null | undefined;
44
+ /**
45
+ * Get the right child pointer.
46
+ * @remarks Time O(1), Space O(1)
47
+ * @returns Right child node, or null/undefined.
48
+ */
49
+ get right(): AVLTreeMultiMapNode<K, V> | null | undefined;
50
+ /**
51
+ * Set the right child and update its parent pointer.
52
+ * @remarks Time O(1), Space O(1)
53
+ * @param v - New right child node, or null/undefined.
54
+ * @returns void
55
+ */
56
+ set right(v: AVLTreeMultiMapNode<K, V> | null | undefined);
57
+ _height: number;
58
+ /**
59
+ * Gets the height of the node (used in self-balancing trees).
60
+ * @remarks Time O(1), Space O(1)
61
+ *
62
+ * @returns The height.
63
+ */
64
+ get height(): number;
65
+ /**
66
+ * Sets the height of the node.
67
+ * @remarks Time O(1), Space O(1)
68
+ *
69
+ * @param value - The new height.
70
+ */
71
+ set height(value: number);
72
+ _color: RBTNColor;
73
+ /**
74
+ * Gets the color of the node (used in Red-Black trees).
75
+ * @remarks Time O(1), Space O(1)
76
+ *
77
+ * @returns The node's color.
78
+ */
79
+ get color(): RBTNColor;
80
+ /**
81
+ * Sets the color of the node.
82
+ * @remarks Time O(1), Space O(1)
83
+ *
84
+ * @param value - The new color.
85
+ */
86
+ set color(value: RBTNColor);
87
+ _count: number;
88
+ /**
89
+ * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
90
+ * @remarks Time O(1), Space O(1)
91
+ *
92
+ * @returns The subtree node count.
93
+ */
94
+ get count(): number;
95
+ /**
96
+ * Sets the count of nodes in the subtree.
97
+ * @remarks Time O(1), Space O(1)
98
+ *
99
+ * @param value - The new count.
100
+ */
101
+ set count(value: number);
102
+ /**
103
+ * Gets the position of the node relative to its parent.
104
+ * @remarks Time O(1), Space O(1)
105
+ *
106
+ * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
107
+ */
108
+ get familyPosition(): FamilyPosition;
109
+ }
110
+ /**
111
+ * AVL-tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
112
+ * @remarks Time O(1), Space O(1)
113
+ * @template K
114
+ * @template V
115
+ * @template R
116
+ */
117
+ export declare class AVLTreeMultiMap<K = any, V = any, R = any> extends AVLTree<K, V[], R> implements IBinaryTree<K, V[], R> {
118
+ /**
119
+ * Create an AVLTreeMultiMap and optionally bulk-insert items.
120
+ * @remarks Time O(N log N), Space O(N)
121
+ * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
122
+ * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
123
+ * @returns New AVLTreeMultiMap instance.
124
+ */
125
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
126
+ createNode(key: K, value?: V[]): AVLTreeMultiMapNode<K, V>;
127
+ /**
128
+ * Checks if the given item is a `AVLTreeMultiMapNode` instance.
129
+ * @remarks Time O(1), Space O(1)
130
+ *
131
+ * @param keyNodeOrEntry - The item to check.
132
+ * @returns True if it's a AVLTreeMultiMapNode, false otherwise.
133
+ */
134
+ isNode(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): keyNodeOrEntry is AVLTreeMultiMapNode<K, V>;
135
+ add(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
136
+ add(key: K, value: V): boolean;
137
+ /**
138
+ * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
139
+ * @remarks Time O(log N), Space O(1)
140
+ * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
141
+ * @param value - Value to remove from the bucket.
142
+ * @returns True if the value was removed; false if not found.
143
+ */
144
+ deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined, value: V): boolean;
145
+ /**
146
+ * Rebuild the tree into a perfectly balanced form using in-order nodes.
147
+ * @remarks Time O(N), Space O(N)
148
+ * @param [iterationType] - Traversal style to use when constructing the balanced tree.
149
+ * @returns True if rebalancing succeeded (tree not empty).
150
+ */
151
+ perfectlyBalance(iterationType?: IterationType): boolean;
152
+ /**
153
+ * Create a new tree by mapping each [key, values] bucket.
154
+ * @remarks Time O(N log N), Space O(N)
155
+ * @template MK
156
+ * @template MVArr
157
+ * @template MR
158
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
159
+ * @param [options] - Options for the output tree.
160
+ * @param [thisArg] - Value for `this` inside the callback.
161
+ * @returns A new AVLTreeMultiMap when mapping to array values; see overloads.
162
+ */
163
+ map<MK = K, MVArr extends unknown[] = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<AVLTreeOptions<MK, MVArr, MR>>, thisArg?: unknown): AVLTreeMultiMap<MK, ElemOf<MVArr>, MR>;
164
+ /**
165
+ * Create a new tree by mapping each [key, values] bucket.
166
+ * @remarks Time O(N log N), Space O(N)
167
+ * @template MK
168
+ * @template MV
169
+ * @template MR
170
+ * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
171
+ * @param [options] - Options for the output tree.
172
+ * @param [thisArg] - Value for `this` inside the callback.
173
+ * @returns A new AVLTree when mapping to non-array values; see overloads.
174
+ */
175
+ map<MK = K, MV = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<AVLTreeOptions<MK, MV, MR>>, thisArg?: unknown): AVLTree<MK, MV, MR>;
176
+ /**
177
+ * (Protected) Create an empty instance of the same concrete class.
178
+ * @remarks Time O(1), Space O(1)
179
+ * @template TK
180
+ * @template TV
181
+ * @template TR
182
+ * @param [options] - Optional constructor options for the like-kind instance.
183
+ * @returns An empty like-kind instance.
184
+ */
185
+ protected _createInstance<TK = K, TV = V, TR = R>(options?: Partial<AVLTreeOptions<TK, TV, TR>>): this;
186
+ /**
187
+ * (Protected) Create a like-kind instance and seed it from an iterable.
188
+ * @remarks Time O(N log N), Space O(N)
189
+ * @template TK
190
+ * @template TV
191
+ * @template TR
192
+ * @param iter - Iterable used to seed the new tree.
193
+ * @param [options] - Options merged with the current snapshot.
194
+ * @returns A like-kind AVLTree built from the iterable.
195
+ */
196
+ protected _createLike<TK = K, TV = V, TR = 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>;
197
+ }