data-structure-typed 2.5.1 → 2.5.3

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 (184) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/MIGRATION.md +169 -0
  3. package/README.md +135 -23
  4. package/README_CN.md +551 -143
  5. package/SPECIFICATION.md +20 -14
  6. package/SPECIFICATION.zh-CN.md +20 -14
  7. package/dist/cjs/binary-tree.cjs +6460 -1591
  8. package/dist/cjs/graph.cjs +440 -20
  9. package/dist/cjs/hash.cjs +125 -22
  10. package/dist/cjs/heap.cjs +196 -47
  11. package/dist/cjs/index.cjs +8486 -2429
  12. package/dist/cjs/linked-list.cjs +456 -31
  13. package/dist/cjs/matrix.cjs +79 -9
  14. package/dist/cjs/priority-queue.cjs +193 -44
  15. package/dist/cjs/queue.cjs +391 -2
  16. package/dist/cjs/stack.cjs +92 -6
  17. package/dist/cjs/trie.cjs +122 -28
  18. package/dist/cjs-legacy/binary-tree.cjs +6484 -1612
  19. package/dist/cjs-legacy/graph.cjs +440 -20
  20. package/dist/cjs-legacy/hash.cjs +125 -22
  21. package/dist/cjs-legacy/heap.cjs +196 -47
  22. package/dist/cjs-legacy/index.cjs +8654 -2594
  23. package/dist/cjs-legacy/linked-list.cjs +456 -31
  24. package/dist/cjs-legacy/matrix.cjs +79 -9
  25. package/dist/cjs-legacy/priority-queue.cjs +193 -44
  26. package/dist/cjs-legacy/queue.cjs +391 -2
  27. package/dist/cjs-legacy/stack.cjs +92 -6
  28. package/dist/cjs-legacy/trie.cjs +122 -28
  29. package/dist/esm/binary-tree.mjs +6460 -1591
  30. package/dist/esm/graph.mjs +440 -20
  31. package/dist/esm/hash.mjs +125 -22
  32. package/dist/esm/heap.mjs +196 -47
  33. package/dist/esm/index.mjs +8486 -2430
  34. package/dist/esm/linked-list.mjs +456 -31
  35. package/dist/esm/matrix.mjs +79 -9
  36. package/dist/esm/priority-queue.mjs +193 -44
  37. package/dist/esm/queue.mjs +391 -2
  38. package/dist/esm/stack.mjs +92 -6
  39. package/dist/esm/trie.mjs +122 -28
  40. package/dist/esm-legacy/binary-tree.mjs +6484 -1612
  41. package/dist/esm-legacy/graph.mjs +440 -20
  42. package/dist/esm-legacy/hash.mjs +125 -22
  43. package/dist/esm-legacy/heap.mjs +196 -47
  44. package/dist/esm-legacy/index.mjs +8654 -2595
  45. package/dist/esm-legacy/linked-list.mjs +456 -31
  46. package/dist/esm-legacy/matrix.mjs +79 -9
  47. package/dist/esm-legacy/priority-queue.mjs +193 -44
  48. package/dist/esm-legacy/queue.mjs +391 -2
  49. package/dist/esm-legacy/stack.mjs +92 -6
  50. package/dist/esm-legacy/trie.mjs +122 -28
  51. package/dist/types/common/error.d.ts +9 -0
  52. package/dist/types/common/index.d.ts +1 -1
  53. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -2
  54. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +112 -0
  55. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +214 -13
  56. package/dist/types/data-structures/binary-tree/bst.d.ts +294 -3
  57. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +155 -8
  58. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +48 -0
  59. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1370 -323
  60. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1329 -316
  61. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +1116 -295
  62. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1330 -326
  63. package/dist/types/data-structures/graph/directed-graph.d.ts +80 -0
  64. package/dist/types/data-structures/graph/undirected-graph.d.ts +72 -0
  65. package/dist/types/data-structures/hash/hash-map.d.ts +95 -6
  66. package/dist/types/data-structures/heap/heap.d.ts +154 -12
  67. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +143 -0
  68. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -1
  69. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +144 -0
  70. package/dist/types/data-structures/matrix/matrix.d.ts +64 -0
  71. package/dist/types/data-structures/queue/deque.d.ts +142 -0
  72. package/dist/types/data-structures/queue/queue.d.ts +109 -0
  73. package/dist/types/data-structures/stack/stack.d.ts +82 -2
  74. package/dist/types/data-structures/trie/trie.d.ts +96 -0
  75. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  76. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  77. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  78. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  79. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  80. package/dist/umd/data-structure-typed.js +8623 -2564
  81. package/dist/umd/data-structure-typed.min.js +5 -5
  82. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +696 -194
  83. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  84. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
  85. package/docs-site-docusaurus/docs/api/classes/BST.md +639 -189
  86. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  87. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  88. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +148 -160
  89. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  90. package/docs-site-docusaurus/docs/api/classes/Deque.md +105 -91
  91. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
  92. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +104 -74
  93. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  94. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  95. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  96. package/docs-site-docusaurus/docs/api/classes/HashMap.md +51 -51
  97. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  98. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  99. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
  100. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
  101. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
  102. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +55 -55
  103. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  104. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
  105. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
  106. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  107. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  108. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  109. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  110. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  111. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  112. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  113. package/docs-site-docusaurus/docs/api/classes/Queue.md +112 -60
  114. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +708 -206
  115. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  116. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +79 -79
  117. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  118. package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
  119. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  120. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +236 -33
  121. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
  122. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +232 -32
  123. package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
  124. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  125. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
  126. package/docs-site-docusaurus/docs/guide/architecture.md +75 -5
  127. package/docs-site-docusaurus/docs/guide/concepts.md +53 -3
  128. package/docs-site-docusaurus/docs/guide/faq.md +233 -0
  129. package/docs-site-docusaurus/docs/guide/guides.md +43 -58
  130. package/docs-site-docusaurus/docs/guide/installation.md +2 -0
  131. package/docs-site-docusaurus/docs/guide/integrations.md +75 -176
  132. package/docs-site-docusaurus/docs/guide/overview.md +132 -11
  133. package/docs-site-docusaurus/docs/guide/performance.md +2 -0
  134. package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
  135. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  136. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  137. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  138. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  139. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  140. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  141. package/docs-site-docusaurus/docusaurus.config.ts +1 -1
  142. package/docs-site-docusaurus/src/pages/index.tsx +55 -2
  143. package/docs-site-docusaurus/static/llms.txt +37 -0
  144. package/docs-site-docusaurus/typedoc.json +1 -0
  145. package/llms.txt +37 -0
  146. package/package.json +65 -56
  147. package/src/common/error.ts +19 -1
  148. package/src/common/index.ts +1 -1
  149. package/src/data-structures/base/iterable-element-base.ts +3 -2
  150. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  151. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  152. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  153. package/src/data-structures/binary-tree/bst.ts +542 -13
  154. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  155. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  156. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  157. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  158. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  159. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  160. package/src/data-structures/graph/abstract-graph.ts +2 -2
  161. package/src/data-structures/graph/directed-graph.ts +71 -1
  162. package/src/data-structures/graph/undirected-graph.ts +64 -1
  163. package/src/data-structures/hash/hash-map.ts +102 -16
  164. package/src/data-structures/heap/heap.ts +153 -23
  165. package/src/data-structures/heap/max-heap.ts +2 -2
  166. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  167. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  168. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  169. package/src/data-structures/matrix/matrix.ts +65 -9
  170. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  171. package/src/data-structures/queue/deque.ts +130 -0
  172. package/src/data-structures/queue/queue.ts +109 -0
  173. package/src/data-structures/stack/stack.ts +75 -5
  174. package/src/data-structures/trie/trie.ts +86 -2
  175. package/src/interfaces/binary-tree.ts +1 -9
  176. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  177. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  178. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  179. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  180. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  181. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  182. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  183. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  184. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -189,14 +189,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
189
189
 
190
190
 
191
191
 
192
- * @example
193
- * // Check if empty
194
- * console.log(new TreeMultiMap().isEmpty()); // true;
195
- */
196
- isEmpty(): boolean;
197
- /**
198
- * Removes all entries from the map.
199
- * @remarks Time O(1), Space O(1)
200
192
 
201
193
 
202
194
 
@@ -237,6 +229,14 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
237
229
 
238
230
 
239
231
 
232
+ * @example
233
+ * // Check if empty
234
+ * console.log(new TreeMultiMap().isEmpty()); // true;
235
+ */
236
+ isEmpty(): boolean;
237
+ /**
238
+ * Removes all entries from the map.
239
+ * @remarks Time O(1), Space O(1)
240
240
 
241
241
 
242
242
 
@@ -335,17 +335,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
335
335
 
336
336
 
337
337
 
338
- * @example
339
- * // Remove all entries
340
- * const mm = new TreeMultiMap<number, string>();
341
- * mm.add(1, 'a');
342
- * mm.clear();
343
- * console.log(mm.isEmpty()); // true;
344
- */
345
- clear(): void;
346
- /**
347
- * Bucket length for a key (missing => 0).
348
- * @remarks Time O(log n), Space O(1)
349
338
 
350
339
 
351
340
 
@@ -368,17 +357,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
368
357
 
369
358
 
370
359
 
371
- * @example
372
- * // Count values for key
373
- * const mm = new TreeMultiMap<number, string>();
374
- * mm.add(1, 'a');
375
- * mm.add(1, 'b');
376
- * console.log(mm.count(1)); // 2;
377
- */
378
- count(key: K): number;
379
- /**
380
- * Total number of values across all buckets (Σ bucket.length).
381
- * @remarks Time O(n), Space O(1)
382
360
 
383
361
 
384
362
 
@@ -401,18 +379,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
401
379
 
402
380
 
403
381
 
404
- * @example
405
- * // Total number of values
406
- * const mm = new TreeMultiMap<number, string>();
407
- * mm.add(1, 'a');
408
- * mm.add(1, 'b');
409
- * mm.add(2, 'c');
410
- * console.log(mm.totalSize); // 3;
411
- */
412
- get totalSize(): number;
413
- /**
414
- * Whether the map contains the given key.
415
- * @remarks Time O(log n), Space O(1)
416
382
 
417
383
 
418
384
 
@@ -449,6 +415,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
449
415
 
450
416
 
451
417
 
418
+ * @example
419
+ * // Remove all entries
420
+ * const mm = new TreeMultiMap<number, string>();
421
+ * mm.add(1, 'a');
422
+ * mm.clear();
423
+ * console.log(mm.isEmpty()); // true;
424
+ */
425
+ clear(): void;
426
+ /**
427
+ * Bucket length for a key (missing => 0).
428
+ * @remarks Time O(log n), Space O(1)
452
429
 
453
430
 
454
431
 
@@ -479,6 +456,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
479
456
 
480
457
 
481
458
 
459
+ * @example
460
+ * // Count values for key
461
+ * const mm = new TreeMultiMap<number, string>();
462
+ * mm.add(1, 'a');
463
+ * mm.add(1, 'b');
464
+ * console.log(mm.count(1)); // 2;
465
+ */
466
+ count(key: K): number;
467
+ /**
468
+ * Total number of values across all buckets (Σ bucket.length).
469
+ * @remarks Time O(n), Space O(1)
482
470
 
483
471
 
484
472
 
@@ -509,6 +497,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
509
497
 
510
498
 
511
499
 
500
+ * @example
501
+ * // Total number of values
502
+ * const mm = new TreeMultiMap<number, string>();
503
+ * mm.add(1, 'a');
504
+ * mm.add(1, 'b');
505
+ * mm.add(2, 'c');
506
+ * console.log(mm.totalSize); // 3;
507
+ */
508
+ get totalSize(): number;
509
+ /**
510
+ * Whether the map contains the given key.
511
+ * @remarks Time O(log n), Space O(1)
512
512
 
513
513
 
514
514
 
@@ -585,17 +585,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
585
585
 
586
586
 
587
587
 
588
- * @example
589
- * // Check key existence
590
- * const mm = new TreeMultiMap<number, string>();
591
- * mm.add(1, 'a');
592
- * console.log(mm.has(1)); // true;
593
- * console.log(mm.has(2)); // false;
594
- */
595
- has(key: K): boolean;
596
- /**
597
- * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
598
- * @remarks Time O(log n), Space O(1)
599
588
 
600
589
 
601
590
 
@@ -740,6 +729,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
740
729
 
741
730
 
742
731
 
732
+ * @example
733
+ * // Check key existence
734
+ * const mm = new TreeMultiMap<number, string>();
735
+ * mm.add(1, 'a');
736
+ * console.log(mm.has(1)); // true;
737
+ * console.log(mm.has(2)); // false;
738
+ */
739
+ has(key: K): boolean;
740
+ /**
741
+ * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
742
+ * @remarks Time O(log n), Space O(1)
743
743
 
744
744
 
745
745
 
@@ -768,17 +768,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
768
768
 
769
769
 
770
770
 
771
- * @example
772
- * // Get values for key
773
- * const mm = new TreeMultiMap<number, string>();
774
- * mm.add(1, 'a');
775
- * mm.add(1, 'b');
776
- * console.log(mm.get(1)); // ['a', 'b'];
777
- */
778
- get(key: K): V[] | undefined;
779
- /**
780
- * Append a single value.
781
- * @remarks Time O(log n), Space O(1)
782
771
 
783
772
 
784
773
 
@@ -911,18 +900,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
911
900
 
912
901
 
913
902
 
914
- * @example
915
- * // Add key-value pair
916
- * const mm = new TreeMultiMap<number, string>();
917
- * mm.add(1, 'a');
918
- * mm.add(1, 'b');
919
- * mm.add(2, 'c');
920
- * console.log(mm.get(1)); // ['a', 'b'];
921
- */
922
- add(key: K, value: V): boolean;
923
- /**
924
- * Alias for compatibility with existing TreeMultiMap semantics.
925
- * @remarks Time O(log n), Space O(1) for single value; O(log n + m) for bucket append
926
903
 
927
904
 
928
905
 
@@ -983,6 +960,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
983
960
 
984
961
 
985
962
 
963
+ * @example
964
+ * // Get values for key
965
+ * const mm = new TreeMultiMap<number, string>();
966
+ * mm.add(1, 'a');
967
+ * mm.add(1, 'b');
968
+ * console.log(mm.get(1)); // ['a', 'b'];
969
+ */
970
+ get(key: K): V[] | undefined;
971
+ /**
972
+ * Append a single value.
973
+ * @remarks Time O(log n), Space O(1)
986
974
 
987
975
 
988
976
 
@@ -1093,18 +1081,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1093
1081
 
1094
1082
 
1095
1083
 
1096
- * @example
1097
- * // Set values for key
1098
- * const mm = new TreeMultiMap<number, string>();
1099
- * mm.set(1, 'a');
1100
- * mm.set(1, 'b');
1101
- * console.log(mm.get(1)); // ['a', 'b'];
1102
- */
1103
- set(entry: [K | null | undefined, V[] | undefined] | K | null | undefined, value?: V): boolean;
1104
- set(key: K, value: V): boolean;
1105
- /**
1106
- * Deletes a key and its entire bucket.
1107
- * @remarks Time O(log n), Space O(1)
1108
1084
 
1109
1085
 
1110
1086
 
@@ -1167,6 +1143,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1167
1143
 
1168
1144
 
1169
1145
 
1146
+ * @example
1147
+ * // Add key-value pair
1148
+ * const mm = new TreeMultiMap<number, string>();
1149
+ * mm.add(1, 'a');
1150
+ * mm.add(1, 'b');
1151
+ * mm.add(2, 'c');
1152
+ * console.log(mm.get(1)); // ['a', 'b'];
1153
+ */
1154
+ add(key: K, value: V): boolean;
1155
+ /**
1156
+ * Alias for compatibility with existing TreeMultiMap semantics.
1157
+ * @remarks Time O(log n), Space O(1) for single value; O(log n + m) for bucket append
1170
1158
 
1171
1159
 
1172
1160
 
@@ -1277,18 +1265,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1277
1265
 
1278
1266
 
1279
1267
 
1280
- * @example
1281
- * // Remove key
1282
- * const mm = new TreeMultiMap<number, string>();
1283
- * mm.add(1, 'a');
1284
- * mm.add(2, 'b');
1285
- * mm.delete(1);
1286
- * console.log(mm.has(1)); // false;
1287
- */
1288
- delete(key: K): boolean;
1289
- /**
1290
- * Check if a specific value exists in a key's bucket.
1291
- * @remarks Time O(log n + m), Space O(1) where m is bucket size
1292
1268
 
1293
1269
 
1294
1270
 
@@ -1311,17 +1287,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1311
1287
 
1312
1288
 
1313
1289
 
1314
- * @example
1315
- * // Check specific key-value
1316
- * const mm = new TreeMultiMap<number, string>();
1317
- * mm.add(1, 'a');
1318
- * console.log(mm.hasEntry(1, 'a')); // true;
1319
- * console.log(mm.hasEntry(1, 'z')); // false;
1320
- */
1321
- hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
1322
- /**
1323
- * Delete a single occurrence of a value from a key's bucket.
1324
- * @remarks Time O(log n + m), Space O(1) where m is bucket size
1325
1290
 
1326
1291
 
1327
1292
 
@@ -1344,18 +1309,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1344
1309
 
1345
1310
 
1346
1311
 
1347
- * @example
1348
- * // Delete specific value
1349
- * const mm = new TreeMultiMap<number, string>();
1350
- * mm.add(1, 'a');
1351
- * mm.add(1, 'b');
1352
- * mm.deleteValue(1, 'a');
1353
- * console.log(mm.get(1)); // ['b'];
1354
- */
1355
- deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
1356
- /**
1357
- * Delete all occurrences of a value from a key's bucket.
1358
- * @remarks Time O(log n + m), Space O(1) where m is bucket size
1359
1312
 
1360
1313
 
1361
1314
 
@@ -1378,24 +1331,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1378
1331
 
1379
1332
 
1380
1333
 
1381
- * @example
1382
- * // Delete all matching values
1383
- * const mm = new TreeMultiMap<number, string>();
1384
- * mm.add(1, 'a');
1385
- * mm.add(1, 'a');
1386
- * mm.add(1, 'b');
1387
- * const count = mm.deleteValues(1, 'a');
1388
- * console.log(count); // 2;
1389
- */
1390
- deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
1391
- /**
1392
- * Iterates over all entries as [key, bucket] pairs.
1393
- * @remarks Time O(n), Space O(1)
1394
- */
1395
- [Symbol.iterator](): Iterator<[K, V[]]>;
1396
- /**
1397
- * Iterates over all keys.
1398
- * @remarks Time O(n), Space O(1)
1399
1334
 
1400
1335
 
1401
1336
 
@@ -1438,6 +1373,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1438
1373
 
1439
1374
 
1440
1375
 
1376
+ * @example
1377
+ * // Set values for key
1378
+ * const mm = new TreeMultiMap<number, string>();
1379
+ * mm.set(1, 'a');
1380
+ * mm.set(1, 'b');
1381
+ * console.log(mm.get(1)); // ['a', 'b'];
1382
+ */
1383
+ set(entry: [K | null | undefined, V[] | undefined] | K | null | undefined, value?: V): boolean;
1384
+ set(key: K, value: V): boolean;
1385
+ /**
1386
+ * Deletes a key and its entire bucket.
1387
+ * @remarks Time O(log n), Space O(1)
1441
1388
 
1442
1389
 
1443
1390
 
@@ -1534,17 +1481,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1534
1481
 
1535
1482
 
1536
1483
 
1537
- * @example
1538
- * // Iterate keys
1539
- * const mm = new TreeMultiMap<number, string>();
1540
- * mm.add(3, 'c');
1541
- * mm.add(1, 'a');
1542
- * console.log([...mm.keys()]); // [1, 3];
1543
- */
1544
- keys(): IterableIterator<K>;
1545
- /**
1546
- * Iterates over all buckets.
1547
- * @remarks Time O(n), Space O(1)
1548
1484
 
1549
1485
 
1550
1486
 
@@ -1669,6 +1605,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1669
1605
 
1670
1606
 
1671
1607
 
1608
+ * @example
1609
+ * // Remove key
1610
+ * const mm = new TreeMultiMap<number, string>();
1611
+ * mm.add(1, 'a');
1612
+ * mm.add(2, 'b');
1613
+ * mm.delete(1);
1614
+ * console.log(mm.has(1)); // false;
1615
+ */
1616
+ delete(key: K): boolean;
1617
+ /**
1618
+ * Check if a specific value exists in a key's bucket.
1619
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
1672
1620
 
1673
1621
 
1674
1622
 
@@ -1683,16 +1631,32 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1683
1631
 
1684
1632
 
1685
1633
 
1686
- * @example
1687
- * // Iterate value arrays
1688
- * const mm = new TreeMultiMap<number, string>();
1689
- * mm.add(1, 'a');
1690
- * mm.add(1, 'b');
1691
- * console.log([...mm.values()]); // [['a', 'b']];
1634
+
1635
+
1636
+
1637
+
1638
+
1639
+
1640
+
1641
+
1642
+
1643
+
1644
+
1645
+
1646
+
1647
+
1648
+
1649
+
1650
+ * @example
1651
+ * // Check specific key-value
1652
+ * const mm = new TreeMultiMap<number, string>();
1653
+ * mm.add(1, 'a');
1654
+ * console.log(mm.hasEntry(1, 'a')); // true;
1655
+ * console.log(mm.hasEntry(1, 'z')); // false;
1692
1656
  */
1693
- values(): IterableIterator<V[]>;
1657
+ hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
1694
1658
  /**
1695
- * Iterates over all entries for a specific key.
1659
+ * Delete a single occurrence of a value from a key's bucket.
1696
1660
  * @remarks Time O(log n + m), Space O(1) where m is bucket size
1697
1661
 
1698
1662
 
@@ -1707,6 +1671,14 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1707
1671
 
1708
1672
 
1709
1673
 
1674
+
1675
+
1676
+
1677
+
1678
+
1679
+
1680
+
1681
+
1710
1682
 
1711
1683
 
1712
1684
 
@@ -1717,15 +1689,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1717
1689
 
1718
1690
 
1719
1691
  * @example
1720
- * // Get entries for key
1692
+ * // Delete specific value
1721
1693
  * const mm = new TreeMultiMap<number, string>();
1722
1694
  * mm.add(1, 'a');
1723
1695
  * mm.add(1, 'b');
1724
- * console.log([...mm.entriesOf(1)]); // [[1, 'a'], [1, 'b']];
1696
+ * mm.deleteValue(1, 'a');
1697
+ * console.log(mm.get(1)); // ['b'];
1725
1698
  */
1726
- entriesOf(key: K): IterableIterator<[K, V]>;
1699
+ deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
1727
1700
  /**
1728
- * Iterates over all values for a specific key.
1701
+ * Delete all occurrences of a value from a key's bucket.
1729
1702
  * @remarks Time O(log n + m), Space O(1) where m is bucket size
1730
1703
 
1731
1704
 
@@ -1740,6 +1713,14 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1740
1713
 
1741
1714
 
1742
1715
 
1716
+
1717
+
1718
+
1719
+
1720
+
1721
+
1722
+
1723
+
1743
1724
 
1744
1725
 
1745
1726
 
@@ -1750,16 +1731,126 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1750
1731
 
1751
1732
 
1752
1733
  * @example
1753
- * // Get flat values for key
1734
+ * // Delete all matching values
1754
1735
  * const mm = new TreeMultiMap<number, string>();
1755
1736
  * mm.add(1, 'a');
1737
+ * mm.add(1, 'a');
1756
1738
  * mm.add(1, 'b');
1757
- * console.log([...mm.valuesOf(1)]); // ['a', 'b'];
1739
+ * const count = mm.deleteValues(1, 'a');
1740
+ * console.log(count); // 2;
1758
1741
  */
1759
- valuesOf(key: K): IterableIterator<V>;
1742
+ deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
1760
1743
  /**
1761
- * Iterates over all [key, value] pairs (flattened from buckets).
1762
- * @remarks Time O(T), Space O(1) where T is totalSize
1744
+ * Iterates over all entries as [key, bucket] pairs.
1745
+ * @remarks Time O(n), Space O(1)
1746
+ */
1747
+ [Symbol.iterator](): Iterator<[K, V[]]>;
1748
+ /**
1749
+ * Iterates over all keys.
1750
+ * @remarks Time O(n), Space O(1)
1751
+
1752
+
1753
+
1754
+
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+
1795
+
1796
+
1797
+
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+
1812
+
1813
+
1814
+
1815
+
1816
+
1817
+
1818
+
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+
1826
+
1827
+
1828
+
1829
+
1830
+
1831
+
1832
+
1833
+
1834
+
1835
+
1836
+
1837
+
1838
+
1839
+
1840
+
1841
+
1842
+
1843
+
1844
+
1845
+
1846
+
1847
+
1848
+
1849
+
1850
+
1851
+
1852
+
1853
+
1763
1854
 
1764
1855
 
1765
1856
 
@@ -1782,19 +1873,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1782
1873
 
1783
1874
 
1784
1875
 
1785
- * @example
1786
- * // All key-value pairs flattened
1787
- * const mm = new TreeMultiMap<number, string>();
1788
- * mm.add(1, 'a');
1789
- * mm.add(1, 'b');
1790
- * mm.add(2, 'c');
1791
- * console.log([...mm.flatEntries()]); // [[1, 'a'], [1, 'b'], [2, 'c']];
1792
- */
1793
- flatEntries(): IterableIterator<[K, V]>;
1794
- /**
1795
- * Returns the entry with the smallest key.
1796
- * @remarks Time O(log n), Space O(1)
1797
-
1798
1876
 
1799
1877
 
1800
1878
 
@@ -1849,17 +1927,855 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1849
1927
 
1850
1928
 
1851
1929
  * @example
1852
- * // First entry
1930
+ * // Iterate keys
1853
1931
  * const mm = new TreeMultiMap<number, string>();
1854
1932
  * mm.add(3, 'c');
1855
1933
  * mm.add(1, 'a');
1856
- * console.log(mm.first()?.[0]); // 1;
1934
+ * console.log([...mm.keys()]); // [1, 3];
1857
1935
  */
1858
- first(): [K, V[]] | undefined;
1936
+ keys(): IterableIterator<K>;
1859
1937
  /**
1860
- * Returns the entry with the largest key.
1861
- * @remarks Time O(log n), Space O(1)
1862
-
1938
+ * Iterates over all buckets.
1939
+ * @remarks Time O(n), Space O(1)
1940
+
1941
+
1942
+
1943
+
1944
+
1945
+
1946
+
1947
+
1948
+
1949
+
1950
+
1951
+
1952
+
1953
+
1954
+
1955
+
1956
+
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+
1977
+
1978
+
1979
+
1980
+
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1991
+
1992
+
1993
+
1994
+
1995
+
1996
+
1997
+
1998
+
1999
+
2000
+
2001
+
2002
+
2003
+
2004
+
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+
2011
+
2012
+
2013
+
2014
+
2015
+
2016
+
2017
+
2018
+
2019
+
2020
+
2021
+
2022
+
2023
+
2024
+
2025
+
2026
+
2027
+
2028
+
2029
+
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+
2036
+
2037
+
2038
+
2039
+
2040
+
2041
+
2042
+
2043
+
2044
+
2045
+
2046
+
2047
+
2048
+
2049
+
2050
+
2051
+
2052
+
2053
+
2054
+
2055
+
2056
+
2057
+
2058
+
2059
+
2060
+
2061
+
2062
+
2063
+
2064
+
2065
+
2066
+
2067
+
2068
+
2069
+
2070
+
2071
+
2072
+
2073
+
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+
2080
+
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
2096
+
2097
+
2098
+
2099
+
2100
+
2101
+
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+
2108
+
2109
+
2110
+
2111
+
2112
+
2113
+
2114
+
2115
+
2116
+
2117
+
2118
+ * @example
2119
+ * // Iterate value arrays
2120
+ * const mm = new TreeMultiMap<number, string>();
2121
+ * mm.add(1, 'a');
2122
+ * mm.add(1, 'b');
2123
+ * console.log([...mm.values()]); // [['a', 'b']];
2124
+ */
2125
+ values(): IterableIterator<V[]>;
2126
+ /**
2127
+ * Iterates over all entries for a specific key.
2128
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+
2140
+
2141
+
2142
+
2143
+
2144
+
2145
+
2146
+
2147
+
2148
+
2149
+
2150
+
2151
+
2152
+
2153
+
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+ * @example
2160
+ * // Get entries for key
2161
+ * const mm = new TreeMultiMap<number, string>();
2162
+ * mm.add(1, 'a');
2163
+ * mm.add(1, 'b');
2164
+ * console.log([...mm.entriesOf(1)]); // [[1, 'a'], [1, 'b']];
2165
+ */
2166
+ entriesOf(key: K): IterableIterator<[K, V]>;
2167
+ /**
2168
+ * Iterates over all values for a specific key.
2169
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
2170
+
2171
+
2172
+
2173
+
2174
+
2175
+
2176
+
2177
+
2178
+
2179
+
2180
+
2181
+
2182
+
2183
+
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
2195
+
2196
+
2197
+
2198
+
2199
+
2200
+ * @example
2201
+ * // Get flat values for key
2202
+ * const mm = new TreeMultiMap<number, string>();
2203
+ * mm.add(1, 'a');
2204
+ * mm.add(1, 'b');
2205
+ * console.log([...mm.valuesOf(1)]); // ['a', 'b'];
2206
+ */
2207
+ valuesOf(key: K): IterableIterator<V>;
2208
+ /**
2209
+ * Iterates over all [key, value] pairs (flattened from buckets).
2210
+ * @remarks Time O(T), Space O(1) where T is totalSize
2211
+
2212
+
2213
+
2214
+
2215
+
2216
+
2217
+
2218
+
2219
+
2220
+
2221
+
2222
+
2223
+
2224
+
2225
+
2226
+
2227
+
2228
+
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+ * @example
2242
+ * // All key-value pairs flattened
2243
+ * const mm = new TreeMultiMap<number, string>();
2244
+ * mm.add(1, 'a');
2245
+ * mm.add(1, 'b');
2246
+ * mm.add(2, 'c');
2247
+ * console.log([...mm.flatEntries()]); // [[1, 'a'], [1, 'b'], [2, 'c']];
2248
+ */
2249
+ flatEntries(): IterableIterator<[K, V]>;
2250
+ /**
2251
+ * Returns the entry with the smallest key.
2252
+ * @remarks Time O(log n), Space O(1)
2253
+
2254
+
2255
+
2256
+
2257
+
2258
+
2259
+
2260
+
2261
+
2262
+
2263
+
2264
+
2265
+
2266
+
2267
+
2268
+
2269
+
2270
+
2271
+
2272
+
2273
+
2274
+
2275
+
2276
+
2277
+
2278
+
2279
+
2280
+
2281
+
2282
+
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+
2289
+
2290
+
2291
+
2292
+
2293
+
2294
+
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2306
+
2307
+
2308
+
2309
+
2310
+
2311
+
2312
+
2313
+
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+ * @example
2324
+ * // First entry
2325
+ * const mm = new TreeMultiMap<number, string>();
2326
+ * mm.add(3, 'c');
2327
+ * mm.add(1, 'a');
2328
+ * console.log(mm.first()?.[0]); // 1;
2329
+ */
2330
+ first(): [K, V[]] | undefined;
2331
+ /**
2332
+ * Returns the entry with the largest key.
2333
+ * @remarks Time O(log n), Space O(1)
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+
2366
+
2367
+
2368
+
2369
+
2370
+
2371
+
2372
+
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+
2398
+
2399
+
2400
+
2401
+
2402
+
2403
+
2404
+ * @example
2405
+ * // Last entry
2406
+ * const mm = new TreeMultiMap<number, string>();
2407
+ * mm.add(1, 'a');
2408
+ * mm.add(3, 'c');
2409
+ * console.log(mm.last()?.[0]); // 3;
2410
+ */
2411
+ last(): [K, V[]] | undefined;
2412
+ /**
2413
+ * Removes and returns the entry with the smallest key.
2414
+ * @remarks Time O(log n), Space O(1)
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+
2423
+
2424
+
2425
+
2426
+
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+ * @example
2447
+ * // Remove and return first
2448
+ * const mm = new TreeMultiMap<number, string>();
2449
+ * mm.add(2, 'b');
2450
+ * mm.add(1, 'a');
2451
+ * const first = mm.pollFirst();
2452
+ * console.log(first?.[0]); // 1;
2453
+ * console.log(mm.has(1)); // false;
2454
+ */
2455
+ pollFirst(): [K, V[]] | undefined;
2456
+ /**
2457
+ * Removes and returns the entry with the largest key.
2458
+ * @remarks Time O(log n), Space O(1)
2459
+
2460
+
2461
+
2462
+
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+
2473
+
2474
+
2475
+
2476
+
2477
+
2478
+
2479
+
2480
+
2481
+
2482
+
2483
+
2484
+
2485
+
2486
+
2487
+
2488
+
2489
+
2490
+ * @example
2491
+ * // Remove and return last
2492
+ * const mm = new TreeMultiMap<number, string>();
2493
+ * mm.add(1, 'a');
2494
+ * mm.add(3, 'c');
2495
+ * const last = mm.pollLast();
2496
+ * console.log(last?.[0]); // 3;
2497
+ */
2498
+ pollLast(): [K, V[]] | undefined;
2499
+ /**
2500
+ * Returns the entry with the smallest key >= given key.
2501
+ * @remarks Time O(log n), Space O(1)
2502
+
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2523
+
2524
+
2525
+
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2549
+
2550
+
2551
+
2552
+
2553
+
2554
+
2555
+
2556
+
2557
+
2558
+
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2585
+
2586
+
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2600
+
2601
+
2602
+
2603
+
2604
+
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2613
+
2614
+
2615
+
2616
+
2617
+
2618
+
2619
+
2620
+
2621
+
2622
+
2623
+
2624
+
2625
+
2626
+
2627
+
2628
+
2629
+
2630
+
2631
+
2632
+
2633
+
2634
+
2635
+
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+ * @example
2684
+ * // Least key ≥ target
2685
+ * const mm = new TreeMultiMap<number, string>();
2686
+ * mm.add(10, 'a');
2687
+ * mm.add(20, 'b');
2688
+ * mm.add(30, 'c');
2689
+ * console.log(mm.ceiling(15)?.[0]); // 20;
2690
+ */
2691
+ ceiling(key: K): [K, V[]] | undefined;
2692
+ /**
2693
+ * Returns the entry with the largest key <= given key.
2694
+ * @remarks Time O(log n), Space O(1)
2695
+
2696
+
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2769
+
2770
+
2771
+
2772
+
2773
+
2774
+
2775
+
2776
+
2777
+
2778
+
1863
2779
 
1864
2780
 
1865
2781
 
@@ -1913,18 +2829,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1913
2829
 
1914
2830
 
1915
2831
 
1916
- * @example
1917
- * // Last entry
1918
- * const mm = new TreeMultiMap<number, string>();
1919
- * mm.add(1, 'a');
1920
- * mm.add(3, 'c');
1921
- * console.log(mm.last()?.[0]); // 3;
1922
- */
1923
- last(): [K, V[]] | undefined;
1924
- /**
1925
- * Removes and returns the entry with the smallest key.
1926
- * @remarks Time O(log n), Space O(1)
1927
-
1928
2832
 
1929
2833
 
1930
2834
 
@@ -1947,20 +2851,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1947
2851
 
1948
2852
 
1949
2853
 
1950
- * @example
1951
- * // Remove and return first
1952
- * const mm = new TreeMultiMap<number, string>();
1953
- * mm.add(2, 'b');
1954
- * mm.add(1, 'a');
1955
- * const first = mm.pollFirst();
1956
- * console.log(first?.[0]); // 1;
1957
- * console.log(mm.has(1)); // false;
1958
- */
1959
- pollFirst(): [K, V[]] | undefined;
1960
- /**
1961
- * Removes and returns the entry with the largest key.
1962
- * @remarks Time O(log n), Space O(1)
1963
-
1964
2854
 
1965
2855
 
1966
2856
 
@@ -1984,16 +2874,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
1984
2874
 
1985
2875
 
1986
2876
  * @example
1987
- * // Remove and return last
2877
+ * // Greatest key target
1988
2878
  * const mm = new TreeMultiMap<number, string>();
1989
- * mm.add(1, 'a');
1990
- * mm.add(3, 'c');
1991
- * const last = mm.pollLast();
1992
- * console.log(last?.[0]); // 3;
2879
+ * mm.add(10, 'a');
2880
+ * mm.add(20, 'b');
2881
+ * mm.add(30, 'c');
2882
+ * console.log(mm.floor(25)?.[0]); // 20;
1993
2883
  */
1994
- pollLast(): [K, V[]] | undefined;
2884
+ floor(key: K): [K, V[]] | undefined;
1995
2885
  /**
1996
- * Returns the entry with the smallest key >= given key.
2886
+ * Returns the entry with the smallest key > given key.
1997
2887
  * @remarks Time O(log n), Space O(1)
1998
2888
 
1999
2889
 
@@ -2134,19 +3024,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2134
3024
 
2135
3025
 
2136
3026
 
3027
+
2137
3028
 
2138
3029
 
2139
3030
  * @example
2140
- * // Least key target
3031
+ * // Least key > target
2141
3032
  * const mm = new TreeMultiMap<number, string>();
2142
3033
  * mm.add(10, 'a');
2143
3034
  * mm.add(20, 'b');
2144
- * mm.add(30, 'c');
2145
- * console.log(mm.ceiling(15)?.[0]); // 20;
3035
+ * console.log(mm.higher(10)?.[0]); // 20;
2146
3036
  */
2147
- ceiling(key: K): [K, V[]] | undefined;
3037
+ higher(key: K): [K, V[]] | undefined;
2148
3038
  /**
2149
- * Returns the entry with the largest key <= given key.
3039
+ * Returns the entry with the largest key < given key.
2150
3040
  * @remarks Time O(log n), Space O(1)
2151
3041
 
2152
3042
 
@@ -2287,21 +3177,20 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2287
3177
 
2288
3178
 
2289
3179
 
3180
+
2290
3181
 
2291
3182
 
2292
3183
  * @example
2293
- * // Greatest key target
3184
+ * // Greatest key < target
2294
3185
  * const mm = new TreeMultiMap<number, string>();
2295
3186
  * mm.add(10, 'a');
2296
3187
  * mm.add(20, 'b');
2297
- * mm.add(30, 'c');
2298
- * console.log(mm.floor(25)?.[0]); // 20;
3188
+ * console.log(mm.lower(20)?.[0]); // 10;
2299
3189
  */
2300
- floor(key: K): [K, V[]] | undefined;
3190
+ lower(key: K): [K, V[]] | undefined;
2301
3191
  /**
2302
- * Returns the entry with the smallest key > given key.
2303
- * @remarks Time O(log n), Space O(1)
2304
-
3192
+ * Prints the internal tree structure (for debugging).
3193
+ * @remarks Time O(n), Space O(n)
2305
3194
 
2306
3195
 
2307
3196
 
@@ -2411,18 +3300,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2411
3300
 
2412
3301
 
2413
3302
 
2414
- * @example
2415
- * // Least key > target
2416
- * const mm = new TreeMultiMap<number, string>();
2417
- * mm.add(10, 'a');
2418
- * mm.add(20, 'b');
2419
- * console.log(mm.higher(10)?.[0]); // 20;
2420
- */
2421
- higher(key: K): [K, V[]] | undefined;
2422
- /**
2423
- * Returns the entry with the largest key < given key.
2424
- * @remarks Time O(log n), Space O(1)
2425
-
2426
3303
 
2427
3304
 
2428
3305
 
@@ -2492,6 +3369,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2492
3369
 
2493
3370
 
2494
3371
 
3372
+ * @example
3373
+ * // Display tree
3374
+ * const mm = new TreeMultiMap<number, string>();
3375
+ * mm.add(1, 'a');
3376
+ * expect(() => mm.print()).not.toThrow();
3377
+ */
3378
+ print(): void;
3379
+ /**
3380
+ * Executes a callback for each entry.
3381
+ * @remarks Time O(n), Space O(1)
2495
3382
 
2496
3383
 
2497
3384
 
@@ -2532,17 +3419,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2532
3419
 
2533
3420
 
2534
3421
 
2535
- * @example
2536
- * // Greatest key < target
2537
- * const mm = new TreeMultiMap<number, string>();
2538
- * mm.add(10, 'a');
2539
- * mm.add(20, 'b');
2540
- * console.log(mm.lower(20)?.[0]); // 10;
2541
- */
2542
- lower(key: K): [K, V[]] | undefined;
2543
- /**
2544
- * Prints the internal tree structure (for debugging).
2545
- * @remarks Time O(n), Space O(n)
2546
3422
 
2547
3423
 
2548
3424
 
@@ -2682,15 +3558,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2682
3558
 
2683
3559
 
2684
3560
  * @example
2685
- * // Display tree
3561
+ * // Iterate entries
2686
3562
  * const mm = new TreeMultiMap<number, string>();
2687
3563
  * mm.add(1, 'a');
2688
- * expect(() => mm.print()).not.toThrow();
3564
+ * mm.add(2, 'b');
3565
+ * const keys: number[] = [];
3566
+ * mm.forEach((v, k) => keys.push(k));
3567
+ * console.log(keys); // [1, 2];
2689
3568
  */
2690
- print(): void;
3569
+ forEach(callback: (value: V[], key: K, map: this) => void): void;
2691
3570
  /**
2692
- * Executes a callback for each entry.
2693
- * @remarks Time O(n), Space O(1)
3571
+ * Creates a new map with entries that pass the predicate.
3572
+ * @remarks Time O(n), Space O(n)
2694
3573
 
2695
3574
 
2696
3575
 
@@ -2829,19 +3708,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2829
3708
 
2830
3709
 
2831
3710
 
2832
- * @example
2833
- * // Iterate entries
2834
- * const mm = new TreeMultiMap<number, string>();
2835
- * mm.add(1, 'a');
2836
- * mm.add(2, 'b');
2837
- * const keys: number[] = [];
2838
- * mm.forEach((v, k) => keys.push(k));
2839
- * console.log(keys); // [1, 2];
2840
- */
2841
- forEach(callback: (value: V[], key: K, map: this) => void): void;
2842
- /**
2843
- * Creates a new map with entries that pass the predicate.
2844
- * @remarks Time O(n), Space O(n)
2845
3711
 
2846
3712
 
2847
3713
 
@@ -2882,6 +3748,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2882
3748
 
2883
3749
 
2884
3750
 
3751
+ * @example
3752
+ * // Filter entries
3753
+ * const mm = new TreeMultiMap<number, string>();
3754
+ * mm.add(1, 'a');
3755
+ * mm.add(2, 'b');
3756
+ * mm.add(3, 'c');
3757
+ * const filtered = mm.filter((v, k) => k > 1);
3758
+ * console.log([...filtered.keys()]); // [2, 3];
3759
+ */
3760
+ filter(predicate: (value: V[], key: K, map: this) => boolean): TreeMultiMap<K, V, R>;
3761
+ /**
3762
+ * Creates a new map by transforming each entry.
3763
+ * @remarks Time O(n log n), Space O(n)
2885
3764
 
2886
3765
 
2887
3766
 
@@ -2980,19 +3859,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
2980
3859
 
2981
3860
 
2982
3861
 
2983
- * @example
2984
- * // Filter entries
2985
- * const mm = new TreeMultiMap<number, string>();
2986
- * mm.add(1, 'a');
2987
- * mm.add(2, 'b');
2988
- * mm.add(3, 'c');
2989
- * const filtered = mm.filter((v, k) => k > 1);
2990
- * console.log([...filtered.keys()]); // [2, 3];
2991
- */
2992
- filter(predicate: (value: V[], key: K, map: this) => boolean): TreeMultiMap<K, V, R>;
2993
- /**
2994
- * Creates a new map by transforming each entry.
2995
- * @remarks Time O(n log n), Space O(n)
2996
3862
 
2997
3863
 
2998
3864
 
@@ -3073,6 +3939,24 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3073
3939
 
3074
3940
 
3075
3941
 
3942
+ * @example
3943
+ * // Transform values
3944
+ * const mm = new TreeMultiMap<number, string>();
3945
+ * mm.add(1, 'a');
3946
+ * const mapped = mm.map((v, k) => [k, v.map(s => s.toUpperCase())] as [number, string[]]);
3947
+ * console.log(mapped.get(1)); // ['A'];
3948
+ */
3949
+ map<V2>(mapper: (value: V[], key: K, map: this) => [K, V2[]]): TreeMultiMap<K, V2, R>;
3950
+ /**
3951
+ * Reduces all entries to a single value.
3952
+ * @remarks Time O(n), Space O(1)
3953
+
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3076
3960
 
3077
3961
 
3078
3962
 
@@ -3131,17 +4015,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3131
4015
 
3132
4016
 
3133
4017
 
3134
- * @example
3135
- * // Transform values
3136
- * const mm = new TreeMultiMap<number, string>();
3137
- * mm.add(1, 'a');
3138
- * const mapped = mm.map((v, k) => [k, v.map(s => s.toUpperCase())] as [number, string[]]);
3139
- * console.log(mapped.get(1)); // ['A'];
3140
- */
3141
- map<V2>(mapper: (value: V[], key: K, map: this) => [K, V2[]]): TreeMultiMap<K, V2, R>;
3142
- /**
3143
- * Reduces all entries to a single value.
3144
- * @remarks Time O(n), Space O(1)
3145
4018
 
3146
4019
 
3147
4020
 
@@ -3255,6 +4128,33 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3255
4128
 
3256
4129
 
3257
4130
 
4131
+ * @example
4132
+ * // Aggregate
4133
+ * const mm = new TreeMultiMap<number, number>();
4134
+ * mm.add(1, 10);
4135
+ * mm.add(2, 20);
4136
+ * const sum = mm.reduce((acc, v) => acc + v.reduce((a, b) => a + b, 0), 0);
4137
+ * console.log(sum); // 30;
4138
+ */
4139
+ reduce<U>(callback: (accumulator: U, value: V[], key: K, map: this) => U, initialValue: U): U;
4140
+ /**
4141
+ * Sets multiple entries at once.
4142
+ * @remarks Time O(m log n), Space O(m) where m is input size
4143
+
4144
+
4145
+
4146
+
4147
+
4148
+
4149
+
4150
+
4151
+
4152
+
4153
+
4154
+
4155
+
4156
+
4157
+
3258
4158
 
3259
4159
 
3260
4160
 
@@ -3280,18 +4180,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3280
4180
 
3281
4181
 
3282
4182
 
3283
- * @example
3284
- * // Aggregate
3285
- * const mm = new TreeMultiMap<number, number>();
3286
- * mm.add(1, 10);
3287
- * mm.add(2, 20);
3288
- * const sum = mm.reduce((acc, v) => acc + v.reduce((a, b) => a + b, 0), 0);
3289
- * console.log(sum); // 30;
3290
- */
3291
- reduce<U>(callback: (accumulator: U, value: V[], key: K, map: this) => U, initialValue: U): U;
3292
- /**
3293
- * Sets multiple entries at once.
3294
- * @remarks Time O(m log n), Space O(m) where m is input size
3295
4183
 
3296
4184
 
3297
4185
 
@@ -3521,6 +4409,38 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3521
4409
 
3522
4410
 
3523
4411
 
4412
+
4413
+
4414
+
4415
+
4416
+
4417
+
4418
+
4419
+
4420
+
4421
+
4422
+
4423
+
4424
+
4425
+
4426
+
4427
+
4428
+
4429
+
4430
+
4431
+
4432
+
4433
+
4434
+
4435
+
4436
+
4437
+
4438
+
4439
+
4440
+
4441
+
4442
+
4443
+
3524
4444
 
3525
4445
 
3526
4446
 
@@ -3674,6 +4594,24 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3674
4594
 
3675
4595
 
3676
4596
 
4597
+
4598
+
4599
+
4600
+
4601
+
4602
+
4603
+
4604
+
4605
+
4606
+
4607
+
4608
+
4609
+
4610
+
4611
+
4612
+
4613
+
4614
+
3677
4615
 
3678
4616
 
3679
4617
 
@@ -3694,13 +4632,88 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
3694
4632
 
3695
4633
 
3696
4634
  * @example
3697
- * // Deep clone
3698
- * const mm = new TreeMultiMap<number, string>();
3699
- * mm.add(1, 'a');
3700
- * const copy = mm.clone();
3701
- * copy.delete(1);
3702
- * console.log(mm.has(1)); // true;
4635
+ * // Order-statistic on BST
4636
+ * const tree = new TreeMultiMap<number>([30, 10, 50, 20, 40], { enableOrderStatistic: true });
4637
+ * console.log(tree.getByRank(0)); // 10;
4638
+ * console.log(tree.getByRank(4)); // 50;
4639
+ * console.log(tree.getRank(30)); // 2;
3703
4640
  */
4641
+ getByRank(k: number): [K, V[]] | undefined;
4642
+ /**
4643
+ * Get the rank of a key in sorted order
4644
+ * @example
4645
+ * // Get the rank of a key in sorted order
4646
+ * const tree = new TreeMultiMap<number>(
4647
+ * [10, 20, 30, 40, 50],
4648
+ * { enableOrderStatistic: true }
4649
+ * );
4650
+ * console.log(tree.getRank(10)); // 0; // smallest → rank 0
4651
+ * console.log(tree.getRank(30)); // 2; // 2 elements before 30 in tree order
4652
+ * console.log(tree.getRank(50)); // 4; // largest → rank 4
4653
+ * console.log(tree.getRank(25)); // 2;
4654
+ */
4655
+ getRank(key: K): number;
4656
+ /**
4657
+ * Get elements by rank range
4658
+
4659
+
4660
+
4661
+
4662
+
4663
+
4664
+
4665
+
4666
+
4667
+ * @example
4668
+ * // Pagination by position in tree order
4669
+ * const tree = new TreeMultiMap<number>(
4670
+ * [10, 20, 30, 40, 50, 60, 70, 80, 90],
4671
+ * { enableOrderStatistic: true }
4672
+ * );
4673
+ * const pageSize = 3;
4674
+ *
4675
+ * // Page 1
4676
+ * console.log(tree.rangeByRank(0, pageSize - 1)); // [10, 20, 30];
4677
+ * // Page 2
4678
+ * console.log(tree.rangeByRank(pageSize, 2 * pageSize - 1)); // [40, 50, 60];
4679
+ * // Page 3
4680
+ * console.log(tree.rangeByRank(2 * pageSize, 3 * pageSize - 1)); // [70, 80, 90];
4681
+ */
4682
+ rangeByRank(start: number, end: number): Array<[K, V[]]>;
4683
+ /**
4684
+ * Deep copy
4685
+
4686
+
4687
+
4688
+
4689
+
4690
+
4691
+
4692
+
4693
+
4694
+
4695
+
4696
+
4697
+
4698
+
4699
+
4700
+
4701
+
4702
+
4703
+
4704
+
4705
+
4706
+
4707
+
4708
+
4709
+ * @example
4710
+ * // Deep clone
4711
+ * const mm = new TreeMultiMap<number, string>();
4712
+ * mm.add(1, 'a');
4713
+ * const copy = mm.clone();
4714
+ * copy.delete(1);
4715
+ * console.log(mm.has(1)); // true;
4716
+ */
3704
4717
  clone(): TreeMultiMap<K, V, R>;
3705
4718
  /**
3706
4719
  * Expose comparator for advanced usage/testing (read-only).