binary-tree-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.
- package/dist/cjs/index.cjs +340 -107
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +339 -106
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +340 -108
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +339 -107
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/binary-tree-typed.js +337 -105
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -194,16 +194,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
194
194
|
|
|
195
195
|
|
|
196
196
|
|
|
197
|
-
* @example
|
|
198
|
-
* // Check if empty
|
|
199
|
-
* console.log(new TreeMultiMap().isEmpty()); // true;
|
|
200
|
-
*/
|
|
201
|
-
isEmpty(): boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Removes all entries from the map.
|
|
204
|
-
* @remarks Time O(1), Space O(1)
|
|
205
|
-
|
|
206
|
-
|
|
207
197
|
|
|
208
198
|
|
|
209
199
|
|
|
@@ -239,6 +229,14 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
239
229
|
|
|
240
230
|
|
|
241
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)
|
|
242
240
|
|
|
243
241
|
|
|
244
242
|
|
|
@@ -345,17 +343,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
345
343
|
|
|
346
344
|
|
|
347
345
|
|
|
348
|
-
* @example
|
|
349
|
-
* // Remove all entries
|
|
350
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
351
|
-
* mm.add(1, 'a');
|
|
352
|
-
* mm.clear();
|
|
353
|
-
* console.log(mm.isEmpty()); // true;
|
|
354
|
-
*/
|
|
355
|
-
clear(): void;
|
|
356
|
-
/**
|
|
357
|
-
* Bucket length for a key (missing => 0).
|
|
358
|
-
* @remarks Time O(log n), Space O(1)
|
|
359
346
|
|
|
360
347
|
|
|
361
348
|
|
|
@@ -379,17 +366,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
379
366
|
|
|
380
367
|
|
|
381
368
|
|
|
382
|
-
* @example
|
|
383
|
-
* // Count values for key
|
|
384
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
385
|
-
* mm.add(1, 'a');
|
|
386
|
-
* mm.add(1, 'b');
|
|
387
|
-
* console.log(mm.count(1)); // 2;
|
|
388
|
-
*/
|
|
389
|
-
count(key: K): number;
|
|
390
|
-
/**
|
|
391
|
-
* Total number of values across all buckets (Σ bucket.length).
|
|
392
|
-
* @remarks Time O(n), Space O(1)
|
|
393
369
|
|
|
394
370
|
|
|
395
371
|
|
|
@@ -413,18 +389,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
413
389
|
|
|
414
390
|
|
|
415
391
|
|
|
416
|
-
* @example
|
|
417
|
-
* // Total number of values
|
|
418
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
419
|
-
* mm.add(1, 'a');
|
|
420
|
-
* mm.add(1, 'b');
|
|
421
|
-
* mm.add(2, 'c');
|
|
422
|
-
* console.log(mm.totalSize); // 3;
|
|
423
|
-
*/
|
|
424
|
-
get totalSize(): number;
|
|
425
|
-
/**
|
|
426
|
-
* Whether the map contains the given key.
|
|
427
|
-
* @remarks Time O(log n), Space O(1)
|
|
428
392
|
|
|
429
393
|
|
|
430
394
|
|
|
@@ -451,6 +415,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
451
415
|
|
|
452
416
|
|
|
453
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)
|
|
454
429
|
|
|
455
430
|
|
|
456
431
|
|
|
@@ -481,6 +456,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
481
456
|
|
|
482
457
|
|
|
483
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)
|
|
484
470
|
|
|
485
471
|
|
|
486
472
|
|
|
@@ -511,6 +497,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
511
497
|
|
|
512
498
|
|
|
513
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)
|
|
514
512
|
|
|
515
513
|
|
|
516
514
|
|
|
@@ -603,17 +601,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
603
601
|
|
|
604
602
|
|
|
605
603
|
|
|
606
|
-
* @example
|
|
607
|
-
* // Check key existence
|
|
608
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
609
|
-
* mm.add(1, 'a');
|
|
610
|
-
* console.log(mm.has(1)); // true;
|
|
611
|
-
* console.log(mm.has(2)); // false;
|
|
612
|
-
*/
|
|
613
|
-
has(key: K): boolean;
|
|
614
|
-
/**
|
|
615
|
-
* Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
|
|
616
|
-
* @remarks Time O(log n), Space O(1)
|
|
617
604
|
|
|
618
605
|
|
|
619
606
|
|
|
@@ -742,6 +729,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
742
729
|
|
|
743
730
|
|
|
744
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)
|
|
745
743
|
|
|
746
744
|
|
|
747
745
|
|
|
@@ -792,17 +790,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
792
790
|
|
|
793
791
|
|
|
794
792
|
|
|
795
|
-
* @example
|
|
796
|
-
* // Get values for key
|
|
797
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
798
|
-
* mm.add(1, 'a');
|
|
799
|
-
* mm.add(1, 'b');
|
|
800
|
-
* console.log(mm.get(1)); // ['a', 'b'];
|
|
801
|
-
*/
|
|
802
|
-
get(key: K): V[] | undefined;
|
|
803
|
-
/**
|
|
804
|
-
* Append a single value.
|
|
805
|
-
* @remarks Time O(log n), Space O(1)
|
|
806
793
|
|
|
807
794
|
|
|
808
795
|
|
|
@@ -940,18 +927,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
940
927
|
|
|
941
928
|
|
|
942
929
|
|
|
943
|
-
* @example
|
|
944
|
-
* // Add key-value pair
|
|
945
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
946
|
-
* mm.add(1, 'a');
|
|
947
|
-
* mm.add(1, 'b');
|
|
948
|
-
* mm.add(2, 'c');
|
|
949
|
-
* console.log(mm.get(1)); // ['a', 'b'];
|
|
950
|
-
*/
|
|
951
|
-
add(key: K, value: V): boolean;
|
|
952
|
-
/**
|
|
953
|
-
* Alias for compatibility with existing TreeMultiMap semantics.
|
|
954
|
-
* @remarks Time O(log n), Space O(1) for single value; O(log n + m) for bucket append
|
|
955
930
|
|
|
956
931
|
|
|
957
932
|
|
|
@@ -985,6 +960,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
985
960
|
|
|
986
961
|
|
|
987
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)
|
|
988
974
|
|
|
989
975
|
|
|
990
976
|
|
|
@@ -1128,18 +1114,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1128
1114
|
|
|
1129
1115
|
|
|
1130
1116
|
|
|
1131
|
-
* @example
|
|
1132
|
-
* // Set values for key
|
|
1133
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1134
|
-
* mm.set(1, 'a');
|
|
1135
|
-
* mm.set(1, 'b');
|
|
1136
|
-
* console.log(mm.get(1)); // ['a', 'b'];
|
|
1137
|
-
*/
|
|
1138
|
-
set(entry: [K | null | undefined, V[] | undefined] | K | null | undefined, value?: V): boolean;
|
|
1139
|
-
set(key: K, value: V): boolean;
|
|
1140
|
-
/**
|
|
1141
|
-
* Deletes a key and its entire bucket.
|
|
1142
|
-
* @remarks Time O(log n), Space O(1)
|
|
1143
1117
|
|
|
1144
1118
|
|
|
1145
1119
|
|
|
@@ -1169,6 +1143,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1169
1143
|
|
|
1170
1144
|
|
|
1171
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
|
|
1172
1158
|
|
|
1173
1159
|
|
|
1174
1160
|
|
|
@@ -1318,18 +1304,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1318
1304
|
|
|
1319
1305
|
|
|
1320
1306
|
|
|
1321
|
-
* @example
|
|
1322
|
-
* // Remove key
|
|
1323
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1324
|
-
* mm.add(1, 'a');
|
|
1325
|
-
* mm.add(2, 'b');
|
|
1326
|
-
* mm.delete(1);
|
|
1327
|
-
* console.log(mm.has(1)); // false;
|
|
1328
|
-
*/
|
|
1329
|
-
delete(key: K): boolean;
|
|
1330
|
-
/**
|
|
1331
|
-
* Check if a specific value exists in a key's bucket.
|
|
1332
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1333
1307
|
|
|
1334
1308
|
|
|
1335
1309
|
|
|
@@ -1353,17 +1327,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1353
1327
|
|
|
1354
1328
|
|
|
1355
1329
|
|
|
1356
|
-
* @example
|
|
1357
|
-
* // Check specific key-value
|
|
1358
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1359
|
-
* mm.add(1, 'a');
|
|
1360
|
-
* console.log(mm.hasEntry(1, 'a')); // true;
|
|
1361
|
-
* console.log(mm.hasEntry(1, 'z')); // false;
|
|
1362
|
-
*/
|
|
1363
|
-
hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1364
|
-
/**
|
|
1365
|
-
* Delete a single occurrence of a value from a key's bucket.
|
|
1366
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1367
1330
|
|
|
1368
1331
|
|
|
1369
1332
|
|
|
@@ -1387,18 +1350,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1387
1350
|
|
|
1388
1351
|
|
|
1389
1352
|
|
|
1390
|
-
* @example
|
|
1391
|
-
* // Delete specific value
|
|
1392
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1393
|
-
* mm.add(1, 'a');
|
|
1394
|
-
* mm.add(1, 'b');
|
|
1395
|
-
* mm.deleteValue(1, 'a');
|
|
1396
|
-
* console.log(mm.get(1)); // ['b'];
|
|
1397
|
-
*/
|
|
1398
|
-
deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1399
|
-
/**
|
|
1400
|
-
* Delete all occurrences of a value from a key's bucket.
|
|
1401
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1402
1353
|
|
|
1403
1354
|
|
|
1404
1355
|
|
|
@@ -1423,33 +1374,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1423
1374
|
|
|
1424
1375
|
|
|
1425
1376
|
* @example
|
|
1426
|
-
* //
|
|
1377
|
+
* // Set values for key
|
|
1427
1378
|
* const mm = new TreeMultiMap<number, string>();
|
|
1428
|
-
* mm.
|
|
1429
|
-
* mm.
|
|
1430
|
-
* mm.
|
|
1431
|
-
* const count = mm.deleteValues(1, 'a');
|
|
1432
|
-
* console.log(count); // 2;
|
|
1433
|
-
*/
|
|
1434
|
-
deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
|
|
1435
|
-
/**
|
|
1436
|
-
* Iterates over all entries as [key, bucket] pairs.
|
|
1437
|
-
* @remarks Time O(n), Space O(1)
|
|
1379
|
+
* mm.set(1, 'a');
|
|
1380
|
+
* mm.set(1, 'b');
|
|
1381
|
+
* console.log(mm.get(1)); // ['a', 'b'];
|
|
1438
1382
|
*/
|
|
1439
|
-
|
|
1383
|
+
set(entry: [K | null | undefined, V[] | undefined] | K | null | undefined, value?: V): boolean;
|
|
1384
|
+
set(key: K, value: V): boolean;
|
|
1440
1385
|
/**
|
|
1441
|
-
*
|
|
1442
|
-
* @remarks Time O(n), Space O(1)
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1386
|
+
* Deletes a key and its entire bucket.
|
|
1387
|
+
* @remarks Time O(log n), Space O(1)
|
|
1453
1388
|
|
|
1454
1389
|
|
|
1455
1390
|
|
|
@@ -1583,17 +1518,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1583
1518
|
|
|
1584
1519
|
|
|
1585
1520
|
|
|
1586
|
-
* @example
|
|
1587
|
-
* // Iterate keys
|
|
1588
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1589
|
-
* mm.add(3, 'c');
|
|
1590
|
-
* mm.add(1, 'a');
|
|
1591
|
-
* console.log([...mm.keys()]); // [1, 3];
|
|
1592
|
-
*/
|
|
1593
|
-
keys(): IterableIterator<K>;
|
|
1594
|
-
/**
|
|
1595
|
-
* Iterates over all buckets.
|
|
1596
|
-
* @remarks Time O(n), Space O(1)
|
|
1597
1521
|
|
|
1598
1522
|
|
|
1599
1523
|
|
|
@@ -1681,6 +1605,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1681
1605
|
|
|
1682
1606
|
|
|
1683
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
|
|
1684
1620
|
|
|
1685
1621
|
|
|
1686
1622
|
|
|
@@ -1711,6 +1647,21 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1711
1647
|
|
|
1712
1648
|
|
|
1713
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;
|
|
1656
|
+
*/
|
|
1657
|
+
hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1658
|
+
/**
|
|
1659
|
+
* Delete a single occurrence of a value from a key's bucket.
|
|
1660
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1661
|
+
|
|
1662
|
+
|
|
1663
|
+
|
|
1664
|
+
|
|
1714
1665
|
|
|
1715
1666
|
|
|
1716
1667
|
|
|
@@ -1738,15 +1689,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1738
1689
|
|
|
1739
1690
|
|
|
1740
1691
|
* @example
|
|
1741
|
-
* //
|
|
1692
|
+
* // Delete specific value
|
|
1742
1693
|
* const mm = new TreeMultiMap<number, string>();
|
|
1743
1694
|
* mm.add(1, 'a');
|
|
1744
1695
|
* mm.add(1, 'b');
|
|
1745
|
-
*
|
|
1696
|
+
* mm.deleteValue(1, 'a');
|
|
1697
|
+
* console.log(mm.get(1)); // ['b'];
|
|
1746
1698
|
*/
|
|
1747
|
-
|
|
1699
|
+
deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1748
1700
|
/**
|
|
1749
|
-
*
|
|
1701
|
+
* Delete all occurrences of a value from a key's bucket.
|
|
1750
1702
|
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1751
1703
|
|
|
1752
1704
|
|
|
@@ -1763,6 +1715,13 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1763
1715
|
|
|
1764
1716
|
|
|
1765
1717
|
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
|
|
1766
1725
|
|
|
1767
1726
|
|
|
1768
1727
|
|
|
@@ -1772,16 +1731,100 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1772
1731
|
|
|
1773
1732
|
|
|
1774
1733
|
* @example
|
|
1775
|
-
* //
|
|
1734
|
+
* // Delete all matching values
|
|
1776
1735
|
* const mm = new TreeMultiMap<number, string>();
|
|
1777
1736
|
* mm.add(1, 'a');
|
|
1737
|
+
* mm.add(1, 'a');
|
|
1778
1738
|
* mm.add(1, 'b');
|
|
1779
|
-
*
|
|
1739
|
+
* const count = mm.deleteValues(1, 'a');
|
|
1740
|
+
* console.log(count); // 2;
|
|
1780
1741
|
*/
|
|
1781
|
-
|
|
1742
|
+
deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
|
|
1782
1743
|
/**
|
|
1783
|
-
* Iterates over all
|
|
1784
|
-
* @remarks Time O(
|
|
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
|
+
|
|
1785
1828
|
|
|
1786
1829
|
|
|
1787
1830
|
|
|
@@ -1805,17 +1848,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1805
1848
|
|
|
1806
1849
|
|
|
1807
1850
|
|
|
1808
|
-
* @example
|
|
1809
|
-
* // Get flat values for key
|
|
1810
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1811
|
-
* mm.add(1, 'a');
|
|
1812
|
-
* mm.add(1, 'b');
|
|
1813
|
-
* console.log([...mm.valuesOf(1)]); // ['a', 'b'];
|
|
1814
|
-
*/
|
|
1815
|
-
valuesOf(key: K): IterableIterator<V>;
|
|
1816
|
-
/**
|
|
1817
|
-
* Iterates over all [key, value] pairs (flattened from buckets).
|
|
1818
|
-
* @remarks Time O(T), Space O(1) where T is totalSize
|
|
1819
1851
|
|
|
1820
1852
|
|
|
1821
1853
|
|
|
@@ -1839,19 +1871,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1839
1871
|
|
|
1840
1872
|
|
|
1841
1873
|
|
|
1842
|
-
* @example
|
|
1843
|
-
* // All key-value pairs flattened
|
|
1844
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1845
|
-
* mm.add(1, 'a');
|
|
1846
|
-
* mm.add(1, 'b');
|
|
1847
|
-
* mm.add(2, 'c');
|
|
1848
|
-
* console.log([...mm.flatEntries()]); // [[1, 'a'], [1, 'b'], [2, 'c']];
|
|
1849
|
-
*/
|
|
1850
|
-
flatEntries(): IterableIterator<[K, V]>;
|
|
1851
|
-
/**
|
|
1852
|
-
* Returns the entry with the smallest key.
|
|
1853
|
-
* @remarks Time O(log n), Space O(1)
|
|
1854
|
-
|
|
1855
1874
|
|
|
1856
1875
|
|
|
1857
1876
|
|
|
@@ -1908,17 +1927,851 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1908
1927
|
|
|
1909
1928
|
|
|
1910
1929
|
* @example
|
|
1911
|
-
* //
|
|
1930
|
+
* // Iterate keys
|
|
1912
1931
|
* const mm = new TreeMultiMap<number, string>();
|
|
1913
1932
|
* mm.add(3, 'c');
|
|
1914
1933
|
* mm.add(1, 'a');
|
|
1915
|
-
* console.log(mm.
|
|
1934
|
+
* console.log([...mm.keys()]); // [1, 3];
|
|
1916
1935
|
*/
|
|
1917
|
-
|
|
1936
|
+
keys(): IterableIterator<K>;
|
|
1918
1937
|
/**
|
|
1919
|
-
*
|
|
1920
|
-
* @remarks Time O(
|
|
1921
|
-
|
|
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
|
+
|
|
1922
2775
|
|
|
1923
2776
|
|
|
1924
2777
|
|
|
@@ -1974,18 +2827,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1974
2827
|
|
|
1975
2828
|
|
|
1976
2829
|
|
|
1977
|
-
* @example
|
|
1978
|
-
* // Last entry
|
|
1979
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1980
|
-
* mm.add(1, 'a');
|
|
1981
|
-
* mm.add(3, 'c');
|
|
1982
|
-
* console.log(mm.last()?.[0]); // 3;
|
|
1983
|
-
*/
|
|
1984
|
-
last(): [K, V[]] | undefined;
|
|
1985
|
-
/**
|
|
1986
|
-
* Removes and returns the entry with the smallest key.
|
|
1987
|
-
* @remarks Time O(log n), Space O(1)
|
|
1988
|
-
|
|
1989
2830
|
|
|
1990
2831
|
|
|
1991
2832
|
|
|
@@ -2009,20 +2850,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2009
2850
|
|
|
2010
2851
|
|
|
2011
2852
|
|
|
2012
|
-
* @example
|
|
2013
|
-
* // Remove and return first
|
|
2014
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2015
|
-
* mm.add(2, 'b');
|
|
2016
|
-
* mm.add(1, 'a');
|
|
2017
|
-
* const first = mm.pollFirst();
|
|
2018
|
-
* console.log(first?.[0]); // 1;
|
|
2019
|
-
* console.log(mm.has(1)); // false;
|
|
2020
|
-
*/
|
|
2021
|
-
pollFirst(): [K, V[]] | undefined;
|
|
2022
|
-
/**
|
|
2023
|
-
* Removes and returns the entry with the largest key.
|
|
2024
|
-
* @remarks Time O(log n), Space O(1)
|
|
2025
|
-
|
|
2026
2853
|
|
|
2027
2854
|
|
|
2028
2855
|
|
|
@@ -2047,16 +2874,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2047
2874
|
|
|
2048
2875
|
|
|
2049
2876
|
* @example
|
|
2050
|
-
* //
|
|
2877
|
+
* // Greatest key ≤ target
|
|
2051
2878
|
* const mm = new TreeMultiMap<number, string>();
|
|
2052
|
-
* mm.add(
|
|
2053
|
-
* mm.add(
|
|
2054
|
-
*
|
|
2055
|
-
* console.log(
|
|
2879
|
+
* mm.add(10, 'a');
|
|
2880
|
+
* mm.add(20, 'b');
|
|
2881
|
+
* mm.add(30, 'c');
|
|
2882
|
+
* console.log(mm.floor(25)?.[0]); // 20;
|
|
2056
2883
|
*/
|
|
2057
|
-
|
|
2884
|
+
floor(key: K): [K, V[]] | undefined;
|
|
2058
2885
|
/**
|
|
2059
|
-
* Returns the entry with the smallest key
|
|
2886
|
+
* Returns the entry with the smallest key > given key.
|
|
2060
2887
|
* @remarks Time O(log n), Space O(1)
|
|
2061
2888
|
|
|
2062
2889
|
|
|
@@ -2195,26 +3022,21 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2195
3022
|
|
|
2196
3023
|
|
|
2197
3024
|
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
3025
|
|
|
2203
3026
|
|
|
2204
3027
|
|
|
2205
3028
|
|
|
2206
3029
|
|
|
2207
3030
|
* @example
|
|
2208
|
-
* // Least key
|
|
3031
|
+
* // Least key > target
|
|
2209
3032
|
* const mm = new TreeMultiMap<number, string>();
|
|
2210
3033
|
* mm.add(10, 'a');
|
|
2211
3034
|
* mm.add(20, 'b');
|
|
2212
|
-
* mm.
|
|
2213
|
-
* console.log(mm.ceiling(15)?.[0]); // 20;
|
|
3035
|
+
* console.log(mm.higher(10)?.[0]); // 20;
|
|
2214
3036
|
*/
|
|
2215
|
-
|
|
3037
|
+
higher(key: K): [K, V[]] | undefined;
|
|
2216
3038
|
/**
|
|
2217
|
-
* Returns the entry with the largest key
|
|
3039
|
+
* Returns the entry with the largest key < given key.
|
|
2218
3040
|
* @remarks Time O(log n), Space O(1)
|
|
2219
3041
|
|
|
2220
3042
|
|
|
@@ -2353,28 +3175,22 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2353
3175
|
|
|
2354
3176
|
|
|
2355
3177
|
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
3178
|
|
|
2361
3179
|
|
|
2362
3180
|
|
|
2363
3181
|
|
|
2364
3182
|
|
|
2365
3183
|
* @example
|
|
2366
|
-
* // Greatest key
|
|
3184
|
+
* // Greatest key < target
|
|
2367
3185
|
* const mm = new TreeMultiMap<number, string>();
|
|
2368
3186
|
* mm.add(10, 'a');
|
|
2369
3187
|
* mm.add(20, 'b');
|
|
2370
|
-
* mm.
|
|
2371
|
-
* console.log(mm.floor(25)?.[0]); // 20;
|
|
3188
|
+
* console.log(mm.lower(20)?.[0]); // 10;
|
|
2372
3189
|
*/
|
|
2373
|
-
|
|
3190
|
+
lower(key: K): [K, V[]] | undefined;
|
|
2374
3191
|
/**
|
|
2375
|
-
*
|
|
2376
|
-
* @remarks Time O(
|
|
2377
|
-
|
|
3192
|
+
* Prints the internal tree structure (for debugging).
|
|
3193
|
+
* @remarks Time O(n), Space O(n)
|
|
2378
3194
|
|
|
2379
3195
|
|
|
2380
3196
|
|
|
@@ -2488,18 +3304,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2488
3304
|
|
|
2489
3305
|
|
|
2490
3306
|
|
|
2491
|
-
* @example
|
|
2492
|
-
* // Least key > target
|
|
2493
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2494
|
-
* mm.add(10, 'a');
|
|
2495
|
-
* mm.add(20, 'b');
|
|
2496
|
-
* console.log(mm.higher(10)?.[0]); // 20;
|
|
2497
|
-
*/
|
|
2498
|
-
higher(key: K): [K, V[]] | undefined;
|
|
2499
|
-
/**
|
|
2500
|
-
* Returns the entry with the largest key < given key.
|
|
2501
|
-
* @remarks Time O(log n), Space O(1)
|
|
2502
|
-
|
|
2503
3307
|
|
|
2504
3308
|
|
|
2505
3309
|
|
|
@@ -2565,6 +3369,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2565
3369
|
|
|
2566
3370
|
|
|
2567
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)
|
|
2568
3382
|
|
|
2569
3383
|
|
|
2570
3384
|
|
|
@@ -2613,17 +3427,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2613
3427
|
|
|
2614
3428
|
|
|
2615
3429
|
|
|
2616
|
-
* @example
|
|
2617
|
-
* // Greatest key < target
|
|
2618
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2619
|
-
* mm.add(10, 'a');
|
|
2620
|
-
* mm.add(20, 'b');
|
|
2621
|
-
* console.log(mm.lower(20)?.[0]); // 10;
|
|
2622
|
-
*/
|
|
2623
|
-
lower(key: K): [K, V[]] | undefined;
|
|
2624
|
-
/**
|
|
2625
|
-
* Prints the internal tree structure (for debugging).
|
|
2626
|
-
* @remarks Time O(n), Space O(n)
|
|
2627
3430
|
|
|
2628
3431
|
|
|
2629
3432
|
|
|
@@ -2754,6 +3557,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2754
3557
|
|
|
2755
3558
|
|
|
2756
3559
|
|
|
3560
|
+
* @example
|
|
3561
|
+
* // Iterate entries
|
|
3562
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
3563
|
+
* mm.add(1, 'a');
|
|
3564
|
+
* mm.add(2, 'b');
|
|
3565
|
+
* const keys: number[] = [];
|
|
3566
|
+
* mm.forEach((v, k) => keys.push(k));
|
|
3567
|
+
* console.log(keys); // [1, 2];
|
|
3568
|
+
*/
|
|
3569
|
+
forEach(callback: (value: V[], key: K, map: this) => void): void;
|
|
3570
|
+
/**
|
|
3571
|
+
* Creates a new map with entries that pass the predicate.
|
|
3572
|
+
* @remarks Time O(n), Space O(n)
|
|
2757
3573
|
|
|
2758
3574
|
|
|
2759
3575
|
|
|
@@ -2767,16 +3583,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2767
3583
|
|
|
2768
3584
|
|
|
2769
3585
|
|
|
2770
|
-
* @example
|
|
2771
|
-
* // Display tree
|
|
2772
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2773
|
-
* mm.add(1, 'a');
|
|
2774
|
-
* expect(() => mm.print()).not.toThrow();
|
|
2775
|
-
*/
|
|
2776
|
-
print(): void;
|
|
2777
|
-
/**
|
|
2778
|
-
* Executes a callback for each entry.
|
|
2779
|
-
* @remarks Time O(n), Space O(1)
|
|
2780
3586
|
|
|
2781
3587
|
|
|
2782
3588
|
|
|
@@ -2920,19 +3726,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2920
3726
|
|
|
2921
3727
|
|
|
2922
3728
|
|
|
2923
|
-
* @example
|
|
2924
|
-
* // Iterate entries
|
|
2925
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2926
|
-
* mm.add(1, 'a');
|
|
2927
|
-
* mm.add(2, 'b');
|
|
2928
|
-
* const keys: number[] = [];
|
|
2929
|
-
* mm.forEach((v, k) => keys.push(k));
|
|
2930
|
-
* console.log(keys); // [1, 2];
|
|
2931
|
-
*/
|
|
2932
|
-
forEach(callback: (value: V[], key: K, map: this) => void): void;
|
|
2933
|
-
/**
|
|
2934
|
-
* Creates a new map with entries that pass the predicate.
|
|
2935
|
-
* @remarks Time O(n), Space O(n)
|
|
2936
3729
|
|
|
2937
3730
|
|
|
2938
3731
|
|
|
@@ -2955,6 +3748,21 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2955
3748
|
|
|
2956
3749
|
|
|
2957
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)
|
|
3764
|
+
|
|
3765
|
+
|
|
2958
3766
|
|
|
2959
3767
|
|
|
2960
3768
|
|
|
@@ -3076,19 +3884,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3076
3884
|
|
|
3077
3885
|
|
|
3078
3886
|
|
|
3079
|
-
* @example
|
|
3080
|
-
* // Filter entries
|
|
3081
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3082
|
-
* mm.add(1, 'a');
|
|
3083
|
-
* mm.add(2, 'b');
|
|
3084
|
-
* mm.add(3, 'c');
|
|
3085
|
-
* const filtered = mm.filter((v, k) => k > 1);
|
|
3086
|
-
* console.log([...filtered.keys()]); // [2, 3];
|
|
3087
|
-
*/
|
|
3088
|
-
filter(predicate: (value: V[], key: K, map: this) => boolean): TreeMultiMap<K, V, R>;
|
|
3089
|
-
/**
|
|
3090
|
-
* Creates a new map by transforming each entry.
|
|
3091
|
-
* @remarks Time O(n log n), Space O(n)
|
|
3092
3887
|
|
|
3093
3888
|
|
|
3094
3889
|
|
|
@@ -3144,6 +3939,27 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3144
3939
|
|
|
3145
3940
|
|
|
3146
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
|
+
|
|
3960
|
+
|
|
3961
|
+
|
|
3962
|
+
|
|
3147
3963
|
|
|
3148
3964
|
|
|
3149
3965
|
|
|
@@ -3232,17 +4048,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3232
4048
|
|
|
3233
4049
|
|
|
3234
4050
|
|
|
3235
|
-
* @example
|
|
3236
|
-
* // Transform values
|
|
3237
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3238
|
-
* mm.add(1, 'a');
|
|
3239
|
-
* const mapped = mm.map((v, k) => [k, v.map(s => s.toUpperCase())] as [number, string[]]);
|
|
3240
|
-
* console.log(mapped.get(1)); // ['A'];
|
|
3241
|
-
*/
|
|
3242
|
-
map<V2>(mapper: (value: V[], key: K, map: this) => [K, V2[]]): TreeMultiMap<K, V2, R>;
|
|
3243
|
-
/**
|
|
3244
|
-
* Reduces all entries to a single value.
|
|
3245
|
-
* @remarks Time O(n), Space O(1)
|
|
3246
4051
|
|
|
3247
4052
|
|
|
3248
4053
|
|
|
@@ -3323,6 +4128,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3323
4128
|
|
|
3324
4129
|
|
|
3325
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
|
|
3326
4143
|
|
|
3327
4144
|
|
|
3328
4145
|
|
|
@@ -3386,18 +4203,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3386
4203
|
|
|
3387
4204
|
|
|
3388
4205
|
|
|
3389
|
-
* @example
|
|
3390
|
-
* // Aggregate
|
|
3391
|
-
* const mm = new TreeMultiMap<number, number>();
|
|
3392
|
-
* mm.add(1, 10);
|
|
3393
|
-
* mm.add(2, 20);
|
|
3394
|
-
* const sum = mm.reduce((acc, v) => acc + v.reduce((a, b) => a + b, 0), 0);
|
|
3395
|
-
* console.log(sum); // 30;
|
|
3396
|
-
*/
|
|
3397
|
-
reduce<U>(callback: (accumulator: U, value: V[], key: K, map: this) => U, initialValue: U): U;
|
|
3398
|
-
/**
|
|
3399
|
-
* Sets multiple entries at once.
|
|
3400
|
-
* @remarks Time O(m log n), Space O(m) where m is input size
|
|
3401
4206
|
|
|
3402
4207
|
|
|
3403
4208
|
|
|
@@ -3505,6 +4310,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3505
4310
|
|
|
3506
4311
|
|
|
3507
4312
|
|
|
4313
|
+
* @example
|
|
4314
|
+
* // Set multiple entries
|
|
4315
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
4316
|
+
* mm.setMany([[1, ['a']], [2, ['b']]]);
|
|
4317
|
+
* console.log(mm.size); // 2;
|
|
4318
|
+
*/
|
|
4319
|
+
setMany(keysNodesEntriesOrRaws: Iterable<K | [K | null | undefined, V[] | undefined]>): boolean[];
|
|
4320
|
+
/**
|
|
4321
|
+
* Searches for entries within a key range.
|
|
4322
|
+
* @remarks Time O(log n + k), Space O(k) where k is result size
|
|
3508
4323
|
|
|
3509
4324
|
|
|
3510
4325
|
|
|
@@ -3533,16 +4348,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3533
4348
|
|
|
3534
4349
|
|
|
3535
4350
|
|
|
3536
|
-
* @example
|
|
3537
|
-
* // Set multiple entries
|
|
3538
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3539
|
-
* mm.setMany([[1, ['a']], [2, ['b']]]);
|
|
3540
|
-
* console.log(mm.size); // 2;
|
|
3541
|
-
*/
|
|
3542
|
-
setMany(keysNodesEntriesOrRaws: Iterable<K | [K | null | undefined, V[] | undefined]>): boolean[];
|
|
3543
|
-
/**
|
|
3544
|
-
* Searches for entries within a key range.
|
|
3545
|
-
* @remarks Time O(log n + k), Space O(k) where k is result size
|
|
3546
4351
|
|
|
3547
4352
|
|
|
3548
4353
|
|
|
@@ -3799,6 +4604,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3799
4604
|
|
|
3800
4605
|
|
|
3801
4606
|
|
|
4607
|
+
|
|
4608
|
+
|
|
4609
|
+
|
|
4610
|
+
|
|
4611
|
+
|
|
4612
|
+
|
|
4613
|
+
|
|
4614
|
+
|
|
4615
|
+
|
|
4616
|
+
|
|
4617
|
+
|
|
4618
|
+
|
|
4619
|
+
|
|
3802
4620
|
|
|
3803
4621
|
|
|
3804
4622
|
|
|
@@ -3814,13 +4632,88 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3814
4632
|
|
|
3815
4633
|
|
|
3816
4634
|
* @example
|
|
3817
|
-
* //
|
|
3818
|
-
* const
|
|
3819
|
-
*
|
|
3820
|
-
*
|
|
3821
|
-
*
|
|
3822
|
-
* 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;
|
|
3823
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
|
+
*/
|
|
3824
4717
|
clone(): TreeMultiMap<K, V, R>;
|
|
3825
4718
|
/**
|
|
3826
4719
|
* Expose comparator for advanced usage/testing (read-only).
|