binary-tree-typed 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +320 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +320 -55
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +320 -55
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +320 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- 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 +191 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -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 +1061 -167
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
- 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 +150 -2
- 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 +171 -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/umd/binary-tree-typed.js +320 -55
- 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/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +88 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
- package/src/data-structures/binary-tree/binary-tree.ts +242 -81
- package/src/data-structures/binary-tree/bst.ts +173 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +948 -36
- package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
- package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
- package/src/data-structures/binary-tree/tree-set.ts +1260 -251
- 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 +100 -12
- package/src/data-structures/heap/heap.ts +149 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
- package/src/data-structures/matrix/matrix.ts +56 -0
- package/src/data-structures/queue/deque.ts +187 -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 +84 -0
- package/src/interfaces/binary-tree.ts +1 -9
|
@@ -209,14 +209,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
|
|
212
|
-
* @example
|
|
213
|
-
* // Check if empty
|
|
214
|
-
* console.log(new TreeMultiMap().isEmpty()); // true;
|
|
215
|
-
*/
|
|
216
|
-
isEmpty(): boolean;
|
|
217
|
-
/**
|
|
218
|
-
* Removes all entries from the map.
|
|
219
|
-
* @remarks Time O(1), Space O(1)
|
|
220
212
|
|
|
221
213
|
|
|
222
214
|
|
|
@@ -252,6 +244,32 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
252
244
|
|
|
253
245
|
|
|
254
246
|
|
|
247
|
+
* @example
|
|
248
|
+
* // Check if empty
|
|
249
|
+
* console.log(new TreeMultiMap().isEmpty()); // true;
|
|
250
|
+
*/
|
|
251
|
+
isEmpty(): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Removes all entries from the map.
|
|
254
|
+
* @remarks Time O(1), Space O(1)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
255
273
|
|
|
256
274
|
|
|
257
275
|
|
|
@@ -375,17 +393,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
375
393
|
|
|
376
394
|
|
|
377
395
|
|
|
378
|
-
* @example
|
|
379
|
-
* // Remove all entries
|
|
380
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
381
|
-
* mm.add(1, 'a');
|
|
382
|
-
* mm.clear();
|
|
383
|
-
* console.log(mm.isEmpty()); // true;
|
|
384
|
-
*/
|
|
385
|
-
clear(): void;
|
|
386
|
-
/**
|
|
387
|
-
* Bucket length for a key (missing => 0).
|
|
388
|
-
* @remarks Time O(log n), Space O(1)
|
|
389
396
|
|
|
390
397
|
|
|
391
398
|
|
|
@@ -412,17 +419,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
412
419
|
|
|
413
420
|
|
|
414
421
|
|
|
415
|
-
* @example
|
|
416
|
-
* // Count values for key
|
|
417
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
418
|
-
* mm.add(1, 'a');
|
|
419
|
-
* mm.add(1, 'b');
|
|
420
|
-
* console.log(mm.count(1)); // 2;
|
|
421
|
-
*/
|
|
422
|
-
count(key: K): number;
|
|
423
|
-
/**
|
|
424
|
-
* Total number of values across all buckets (Σ bucket.length).
|
|
425
|
-
* @remarks Time O(n), Space O(1)
|
|
426
422
|
|
|
427
423
|
|
|
428
424
|
|
|
@@ -450,16 +446,15 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
450
446
|
|
|
451
447
|
|
|
452
448
|
* @example
|
|
453
|
-
* //
|
|
449
|
+
* // Remove all entries
|
|
454
450
|
* const mm = new TreeMultiMap<number, string>();
|
|
455
451
|
* mm.add(1, 'a');
|
|
456
|
-
* mm.
|
|
457
|
-
* mm.
|
|
458
|
-
* console.log(mm.totalSize); // 3;
|
|
452
|
+
* mm.clear();
|
|
453
|
+
* console.log(mm.isEmpty()); // true;
|
|
459
454
|
*/
|
|
460
|
-
|
|
455
|
+
clear(): void;
|
|
461
456
|
/**
|
|
462
|
-
*
|
|
457
|
+
* Bucket length for a key (missing => 0).
|
|
463
458
|
* @remarks Time O(log n), Space O(1)
|
|
464
459
|
|
|
465
460
|
|
|
@@ -494,6 +489,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
494
489
|
|
|
495
490
|
|
|
496
491
|
|
|
492
|
+
* @example
|
|
493
|
+
* // Count values for key
|
|
494
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
495
|
+
* mm.add(1, 'a');
|
|
496
|
+
* mm.add(1, 'b');
|
|
497
|
+
* console.log(mm.count(1)); // 2;
|
|
498
|
+
*/
|
|
499
|
+
count(key: K): number;
|
|
500
|
+
/**
|
|
501
|
+
* Total number of values across all buckets (Σ bucket.length).
|
|
502
|
+
* @remarks Time O(n), Space O(1)
|
|
497
503
|
|
|
498
504
|
|
|
499
505
|
|
|
@@ -527,6 +533,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
527
533
|
|
|
528
534
|
|
|
529
535
|
|
|
536
|
+
* @example
|
|
537
|
+
* // Total number of values
|
|
538
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
539
|
+
* mm.add(1, 'a');
|
|
540
|
+
* mm.add(1, 'b');
|
|
541
|
+
* mm.add(2, 'c');
|
|
542
|
+
* console.log(mm.totalSize); // 3;
|
|
543
|
+
*/
|
|
544
|
+
get totalSize(): number;
|
|
545
|
+
/**
|
|
546
|
+
* Whether the map contains the given key.
|
|
547
|
+
* @remarks Time O(log n), Space O(1)
|
|
530
548
|
|
|
531
549
|
|
|
532
550
|
|
|
@@ -657,19 +675,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
657
675
|
|
|
658
676
|
|
|
659
677
|
|
|
660
|
-
* @example
|
|
661
|
-
* // Check key existence
|
|
662
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
663
|
-
* mm.add(1, 'a');
|
|
664
|
-
* console.log(mm.has(1)); // true;
|
|
665
|
-
* console.log(mm.has(2)); // false;
|
|
666
|
-
*/
|
|
667
|
-
has(key: K): boolean;
|
|
668
|
-
/**
|
|
669
|
-
* Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
|
|
670
|
-
* @remarks Time O(log n), Space O(1)
|
|
671
|
-
|
|
672
|
-
|
|
673
678
|
|
|
674
679
|
|
|
675
680
|
|
|
@@ -778,6 +783,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
778
783
|
|
|
779
784
|
|
|
780
785
|
|
|
786
|
+
* @example
|
|
787
|
+
* // Check key existence
|
|
788
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
789
|
+
* mm.add(1, 'a');
|
|
790
|
+
* console.log(mm.has(1)); // true;
|
|
791
|
+
* console.log(mm.has(2)); // false;
|
|
792
|
+
*/
|
|
793
|
+
has(key: K): boolean;
|
|
794
|
+
/**
|
|
795
|
+
* Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
|
|
796
|
+
* @remarks Time O(log n), Space O(1)
|
|
781
797
|
|
|
782
798
|
|
|
783
799
|
|
|
@@ -864,17 +880,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
864
880
|
|
|
865
881
|
|
|
866
882
|
|
|
867
|
-
* @example
|
|
868
|
-
* // Get values for key
|
|
869
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
870
|
-
* mm.add(1, 'a');
|
|
871
|
-
* mm.add(1, 'b');
|
|
872
|
-
* console.log(mm.get(1)); // ['a', 'b'];
|
|
873
|
-
*/
|
|
874
|
-
get(key: K): V[] | undefined;
|
|
875
|
-
/**
|
|
876
|
-
* Append a single value.
|
|
877
|
-
* @remarks Time O(log n), Space O(1)
|
|
878
883
|
|
|
879
884
|
|
|
880
885
|
|
|
@@ -1028,24 +1033,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1028
1033
|
|
|
1029
1034
|
|
|
1030
1035
|
* @example
|
|
1031
|
-
* //
|
|
1036
|
+
* // Get values for key
|
|
1032
1037
|
* const mm = new TreeMultiMap<number, string>();
|
|
1033
1038
|
* mm.add(1, 'a');
|
|
1034
1039
|
* mm.add(1, 'b');
|
|
1035
|
-
* mm.add(2, 'c');
|
|
1036
1040
|
* console.log(mm.get(1)); // ['a', 'b'];
|
|
1037
1041
|
*/
|
|
1038
|
-
|
|
1042
|
+
get(key: K): V[] | undefined;
|
|
1039
1043
|
/**
|
|
1040
|
-
*
|
|
1041
|
-
* @remarks Time O(log n), Space O(1)
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1044
|
+
* Append a single value.
|
|
1045
|
+
* @remarks Time O(log n), Space O(1)
|
|
1049
1046
|
|
|
1050
1047
|
|
|
1051
1048
|
|
|
@@ -1234,19 +1231,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1234
1231
|
|
|
1235
1232
|
|
|
1236
1233
|
* @example
|
|
1237
|
-
* //
|
|
1234
|
+
* // Add key-value pair
|
|
1238
1235
|
* const mm = new TreeMultiMap<number, string>();
|
|
1239
|
-
* mm.
|
|
1240
|
-
* mm.
|
|
1236
|
+
* mm.add(1, 'a');
|
|
1237
|
+
* mm.add(1, 'b');
|
|
1238
|
+
* mm.add(2, 'c');
|
|
1241
1239
|
* console.log(mm.get(1)); // ['a', 'b'];
|
|
1242
1240
|
*/
|
|
1243
|
-
|
|
1244
|
-
set(key: K, value: V): boolean;
|
|
1241
|
+
add(key: K, value: V): boolean;
|
|
1245
1242
|
/**
|
|
1246
|
-
*
|
|
1247
|
-
* @remarks Time O(log n), Space O(1)
|
|
1248
|
-
|
|
1249
|
-
|
|
1243
|
+
* Alias for compatibility with existing TreeMultiMap semantics.
|
|
1244
|
+
* @remarks Time O(log n), Space O(1) for single value; O(log n + m) for bucket append
|
|
1250
1245
|
|
|
1251
1246
|
|
|
1252
1247
|
|
|
@@ -1441,18 +1436,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1441
1436
|
|
|
1442
1437
|
|
|
1443
1438
|
|
|
1444
|
-
* @example
|
|
1445
|
-
* // Remove key
|
|
1446
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1447
|
-
* mm.add(1, 'a');
|
|
1448
|
-
* mm.add(2, 'b');
|
|
1449
|
-
* mm.delete(1);
|
|
1450
|
-
* console.log(mm.has(1)); // false;
|
|
1451
|
-
*/
|
|
1452
|
-
delete(key: K): boolean;
|
|
1453
|
-
/**
|
|
1454
|
-
* Check if a specific value exists in a key's bucket.
|
|
1455
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1456
1439
|
|
|
1457
1440
|
|
|
1458
1441
|
|
|
@@ -1479,17 +1462,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1479
1462
|
|
|
1480
1463
|
|
|
1481
1464
|
|
|
1482
|
-
* @example
|
|
1483
|
-
* // Check specific key-value
|
|
1484
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1485
|
-
* mm.add(1, 'a');
|
|
1486
|
-
* console.log(mm.hasEntry(1, 'a')); // true;
|
|
1487
|
-
* console.log(mm.hasEntry(1, 'z')); // false;
|
|
1488
|
-
*/
|
|
1489
|
-
hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1490
|
-
/**
|
|
1491
|
-
* Delete a single occurrence of a value from a key's bucket.
|
|
1492
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1493
1465
|
|
|
1494
1466
|
|
|
1495
1467
|
|
|
@@ -1506,6 +1478,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1506
1478
|
|
|
1507
1479
|
|
|
1508
1480
|
|
|
1481
|
+
* @example
|
|
1482
|
+
* // Set values for key
|
|
1483
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
1484
|
+
* mm.set(1, 'a');
|
|
1485
|
+
* mm.set(1, 'b');
|
|
1486
|
+
* console.log(mm.get(1)); // ['a', 'b'];
|
|
1487
|
+
*/
|
|
1488
|
+
set(entry: [K | null | undefined, V[] | undefined] | K | null | undefined, value?: V): boolean;
|
|
1489
|
+
set(key: K, value: V): boolean;
|
|
1490
|
+
/**
|
|
1491
|
+
* Deletes a key and its entire bucket.
|
|
1492
|
+
* @remarks Time O(log n), Space O(1)
|
|
1509
1493
|
|
|
1510
1494
|
|
|
1511
1495
|
|
|
@@ -1516,18 +1500,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1516
1500
|
|
|
1517
1501
|
|
|
1518
1502
|
|
|
1519
|
-
* @example
|
|
1520
|
-
* // Delete specific value
|
|
1521
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1522
|
-
* mm.add(1, 'a');
|
|
1523
|
-
* mm.add(1, 'b');
|
|
1524
|
-
* mm.deleteValue(1, 'a');
|
|
1525
|
-
* console.log(mm.get(1)); // ['b'];
|
|
1526
|
-
*/
|
|
1527
|
-
deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1528
|
-
/**
|
|
1529
|
-
* Delete all occurrences of a value from a key's bucket.
|
|
1530
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1531
1503
|
|
|
1532
1504
|
|
|
1533
1505
|
|
|
@@ -1554,24 +1526,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1554
1526
|
|
|
1555
1527
|
|
|
1556
1528
|
|
|
1557
|
-
* @example
|
|
1558
|
-
* // Delete all matching values
|
|
1559
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1560
|
-
* mm.add(1, 'a');
|
|
1561
|
-
* mm.add(1, 'a');
|
|
1562
|
-
* mm.add(1, 'b');
|
|
1563
|
-
* const count = mm.deleteValues(1, 'a');
|
|
1564
|
-
* console.log(count); // 2;
|
|
1565
|
-
*/
|
|
1566
|
-
deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
|
|
1567
|
-
/**
|
|
1568
|
-
* Iterates over all entries as [key, bucket] pairs.
|
|
1569
|
-
* @remarks Time O(n), Space O(1)
|
|
1570
|
-
*/
|
|
1571
|
-
[Symbol.iterator](): Iterator<[K, V[]]>;
|
|
1572
|
-
/**
|
|
1573
|
-
* Iterates over all keys.
|
|
1574
|
-
* @remarks Time O(n), Space O(1)
|
|
1575
1529
|
|
|
1576
1530
|
|
|
1577
1531
|
|
|
@@ -1730,17 +1684,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1730
1684
|
|
|
1731
1685
|
|
|
1732
1686
|
|
|
1733
|
-
* @example
|
|
1734
|
-
* // Iterate keys
|
|
1735
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1736
|
-
* mm.add(3, 'c');
|
|
1737
|
-
* mm.add(1, 'a');
|
|
1738
|
-
* console.log([...mm.keys()]); // [1, 3];
|
|
1739
|
-
*/
|
|
1740
|
-
keys(): IterableIterator<K>;
|
|
1741
|
-
/**
|
|
1742
|
-
* Iterates over all buckets.
|
|
1743
|
-
* @remarks Time O(n), Space O(1)
|
|
1744
1687
|
|
|
1745
1688
|
|
|
1746
1689
|
|
|
@@ -1785,6 +1728,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1785
1728
|
|
|
1786
1729
|
|
|
1787
1730
|
|
|
1731
|
+
* @example
|
|
1732
|
+
* // Remove key
|
|
1733
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
1734
|
+
* mm.add(1, 'a');
|
|
1735
|
+
* mm.add(2, 'b');
|
|
1736
|
+
* mm.delete(1);
|
|
1737
|
+
* console.log(mm.has(1)); // false;
|
|
1738
|
+
*/
|
|
1739
|
+
delete(key: K): boolean;
|
|
1740
|
+
/**
|
|
1741
|
+
* Check if a specific value exists in a key's bucket.
|
|
1742
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1788
1743
|
|
|
1789
1744
|
|
|
1790
1745
|
|
|
@@ -1818,6 +1773,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1818
1773
|
|
|
1819
1774
|
|
|
1820
1775
|
|
|
1776
|
+
* @example
|
|
1777
|
+
* // Check specific key-value
|
|
1778
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
1779
|
+
* mm.add(1, 'a');
|
|
1780
|
+
* console.log(mm.hasEntry(1, 'a')); // true;
|
|
1781
|
+
* console.log(mm.hasEntry(1, 'z')); // false;
|
|
1782
|
+
*/
|
|
1783
|
+
hasEntry(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1784
|
+
/**
|
|
1785
|
+
* Delete a single occurrence of a value from a key's bucket.
|
|
1786
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1821
1787
|
|
|
1822
1788
|
|
|
1823
1789
|
|
|
@@ -1848,6 +1814,823 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1848
1814
|
|
|
1849
1815
|
|
|
1850
1816
|
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
* @example
|
|
1821
|
+
* // Delete specific value
|
|
1822
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
1823
|
+
* mm.add(1, 'a');
|
|
1824
|
+
* mm.add(1, 'b');
|
|
1825
|
+
* mm.deleteValue(1, 'a');
|
|
1826
|
+
* console.log(mm.get(1)); // ['b'];
|
|
1827
|
+
*/
|
|
1828
|
+
deleteValue(key: K, value: V, eq?: (a: V, b: V) => boolean): boolean;
|
|
1829
|
+
/**
|
|
1830
|
+
* Delete all occurrences of a value from a key's bucket.
|
|
1831
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1832
|
+
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
* @example
|
|
1866
|
+
* // Delete all matching values
|
|
1867
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
1868
|
+
* mm.add(1, 'a');
|
|
1869
|
+
* mm.add(1, 'a');
|
|
1870
|
+
* mm.add(1, 'b');
|
|
1871
|
+
* const count = mm.deleteValues(1, 'a');
|
|
1872
|
+
* console.log(count); // 2;
|
|
1873
|
+
*/
|
|
1874
|
+
deleteValues(key: K, value: V, eq?: (a: V, b: V) => boolean): number;
|
|
1875
|
+
/**
|
|
1876
|
+
* Iterates over all entries as [key, bucket] pairs.
|
|
1877
|
+
* @remarks Time O(n), Space O(1)
|
|
1878
|
+
*/
|
|
1879
|
+
[Symbol.iterator](): Iterator<[K, V[]]>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Iterates over all keys.
|
|
1882
|
+
* @remarks Time O(n), Space O(1)
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
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
|
+
* @example
|
|
2077
|
+
* // Iterate keys
|
|
2078
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2079
|
+
* mm.add(3, 'c');
|
|
2080
|
+
* mm.add(1, 'a');
|
|
2081
|
+
* console.log([...mm.keys()]); // [1, 3];
|
|
2082
|
+
*/
|
|
2083
|
+
keys(): IterableIterator<K>;
|
|
2084
|
+
/**
|
|
2085
|
+
* Iterates over all buckets.
|
|
2086
|
+
* @remarks Time O(n), Space O(1)
|
|
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
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
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
|
+
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
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
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
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
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
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
|
+
* @example
|
|
2281
|
+
* // Iterate value arrays
|
|
2282
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2283
|
+
* mm.add(1, 'a');
|
|
2284
|
+
* mm.add(1, 'b');
|
|
2285
|
+
* console.log([...mm.values()]); // [['a', 'b']];
|
|
2286
|
+
*/
|
|
2287
|
+
values(): IterableIterator<V[]>;
|
|
2288
|
+
/**
|
|
2289
|
+
* Iterate over all `[key, values[]]` entries (Map-compatible).
|
|
2290
|
+
* @remarks Time O(n), Space O(1) per step.
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
|
|
2296
|
+
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
* @example
|
|
2300
|
+
* // Iterate over entries
|
|
2301
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2302
|
+
* mm.set(1, 'a');
|
|
2303
|
+
* mm.set(1, 'b');
|
|
2304
|
+
* mm.set(2, 'c');
|
|
2305
|
+
* console.log([...mm.entries()]); // [
|
|
2306
|
+
* // [1, ['a', 'b']],
|
|
2307
|
+
* // [2, ['c']]
|
|
2308
|
+
* // ];
|
|
2309
|
+
*/
|
|
2310
|
+
entries(): IterableIterator<[K, V[]]>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Iterates over all entries for a specific key.
|
|
2313
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2347
|
+
* @example
|
|
2348
|
+
* // Get entries for key
|
|
2349
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2350
|
+
* mm.add(1, 'a');
|
|
2351
|
+
* mm.add(1, 'b');
|
|
2352
|
+
* console.log([...mm.entriesOf(1)]); // [[1, 'a'], [1, 'b']];
|
|
2353
|
+
*/
|
|
2354
|
+
entriesOf(key: K): IterableIterator<[K, V]>;
|
|
2355
|
+
/**
|
|
2356
|
+
* Iterates over all values for a specific key.
|
|
2357
|
+
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
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
|
+
* @example
|
|
2392
|
+
* // Get flat values for key
|
|
2393
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2394
|
+
* mm.add(1, 'a');
|
|
2395
|
+
* mm.add(1, 'b');
|
|
2396
|
+
* console.log([...mm.valuesOf(1)]); // ['a', 'b'];
|
|
2397
|
+
*/
|
|
2398
|
+
valuesOf(key: K): IterableIterator<V>;
|
|
2399
|
+
/**
|
|
2400
|
+
* Iterates over all [key, value] pairs (flattened from buckets).
|
|
2401
|
+
* @remarks Time O(T), Space O(1) where T is totalSize
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
|
|
2406
|
+
|
|
2407
|
+
|
|
2408
|
+
|
|
2409
|
+
|
|
2410
|
+
|
|
2411
|
+
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
* @example
|
|
2436
|
+
* // All key-value pairs flattened
|
|
2437
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2438
|
+
* mm.add(1, 'a');
|
|
2439
|
+
* mm.add(1, 'b');
|
|
2440
|
+
* mm.add(2, 'c');
|
|
2441
|
+
* console.log([...mm.flatEntries()]); // [[1, 'a'], [1, 'b'], [2, 'c']];
|
|
2442
|
+
*/
|
|
2443
|
+
flatEntries(): IterableIterator<[K, V]>;
|
|
2444
|
+
/**
|
|
2445
|
+
* Returns the entry with the smallest key.
|
|
2446
|
+
* @remarks Time O(log n), Space O(1)
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
|
|
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
|
+
|
|
2491
|
+
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
|
|
2502
|
+
|
|
2503
|
+
|
|
2504
|
+
|
|
2505
|
+
|
|
2506
|
+
|
|
2507
|
+
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
* @example
|
|
2524
|
+
* // First entry
|
|
2525
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2526
|
+
* mm.add(3, 'c');
|
|
2527
|
+
* mm.add(1, 'a');
|
|
2528
|
+
* console.log(mm.first()?.[0]); // 1;
|
|
2529
|
+
*/
|
|
2530
|
+
first(): [K, V[]] | undefined;
|
|
2531
|
+
/**
|
|
2532
|
+
* Returns the entry with the largest key.
|
|
2533
|
+
* @remarks Time O(log n), Space O(1)
|
|
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
|
+
* @example
|
|
2611
|
+
* // Last entry
|
|
2612
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2613
|
+
* mm.add(1, 'a');
|
|
2614
|
+
* mm.add(3, 'c');
|
|
2615
|
+
* console.log(mm.last()?.[0]); // 3;
|
|
2616
|
+
*/
|
|
2617
|
+
last(): [K, V[]] | undefined;
|
|
2618
|
+
/**
|
|
2619
|
+
* Removes and returns the entry with the smallest key.
|
|
2620
|
+
* @remarks Time O(log n), Space O(1)
|
|
2621
|
+
|
|
2622
|
+
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
|
|
2626
|
+
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
|
|
2630
|
+
|
|
2631
|
+
|
|
2632
|
+
|
|
2633
|
+
|
|
1851
2634
|
|
|
1852
2635
|
|
|
1853
2636
|
|
|
@@ -1869,6 +2652,23 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1869
2652
|
|
|
1870
2653
|
|
|
1871
2654
|
|
|
2655
|
+
* @example
|
|
2656
|
+
* // Remove and return first
|
|
2657
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
2658
|
+
* mm.add(2, 'b');
|
|
2659
|
+
* mm.add(1, 'a');
|
|
2660
|
+
* const first = mm.pollFirst();
|
|
2661
|
+
* console.log(first?.[0]); // 1;
|
|
2662
|
+
* console.log(mm.has(1)); // false;
|
|
2663
|
+
*/
|
|
2664
|
+
pollFirst(): [K, V[]] | undefined;
|
|
2665
|
+
/**
|
|
2666
|
+
* Removes and returns the entry with the largest key.
|
|
2667
|
+
* @remarks Time O(log n), Space O(1)
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
1872
2672
|
|
|
1873
2673
|
|
|
1874
2674
|
|
|
@@ -1900,16 +2700,74 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1900
2700
|
|
|
1901
2701
|
|
|
1902
2702
|
* @example
|
|
1903
|
-
* //
|
|
2703
|
+
* // Remove and return last
|
|
1904
2704
|
* const mm = new TreeMultiMap<number, string>();
|
|
1905
2705
|
* mm.add(1, 'a');
|
|
1906
|
-
* mm.add(
|
|
1907
|
-
*
|
|
2706
|
+
* mm.add(3, 'c');
|
|
2707
|
+
* const last = mm.pollLast();
|
|
2708
|
+
* console.log(last?.[0]); // 3;
|
|
1908
2709
|
*/
|
|
1909
|
-
|
|
2710
|
+
pollLast(): [K, V[]] | undefined;
|
|
1910
2711
|
/**
|
|
1911
|
-
*
|
|
1912
|
-
* @remarks Time O(log n
|
|
2712
|
+
* Returns the entry with the smallest key >= given key.
|
|
2713
|
+
* @remarks Time O(log n), Space O(1)
|
|
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
|
+
|
|
1913
2771
|
|
|
1914
2772
|
|
|
1915
2773
|
|
|
@@ -1936,17 +2794,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1936
2794
|
|
|
1937
2795
|
|
|
1938
2796
|
|
|
1939
|
-
* @example
|
|
1940
|
-
* // Get entries for key
|
|
1941
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1942
|
-
* mm.add(1, 'a');
|
|
1943
|
-
* mm.add(1, 'b');
|
|
1944
|
-
* console.log([...mm.entriesOf(1)]); // [[1, 'a'], [1, 'b']];
|
|
1945
|
-
*/
|
|
1946
|
-
entriesOf(key: K): IterableIterator<[K, V]>;
|
|
1947
|
-
/**
|
|
1948
|
-
* Iterates over all values for a specific key.
|
|
1949
|
-
* @remarks Time O(log n + m), Space O(1) where m is bucket size
|
|
1950
2797
|
|
|
1951
2798
|
|
|
1952
2799
|
|
|
@@ -1973,17 +2820,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
1973
2820
|
|
|
1974
2821
|
|
|
1975
2822
|
|
|
1976
|
-
* @example
|
|
1977
|
-
* // Get flat values for key
|
|
1978
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
1979
|
-
* mm.add(1, 'a');
|
|
1980
|
-
* mm.add(1, 'b');
|
|
1981
|
-
* console.log([...mm.valuesOf(1)]); // ['a', 'b'];
|
|
1982
|
-
*/
|
|
1983
|
-
valuesOf(key: K): IterableIterator<V>;
|
|
1984
|
-
/**
|
|
1985
|
-
* Iterates over all [key, value] pairs (flattened from buckets).
|
|
1986
|
-
* @remarks Time O(T), Space O(1) where T is totalSize
|
|
1987
2823
|
|
|
1988
2824
|
|
|
1989
2825
|
|
|
@@ -2010,19 +2846,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2010
2846
|
|
|
2011
2847
|
|
|
2012
2848
|
|
|
2013
|
-
* @example
|
|
2014
|
-
* // All key-value pairs flattened
|
|
2015
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2016
|
-
* mm.add(1, 'a');
|
|
2017
|
-
* mm.add(1, 'b');
|
|
2018
|
-
* mm.add(2, 'c');
|
|
2019
|
-
* console.log([...mm.flatEntries()]); // [[1, 'a'], [1, 'b'], [2, 'c']];
|
|
2020
|
-
*/
|
|
2021
|
-
flatEntries(): IterableIterator<[K, V]>;
|
|
2022
|
-
/**
|
|
2023
|
-
* Returns the entry with the smallest key.
|
|
2024
|
-
* @remarks Time O(log n), Space O(1)
|
|
2025
|
-
|
|
2026
2849
|
|
|
2027
2850
|
|
|
2028
2851
|
|
|
@@ -2085,15 +2908,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2085
2908
|
|
|
2086
2909
|
|
|
2087
2910
|
* @example
|
|
2088
|
-
* //
|
|
2911
|
+
* // Least key ≥ target
|
|
2089
2912
|
* const mm = new TreeMultiMap<number, string>();
|
|
2090
|
-
* mm.add(
|
|
2091
|
-
* mm.add(
|
|
2092
|
-
*
|
|
2913
|
+
* mm.add(10, 'a');
|
|
2914
|
+
* mm.add(20, 'b');
|
|
2915
|
+
* mm.add(30, 'c');
|
|
2916
|
+
* console.log(mm.ceiling(15)?.[0]); // 20;
|
|
2093
2917
|
*/
|
|
2094
|
-
|
|
2918
|
+
ceiling(key: K): [K, V[]] | undefined;
|
|
2095
2919
|
/**
|
|
2096
|
-
* Returns the entry with the largest key.
|
|
2920
|
+
* Returns the entry with the largest key <= given key.
|
|
2097
2921
|
* @remarks Time O(log n), Space O(1)
|
|
2098
2922
|
|
|
2099
2923
|
|
|
@@ -2157,18 +2981,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2157
2981
|
|
|
2158
2982
|
|
|
2159
2983
|
|
|
2160
|
-
* @example
|
|
2161
|
-
* // Last entry
|
|
2162
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2163
|
-
* mm.add(1, 'a');
|
|
2164
|
-
* mm.add(3, 'c');
|
|
2165
|
-
* console.log(mm.last()?.[0]); // 3;
|
|
2166
|
-
*/
|
|
2167
|
-
last(): [K, V[]] | undefined;
|
|
2168
|
-
/**
|
|
2169
|
-
* Removes and returns the entry with the smallest key.
|
|
2170
|
-
* @remarks Time O(log n), Space O(1)
|
|
2171
|
-
|
|
2172
2984
|
|
|
2173
2985
|
|
|
2174
2986
|
|
|
@@ -2195,20 +3007,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2195
3007
|
|
|
2196
3008
|
|
|
2197
3009
|
|
|
2198
|
-
* @example
|
|
2199
|
-
* // Remove and return first
|
|
2200
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2201
|
-
* mm.add(2, 'b');
|
|
2202
|
-
* mm.add(1, 'a');
|
|
2203
|
-
* const first = mm.pollFirst();
|
|
2204
|
-
* console.log(first?.[0]); // 1;
|
|
2205
|
-
* console.log(mm.has(1)); // false;
|
|
2206
|
-
*/
|
|
2207
|
-
pollFirst(): [K, V[]] | undefined;
|
|
2208
|
-
/**
|
|
2209
|
-
* Removes and returns the entry with the largest key.
|
|
2210
|
-
* @remarks Time O(log n), Space O(1)
|
|
2211
|
-
|
|
2212
3010
|
|
|
2213
3011
|
|
|
2214
3012
|
|
|
@@ -2235,19 +3033,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2235
3033
|
|
|
2236
3034
|
|
|
2237
3035
|
|
|
2238
|
-
* @example
|
|
2239
|
-
* // Remove and return last
|
|
2240
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2241
|
-
* mm.add(1, 'a');
|
|
2242
|
-
* mm.add(3, 'c');
|
|
2243
|
-
* const last = mm.pollLast();
|
|
2244
|
-
* console.log(last?.[0]); // 3;
|
|
2245
|
-
*/
|
|
2246
|
-
pollLast(): [K, V[]] | undefined;
|
|
2247
|
-
/**
|
|
2248
|
-
* Returns the entry with the smallest key >= given key.
|
|
2249
|
-
* @remarks Time O(log n), Space O(1)
|
|
2250
|
-
|
|
2251
3036
|
|
|
2252
3037
|
|
|
2253
3038
|
|
|
@@ -2309,6 +3094,94 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2309
3094
|
|
|
2310
3095
|
|
|
2311
3096
|
|
|
3097
|
+
|
|
3098
|
+
|
|
3099
|
+
|
|
3100
|
+
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
|
|
3104
|
+
|
|
3105
|
+
|
|
3106
|
+
|
|
3107
|
+
|
|
3108
|
+
|
|
3109
|
+
|
|
3110
|
+
|
|
3111
|
+
|
|
3112
|
+
|
|
3113
|
+
|
|
3114
|
+
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
|
|
3118
|
+
* @example
|
|
3119
|
+
* // Greatest key ≤ target
|
|
3120
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
3121
|
+
* mm.add(10, 'a');
|
|
3122
|
+
* mm.add(20, 'b');
|
|
3123
|
+
* mm.add(30, 'c');
|
|
3124
|
+
* console.log(mm.floor(25)?.[0]); // 20;
|
|
3125
|
+
*/
|
|
3126
|
+
floor(key: K): [K, V[]] | undefined;
|
|
3127
|
+
/**
|
|
3128
|
+
* Returns the entry with the smallest key > given key.
|
|
3129
|
+
* @remarks Time O(log n), Space O(1)
|
|
3130
|
+
|
|
3131
|
+
|
|
3132
|
+
|
|
3133
|
+
|
|
3134
|
+
|
|
3135
|
+
|
|
3136
|
+
|
|
3137
|
+
|
|
3138
|
+
|
|
3139
|
+
|
|
3140
|
+
|
|
3141
|
+
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
|
|
3145
|
+
|
|
3146
|
+
|
|
3147
|
+
|
|
3148
|
+
|
|
3149
|
+
|
|
3150
|
+
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
|
|
3154
|
+
|
|
3155
|
+
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
|
|
3161
|
+
|
|
3162
|
+
|
|
3163
|
+
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
|
|
3167
|
+
|
|
3168
|
+
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
|
|
3183
|
+
|
|
3184
|
+
|
|
2312
3185
|
|
|
2313
3186
|
|
|
2314
3187
|
|
|
@@ -2409,16 +3282,15 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2409
3282
|
|
|
2410
3283
|
|
|
2411
3284
|
* @example
|
|
2412
|
-
* // Least key
|
|
3285
|
+
* // Least key > target
|
|
2413
3286
|
* const mm = new TreeMultiMap<number, string>();
|
|
2414
3287
|
* mm.add(10, 'a');
|
|
2415
3288
|
* mm.add(20, 'b');
|
|
2416
|
-
* mm.
|
|
2417
|
-
* console.log(mm.ceiling(15)?.[0]); // 20;
|
|
3289
|
+
* console.log(mm.higher(10)?.[0]); // 20;
|
|
2418
3290
|
*/
|
|
2419
|
-
|
|
3291
|
+
higher(key: K): [K, V[]] | undefined;
|
|
2420
3292
|
/**
|
|
2421
|
-
* Returns the entry with the largest key
|
|
3293
|
+
* Returns the entry with the largest key < given key.
|
|
2422
3294
|
* @remarks Time O(log n), Space O(1)
|
|
2423
3295
|
|
|
2424
3296
|
|
|
@@ -2566,13 +3438,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2566
3438
|
|
|
2567
3439
|
|
|
2568
3440
|
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
3441
|
|
|
2577
3442
|
|
|
2578
3443
|
|
|
@@ -2582,30 +3447,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2582
3447
|
|
|
2583
3448
|
|
|
2584
3449
|
* @example
|
|
2585
|
-
* // Greatest key
|
|
3450
|
+
* // Greatest key < target
|
|
2586
3451
|
* const mm = new TreeMultiMap<number, string>();
|
|
2587
3452
|
* mm.add(10, 'a');
|
|
2588
3453
|
* mm.add(20, 'b');
|
|
2589
|
-
* mm.
|
|
2590
|
-
* console.log(mm.floor(25)?.[0]); // 20;
|
|
3454
|
+
* console.log(mm.lower(20)?.[0]); // 10;
|
|
2591
3455
|
*/
|
|
2592
|
-
|
|
3456
|
+
lower(key: K): [K, V[]] | undefined;
|
|
2593
3457
|
/**
|
|
2594
|
-
*
|
|
2595
|
-
* @remarks Time O(
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
3458
|
+
* Prints the internal tree structure (for debugging).
|
|
3459
|
+
* @remarks Time O(n), Space O(n)
|
|
2609
3460
|
|
|
2610
3461
|
|
|
2611
3462
|
|
|
@@ -2719,18 +3570,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2719
3570
|
|
|
2720
3571
|
|
|
2721
3572
|
|
|
2722
|
-
* @example
|
|
2723
|
-
* // Least key > target
|
|
2724
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2725
|
-
* mm.add(10, 'a');
|
|
2726
|
-
* mm.add(20, 'b');
|
|
2727
|
-
* console.log(mm.higher(10)?.[0]); // 20;
|
|
2728
|
-
*/
|
|
2729
|
-
higher(key: K): [K, V[]] | undefined;
|
|
2730
|
-
/**
|
|
2731
|
-
* Returns the entry with the largest key < given key.
|
|
2732
|
-
* @remarks Time O(log n), Space O(1)
|
|
2733
|
-
|
|
2734
3573
|
|
|
2735
3574
|
|
|
2736
3575
|
|
|
@@ -2811,6 +3650,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2811
3650
|
|
|
2812
3651
|
|
|
2813
3652
|
|
|
3653
|
+
* @example
|
|
3654
|
+
* // Display tree
|
|
3655
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
3656
|
+
* mm.add(1, 'a');
|
|
3657
|
+
* expect(() => mm.print()).not.toThrow();
|
|
3658
|
+
*/
|
|
3659
|
+
print(): void;
|
|
3660
|
+
/**
|
|
3661
|
+
* Executes a callback for each entry.
|
|
3662
|
+
* @remarks Time O(n), Space O(1)
|
|
2814
3663
|
|
|
2815
3664
|
|
|
2816
3665
|
|
|
@@ -2856,17 +3705,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
2856
3705
|
|
|
2857
3706
|
|
|
2858
3707
|
|
|
2859
|
-
* @example
|
|
2860
|
-
* // Greatest key < target
|
|
2861
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
2862
|
-
* mm.add(10, 'a');
|
|
2863
|
-
* mm.add(20, 'b');
|
|
2864
|
-
* console.log(mm.lower(20)?.[0]); // 10;
|
|
2865
|
-
*/
|
|
2866
|
-
lower(key: K): [K, V[]] | undefined;
|
|
2867
|
-
/**
|
|
2868
|
-
* Prints the internal tree structure (for debugging).
|
|
2869
|
-
* @remarks Time O(n), Space O(n)
|
|
2870
3708
|
|
|
2871
3709
|
|
|
2872
3710
|
|
|
@@ -3015,6 +3853,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3015
3853
|
|
|
3016
3854
|
|
|
3017
3855
|
|
|
3856
|
+
* @example
|
|
3857
|
+
* // Iterate entries
|
|
3858
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
3859
|
+
* mm.add(1, 'a');
|
|
3860
|
+
* mm.add(2, 'b');
|
|
3861
|
+
* const keys: number[] = [];
|
|
3862
|
+
* mm.forEach((v, k) => keys.push(k));
|
|
3863
|
+
* console.log(keys); // [1, 2];
|
|
3864
|
+
*/
|
|
3865
|
+
forEach(callback: (value: V[], key: K, map: this) => void): void;
|
|
3866
|
+
/**
|
|
3867
|
+
* Creates a new map with entries that pass the predicate.
|
|
3868
|
+
* @remarks Time O(n), Space O(n)
|
|
3018
3869
|
|
|
3019
3870
|
|
|
3020
3871
|
|
|
@@ -3025,16 +3876,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3025
3876
|
|
|
3026
3877
|
|
|
3027
3878
|
|
|
3028
|
-
* @example
|
|
3029
|
-
* // Display tree
|
|
3030
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3031
|
-
* mm.add(1, 'a');
|
|
3032
|
-
* expect(() => mm.print()).not.toThrow();
|
|
3033
|
-
*/
|
|
3034
|
-
print(): void;
|
|
3035
|
-
/**
|
|
3036
|
-
* Executes a callback for each entry.
|
|
3037
|
-
* @remarks Time O(n), Space O(1)
|
|
3038
3879
|
|
|
3039
3880
|
|
|
3040
3881
|
|
|
@@ -3193,19 +4034,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3193
4034
|
|
|
3194
4035
|
|
|
3195
4036
|
|
|
3196
|
-
* @example
|
|
3197
|
-
* // Iterate entries
|
|
3198
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3199
|
-
* mm.add(1, 'a');
|
|
3200
|
-
* mm.add(2, 'b');
|
|
3201
|
-
* const keys: number[] = [];
|
|
3202
|
-
* mm.forEach((v, k) => keys.push(k));
|
|
3203
|
-
* console.log(keys); // [1, 2];
|
|
3204
|
-
*/
|
|
3205
|
-
forEach(callback: (value: V[], key: K, map: this) => void): void;
|
|
3206
|
-
/**
|
|
3207
|
-
* Creates a new map with entries that pass the predicate.
|
|
3208
|
-
* @remarks Time O(n), Space O(n)
|
|
3209
4037
|
|
|
3210
4038
|
|
|
3211
4039
|
|
|
@@ -3231,6 +4059,19 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3231
4059
|
|
|
3232
4060
|
|
|
3233
4061
|
|
|
4062
|
+
* @example
|
|
4063
|
+
* // Filter entries
|
|
4064
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
4065
|
+
* mm.add(1, 'a');
|
|
4066
|
+
* mm.add(2, 'b');
|
|
4067
|
+
* mm.add(3, 'c');
|
|
4068
|
+
* const filtered = mm.filter((v, k) => k > 1);
|
|
4069
|
+
* console.log([...filtered.keys()]); // [2, 3];
|
|
4070
|
+
*/
|
|
4071
|
+
filter(predicate: (value: V[], key: K, map: this) => boolean): TreeMultiMap<K, V, R>;
|
|
4072
|
+
/**
|
|
4073
|
+
* Creates a new map by transforming each entry.
|
|
4074
|
+
* @remarks Time O(n log n), Space O(n)
|
|
3234
4075
|
|
|
3235
4076
|
|
|
3236
4077
|
|
|
@@ -3364,19 +4205,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3364
4205
|
|
|
3365
4206
|
|
|
3366
4207
|
|
|
3367
|
-
* @example
|
|
3368
|
-
* // Filter entries
|
|
3369
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3370
|
-
* mm.add(1, 'a');
|
|
3371
|
-
* mm.add(2, 'b');
|
|
3372
|
-
* mm.add(3, 'c');
|
|
3373
|
-
* const filtered = mm.filter((v, k) => k > 1);
|
|
3374
|
-
* console.log([...filtered.keys()]); // [2, 3];
|
|
3375
|
-
*/
|
|
3376
|
-
filter(predicate: (value: V[], key: K, map: this) => boolean): TreeMultiMap<K, V, R>;
|
|
3377
|
-
/**
|
|
3378
|
-
* Creates a new map by transforming each entry.
|
|
3379
|
-
* @remarks Time O(n log n), Space O(n)
|
|
3380
4208
|
|
|
3381
4209
|
|
|
3382
4210
|
|
|
@@ -3437,6 +4265,17 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3437
4265
|
|
|
3438
4266
|
|
|
3439
4267
|
|
|
4268
|
+
* @example
|
|
4269
|
+
* // Transform values
|
|
4270
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
4271
|
+
* mm.add(1, 'a');
|
|
4272
|
+
* const mapped = mm.map((v, k) => [k, v.map(s => s.toUpperCase())] as [number, string[]]);
|
|
4273
|
+
* console.log(mapped.get(1)); // ['A'];
|
|
4274
|
+
*/
|
|
4275
|
+
map<V2>(mapper: (value: V[], key: K, map: this) => [K, V2[]]): TreeMultiMap<K, V2, R>;
|
|
4276
|
+
/**
|
|
4277
|
+
* Reduces all entries to a single value.
|
|
4278
|
+
* @remarks Time O(n), Space O(1)
|
|
3440
4279
|
|
|
3441
4280
|
|
|
3442
4281
|
|
|
@@ -3535,17 +4374,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3535
4374
|
|
|
3536
4375
|
|
|
3537
4376
|
|
|
3538
|
-
* @example
|
|
3539
|
-
* // Transform values
|
|
3540
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3541
|
-
* mm.add(1, 'a');
|
|
3542
|
-
* const mapped = mm.map((v, k) => [k, v.map(s => s.toUpperCase())] as [number, string[]]);
|
|
3543
|
-
* console.log(mapped.get(1)); // ['A'];
|
|
3544
|
-
*/
|
|
3545
|
-
map<V2>(mapper: (value: V[], key: K, map: this) => [K, V2[]]): TreeMultiMap<K, V2, R>;
|
|
3546
|
-
/**
|
|
3547
|
-
* Reduces all entries to a single value.
|
|
3548
|
-
* @remarks Time O(n), Space O(1)
|
|
3549
4377
|
|
|
3550
4378
|
|
|
3551
4379
|
|
|
@@ -3641,6 +4469,18 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3641
4469
|
|
|
3642
4470
|
|
|
3643
4471
|
|
|
4472
|
+
* @example
|
|
4473
|
+
* // Aggregate
|
|
4474
|
+
* const mm = new TreeMultiMap<number, number>();
|
|
4475
|
+
* mm.add(1, 10);
|
|
4476
|
+
* mm.add(2, 20);
|
|
4477
|
+
* const sum = mm.reduce((acc, v) => acc + v.reduce((a, b) => a + b, 0), 0);
|
|
4478
|
+
* console.log(sum); // 30;
|
|
4479
|
+
*/
|
|
4480
|
+
reduce<U>(callback: (accumulator: U, value: V[], key: K, map: this) => U, initialValue: U): U;
|
|
4481
|
+
/**
|
|
4482
|
+
* Sets multiple entries at once.
|
|
4483
|
+
* @remarks Time O(m log n), Space O(m) where m is input size
|
|
3644
4484
|
|
|
3645
4485
|
|
|
3646
4486
|
|
|
@@ -3704,18 +4544,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3704
4544
|
|
|
3705
4545
|
|
|
3706
4546
|
|
|
3707
|
-
* @example
|
|
3708
|
-
* // Aggregate
|
|
3709
|
-
* const mm = new TreeMultiMap<number, number>();
|
|
3710
|
-
* mm.add(1, 10);
|
|
3711
|
-
* mm.add(2, 20);
|
|
3712
|
-
* const sum = mm.reduce((acc, v) => acc + v.reduce((a, b) => a + b, 0), 0);
|
|
3713
|
-
* console.log(sum); // 30;
|
|
3714
|
-
*/
|
|
3715
|
-
reduce<U>(callback: (accumulator: U, value: V[], key: K, map: this) => U, initialValue: U): U;
|
|
3716
|
-
/**
|
|
3717
|
-
* Sets multiple entries at once.
|
|
3718
|
-
* @remarks Time O(m log n), Space O(m) where m is input size
|
|
3719
4547
|
|
|
3720
4548
|
|
|
3721
4549
|
|
|
@@ -3838,6 +4666,16 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3838
4666
|
|
|
3839
4667
|
|
|
3840
4668
|
|
|
4669
|
+
* @example
|
|
4670
|
+
* // Set multiple entries
|
|
4671
|
+
* const mm = new TreeMultiMap<number, string>();
|
|
4672
|
+
* mm.setMany([[1, ['a']], [2, ['b']]]);
|
|
4673
|
+
* console.log(mm.size); // 2;
|
|
4674
|
+
*/
|
|
4675
|
+
setMany(keysNodesEntriesOrRaws: Iterable<K | [K | null | undefined, V[] | undefined]>): boolean[];
|
|
4676
|
+
/**
|
|
4677
|
+
* Searches for entries within a key range.
|
|
4678
|
+
* @remarks Time O(log n + k), Space O(k) where k is result size
|
|
3841
4679
|
|
|
3842
4680
|
|
|
3843
4681
|
|
|
@@ -3866,16 +4704,6 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
3866
4704
|
|
|
3867
4705
|
|
|
3868
4706
|
|
|
3869
|
-
* @example
|
|
3870
|
-
* // Set multiple entries
|
|
3871
|
-
* const mm = new TreeMultiMap<number, string>();
|
|
3872
|
-
* mm.setMany([[1, ['a']], [2, ['b']]]);
|
|
3873
|
-
* console.log(mm.size); // 2;
|
|
3874
|
-
*/
|
|
3875
|
-
setMany(keysNodesEntriesOrRaws: Iterable<K | [K | null | undefined, V[] | undefined]>): boolean[];
|
|
3876
|
-
/**
|
|
3877
|
-
* Searches for entries within a key range.
|
|
3878
|
-
* @remarks Time O(log n + k), Space O(k) where k is result size
|
|
3879
4707
|
|
|
3880
4708
|
|
|
3881
4709
|
|
|
@@ -4196,8 +5024,22 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
4196
5024
|
/**
|
|
4197
5025
|
* Get elements by rank range
|
|
4198
5026
|
|
|
5027
|
+
|
|
5028
|
+
|
|
5029
|
+
|
|
5030
|
+
|
|
5031
|
+
|
|
5032
|
+
|
|
5033
|
+
|
|
5034
|
+
|
|
5035
|
+
|
|
5036
|
+
|
|
5037
|
+
|
|
5038
|
+
|
|
5039
|
+
|
|
5040
|
+
|
|
4199
5041
|
* @example
|
|
4200
|
-
* // Pagination
|
|
5042
|
+
* // Pagination by position in tree order
|
|
4201
5043
|
* const tree = new TreeMultiMap<number>(
|
|
4202
5044
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
4203
5045
|
* { enableOrderStatistic: true }
|
|
@@ -4218,6 +5060,41 @@ export declare class TreeMultiMap<K = any, V = any, R = any> implements Iterable
|
|
|
4218
5060
|
|
|
4219
5061
|
|
|
4220
5062
|
|
|
5063
|
+
|
|
5064
|
+
|
|
5065
|
+
|
|
5066
|
+
|
|
5067
|
+
|
|
5068
|
+
|
|
5069
|
+
|
|
5070
|
+
|
|
5071
|
+
|
|
5072
|
+
|
|
5073
|
+
|
|
5074
|
+
|
|
5075
|
+
|
|
5076
|
+
|
|
5077
|
+
|
|
5078
|
+
|
|
5079
|
+
|
|
5080
|
+
|
|
5081
|
+
|
|
5082
|
+
|
|
5083
|
+
|
|
5084
|
+
|
|
5085
|
+
|
|
5086
|
+
|
|
5087
|
+
|
|
5088
|
+
|
|
5089
|
+
|
|
5090
|
+
|
|
5091
|
+
|
|
5092
|
+
|
|
5093
|
+
|
|
5094
|
+
|
|
5095
|
+
|
|
5096
|
+
|
|
5097
|
+
|
|
4221
5098
|
* @example
|
|
4222
5099
|
* // Deep clone
|
|
4223
5100
|
* const mm = new TreeMultiMap<number, string>();
|