max-priority-queue-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 +207 -71
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +206 -70
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +207 -72
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +206 -71
- 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/max-priority-queue-typed.js +204 -69
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js +1 -1
- package/dist/umd/max-priority-queue-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
|
@@ -58,6 +58,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
61
68
|
|
|
62
69
|
|
|
63
70
|
|
|
@@ -220,14 +227,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
220
227
|
|
|
221
228
|
|
|
222
229
|
|
|
223
|
-
* @example
|
|
224
|
-
* // Check empty
|
|
225
|
-
* console.log(new TreeMultiSet().isEmpty()); // true;
|
|
226
|
-
*/
|
|
227
|
-
isEmpty(): boolean;
|
|
228
|
-
/**
|
|
229
|
-
* Whether the multiset contains the given key.
|
|
230
|
-
* @remarks Time O(log n), Space O(1)
|
|
231
230
|
|
|
232
231
|
|
|
233
232
|
|
|
@@ -263,6 +262,14 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
263
262
|
|
|
264
263
|
|
|
265
264
|
|
|
265
|
+
* @example
|
|
266
|
+
* // Check empty
|
|
267
|
+
* console.log(new TreeMultiSet().isEmpty()); // true;
|
|
268
|
+
*/
|
|
269
|
+
isEmpty(): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Whether the multiset contains the given key.
|
|
272
|
+
* @remarks Time O(log n), Space O(1)
|
|
266
273
|
|
|
267
274
|
|
|
268
275
|
|
|
@@ -374,17 +381,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
374
381
|
|
|
375
382
|
|
|
376
383
|
|
|
377
|
-
* @example
|
|
378
|
-
* // Check existence
|
|
379
|
-
* const ms = new TreeMultiSet<number>();
|
|
380
|
-
* ms.add(1);
|
|
381
|
-
* console.log(ms.has(1)); // true;
|
|
382
|
-
* console.log(ms.has(2)); // false;
|
|
383
|
-
*/
|
|
384
|
-
has(key: K): boolean;
|
|
385
|
-
/**
|
|
386
|
-
* Returns the count of occurrences for the given key.
|
|
387
|
-
* @remarks Time O(log n), Space O(1)
|
|
388
384
|
|
|
389
385
|
|
|
390
386
|
|
|
@@ -408,17 +404,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
408
404
|
|
|
409
405
|
|
|
410
406
|
|
|
411
|
-
* @example
|
|
412
|
-
* // Get occurrence count
|
|
413
|
-
* const ms = new TreeMultiSet<number>();
|
|
414
|
-
* ms.add(1, 5);
|
|
415
|
-
* console.log(ms.count(1)); // 5;
|
|
416
|
-
*/
|
|
417
|
-
count(key: K): number;
|
|
418
|
-
/**
|
|
419
|
-
* Add `n` occurrences of `key`.
|
|
420
|
-
* @returns True if the multiset changed.
|
|
421
|
-
* @remarks Time O(log n), Space O(1)
|
|
422
407
|
|
|
423
408
|
|
|
424
409
|
|
|
@@ -466,6 +451,17 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
466
451
|
|
|
467
452
|
|
|
468
453
|
|
|
454
|
+
* @example
|
|
455
|
+
* // Check existence
|
|
456
|
+
* const ms = new TreeMultiSet<number>();
|
|
457
|
+
* ms.add(1);
|
|
458
|
+
* console.log(ms.has(1)); // true;
|
|
459
|
+
* console.log(ms.has(2)); // false;
|
|
460
|
+
*/
|
|
461
|
+
has(key: K): boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Returns the count of occurrences for the given key.
|
|
464
|
+
* @remarks Time O(log n), Space O(1)
|
|
469
465
|
|
|
470
466
|
|
|
471
467
|
|
|
@@ -496,6 +492,17 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
496
492
|
|
|
497
493
|
|
|
498
494
|
|
|
495
|
+
* @example
|
|
496
|
+
* // Get occurrence count
|
|
497
|
+
* const ms = new TreeMultiSet<number>();
|
|
498
|
+
* ms.add(1, 5);
|
|
499
|
+
* console.log(ms.count(1)); // 5;
|
|
500
|
+
*/
|
|
501
|
+
count(key: K): number;
|
|
502
|
+
/**
|
|
503
|
+
* Add `n` occurrences of `key`.
|
|
504
|
+
* @returns True if the multiset changed.
|
|
505
|
+
* @remarks Time O(log n), Space O(1)
|
|
499
506
|
|
|
500
507
|
|
|
501
508
|
|
|
@@ -556,20 +563,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
556
563
|
|
|
557
564
|
|
|
558
565
|
|
|
559
|
-
* @example
|
|
560
|
-
* // Add elements
|
|
561
|
-
* const ms = new TreeMultiSet<number>();
|
|
562
|
-
* ms.add(1);
|
|
563
|
-
* ms.add(1);
|
|
564
|
-
* ms.add(2);
|
|
565
|
-
* console.log(ms.count(1)); // 2;
|
|
566
|
-
* console.log(ms.size); // 3;
|
|
567
|
-
*/
|
|
568
|
-
add(key: K, n?: number): boolean;
|
|
569
|
-
/**
|
|
570
|
-
* Set count for `key` to exactly `n`.
|
|
571
|
-
* @returns True if changed.
|
|
572
|
-
* @remarks Time O(log n), Space O(1)
|
|
573
566
|
|
|
574
567
|
|
|
575
568
|
|
|
@@ -593,17 +586,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
593
586
|
|
|
594
587
|
|
|
595
588
|
|
|
596
|
-
* @example
|
|
597
|
-
* // Set occurrence count
|
|
598
|
-
* const ms = new TreeMultiSet<number>();
|
|
599
|
-
* ms.setCount(1, 3);
|
|
600
|
-
* console.log(ms.count(1)); // 3;
|
|
601
|
-
*/
|
|
602
|
-
setCount(key: K, n: number): boolean;
|
|
603
|
-
/**
|
|
604
|
-
* Delete `n` occurrences of `key` (default 1).
|
|
605
|
-
* @returns True if any occurrence was removed.
|
|
606
|
-
* @remarks Time O(log n), Space O(1)
|
|
607
589
|
|
|
608
590
|
|
|
609
591
|
|
|
@@ -693,6 +675,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
693
675
|
|
|
694
676
|
|
|
695
677
|
|
|
678
|
+
* @example
|
|
679
|
+
* // Add elements
|
|
680
|
+
* const ms = new TreeMultiSet<number>();
|
|
681
|
+
* ms.add(1);
|
|
682
|
+
* ms.add(1);
|
|
683
|
+
* ms.add(2);
|
|
684
|
+
* console.log(ms.count(1)); // 2;
|
|
685
|
+
* console.log(ms.size); // 3;
|
|
686
|
+
*/
|
|
687
|
+
add(key: K, n?: number): boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Set count for `key` to exactly `n`.
|
|
690
|
+
* @returns True if changed.
|
|
691
|
+
* @remarks Time O(log n), Space O(1)
|
|
696
692
|
|
|
697
693
|
|
|
698
694
|
|
|
@@ -723,6 +719,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
723
719
|
|
|
724
720
|
|
|
725
721
|
|
|
722
|
+
* @example
|
|
723
|
+
* // Set occurrence count
|
|
724
|
+
* const ms = new TreeMultiSet<number>();
|
|
725
|
+
* ms.setCount(1, 3);
|
|
726
|
+
* console.log(ms.count(1)); // 3;
|
|
727
|
+
*/
|
|
728
|
+
setCount(key: K, n: number): boolean;
|
|
729
|
+
/**
|
|
730
|
+
* Delete `n` occurrences of `key` (default 1).
|
|
731
|
+
* @returns True if any occurrence was removed.
|
|
732
|
+
* @remarks Time O(log n), Space O(1)
|
|
733
|
+
|
|
726
734
|
|
|
727
735
|
|
|
728
736
|
|
|
@@ -750,18 +758,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
750
758
|
|
|
751
759
|
|
|
752
760
|
|
|
753
|
-
* @example
|
|
754
|
-
* // Remove one occurrence
|
|
755
|
-
* const ms = new TreeMultiSet<number>();
|
|
756
|
-
* ms.add(1, 3);
|
|
757
|
-
* ms.delete(1);
|
|
758
|
-
* console.log(ms.count(1)); // 2;
|
|
759
|
-
*/
|
|
760
|
-
delete(key: K, n?: number): boolean;
|
|
761
|
-
/**
|
|
762
|
-
* Delete all occurrences of the given key.
|
|
763
|
-
* @returns True if any occurrence was removed.
|
|
764
|
-
* @remarks Time O(log n), Space O(1)
|
|
765
761
|
|
|
766
762
|
|
|
767
763
|
|
|
@@ -785,17 +781,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
785
781
|
|
|
786
782
|
|
|
787
783
|
|
|
788
|
-
* @example
|
|
789
|
-
* // Remove all occurrences
|
|
790
|
-
* const ms = new TreeMultiSet<number>();
|
|
791
|
-
* ms.add(1, 3);
|
|
792
|
-
* ms.deleteAll(1);
|
|
793
|
-
* console.log(ms.has(1)); // false;
|
|
794
|
-
*/
|
|
795
|
-
deleteAll(key: K): boolean;
|
|
796
|
-
/**
|
|
797
|
-
* Iterates over distinct keys (each key yielded once).
|
|
798
|
-
* @remarks Time O(n), Space O(1)
|
|
799
784
|
|
|
800
785
|
|
|
801
786
|
|
|
@@ -819,17 +804,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
819
804
|
|
|
820
805
|
|
|
821
806
|
|
|
822
|
-
* @example
|
|
823
|
-
* // Iterate unique keys
|
|
824
|
-
* const ms = new TreeMultiSet<number>();
|
|
825
|
-
* ms.add(1, 2);
|
|
826
|
-
* ms.add(2);
|
|
827
|
-
* console.log([...ms.keysDistinct()]); // [1, 2];
|
|
828
|
-
*/
|
|
829
|
-
keysDistinct(): IterableIterator<K>;
|
|
830
|
-
/**
|
|
831
|
-
* Iterates over entries as [key, count] pairs.
|
|
832
|
-
* @remarks Time O(n), Space O(1)
|
|
833
807
|
|
|
834
808
|
|
|
835
809
|
|
|
@@ -937,6 +911,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
937
911
|
|
|
938
912
|
|
|
939
913
|
|
|
914
|
+
* @example
|
|
915
|
+
* // Remove one occurrence
|
|
916
|
+
* const ms = new TreeMultiSet<number>();
|
|
917
|
+
* ms.add(1, 3);
|
|
918
|
+
* ms.delete(1);
|
|
919
|
+
* console.log(ms.count(1)); // 2;
|
|
920
|
+
*/
|
|
921
|
+
delete(key: K, n?: number): boolean;
|
|
922
|
+
/**
|
|
923
|
+
* Delete all occurrences of the given key.
|
|
924
|
+
* @returns True if any occurrence was removed.
|
|
925
|
+
* @remarks Time O(log n), Space O(1)
|
|
926
|
+
|
|
927
|
+
|
|
940
928
|
|
|
941
929
|
|
|
942
930
|
|
|
@@ -965,6 +953,17 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
965
953
|
|
|
966
954
|
|
|
967
955
|
|
|
956
|
+
* @example
|
|
957
|
+
* // Remove all occurrences
|
|
958
|
+
* const ms = new TreeMultiSet<number>();
|
|
959
|
+
* ms.add(1, 3);
|
|
960
|
+
* ms.deleteAll(1);
|
|
961
|
+
* console.log(ms.has(1)); // false;
|
|
962
|
+
*/
|
|
963
|
+
deleteAll(key: K): boolean;
|
|
964
|
+
/**
|
|
965
|
+
* Iterates over distinct keys (each key yielded once).
|
|
966
|
+
* @remarks Time O(n), Space O(1)
|
|
968
967
|
|
|
969
968
|
|
|
970
969
|
|
|
@@ -973,21 +972,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
973
972
|
|
|
974
973
|
|
|
975
974
|
|
|
976
|
-
* @example
|
|
977
|
-
* // Iterate entries
|
|
978
|
-
* const ms = new TreeMultiSet<number>();
|
|
979
|
-
* ms.add(1, 2);
|
|
980
|
-
* console.log([...ms.entries()].length); // > 0;
|
|
981
|
-
*/
|
|
982
|
-
entries(): IterableIterator<[K, number]>;
|
|
983
|
-
/**
|
|
984
|
-
* Expanded iteration (default). Each key is yielded `count(key)` times.
|
|
985
|
-
* @remarks Time O(size), Space O(1) where size is total occurrences
|
|
986
|
-
*/
|
|
987
|
-
[Symbol.iterator](): Iterator<K>;
|
|
988
|
-
/**
|
|
989
|
-
* Returns an array with all elements (expanded).
|
|
990
|
-
* @remarks Time O(size), Space O(size)
|
|
991
975
|
|
|
992
976
|
|
|
993
977
|
|
|
@@ -1010,6 +994,28 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1010
994
|
|
|
1011
995
|
|
|
1012
996
|
|
|
997
|
+
* @example
|
|
998
|
+
* // Iterate unique keys
|
|
999
|
+
* const ms = new TreeMultiSet<number>();
|
|
1000
|
+
* ms.add(1, 2);
|
|
1001
|
+
* ms.add(2);
|
|
1002
|
+
* console.log([...ms.keysDistinct()]); // [1, 2];
|
|
1003
|
+
*/
|
|
1004
|
+
keysDistinct(): IterableIterator<K>;
|
|
1005
|
+
/**
|
|
1006
|
+
* Iterates over entries as [key, count] pairs.
|
|
1007
|
+
* @remarks Time O(n), Space O(1)
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1013
1019
|
|
|
1014
1020
|
|
|
1015
1021
|
|
|
@@ -1131,17 +1137,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1131
1137
|
|
|
1132
1138
|
|
|
1133
1139
|
|
|
1134
|
-
* @example
|
|
1135
|
-
* // All elements (with duplicates)
|
|
1136
|
-
* const ms = new TreeMultiSet<number>();
|
|
1137
|
-
* ms.add(1, 2);
|
|
1138
|
-
* ms.add(2);
|
|
1139
|
-
* console.log(ms.toArray()); // [1, 1, 2];
|
|
1140
|
-
*/
|
|
1141
|
-
toArray(): K[];
|
|
1142
|
-
/**
|
|
1143
|
-
* Returns an array with distinct keys only.
|
|
1144
|
-
* @remarks Time O(n), Space O(n)
|
|
1145
1140
|
|
|
1146
1141
|
|
|
1147
1142
|
|
|
@@ -1165,17 +1160,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1165
1160
|
|
|
1166
1161
|
|
|
1167
1162
|
|
|
1168
|
-
* @example
|
|
1169
|
-
* // Unique keys only
|
|
1170
|
-
* const ms = new TreeMultiSet<number>();
|
|
1171
|
-
* ms.add(1, 3);
|
|
1172
|
-
* ms.add(2);
|
|
1173
|
-
* console.log(ms.toDistinctArray()); // [1, 2];
|
|
1174
|
-
*/
|
|
1175
|
-
toDistinctArray(): K[];
|
|
1176
|
-
/**
|
|
1177
|
-
* Returns an array of [key, count] entries.
|
|
1178
|
-
* @remarks Time O(n), Space O(n)
|
|
1179
1163
|
|
|
1180
1164
|
|
|
1181
1165
|
|
|
@@ -1200,22 +1184,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1200
1184
|
|
|
1201
1185
|
|
|
1202
1186
|
* @example
|
|
1203
|
-
* //
|
|
1187
|
+
* // Iterate entries
|
|
1204
1188
|
* const ms = new TreeMultiSet<number>();
|
|
1205
1189
|
* ms.add(1, 2);
|
|
1206
|
-
* ms.
|
|
1207
|
-
* console.log(ms.toEntries()); // [[1, 2], [3, 1]];
|
|
1190
|
+
* console.log([...ms.entries()].length); // > 0;
|
|
1208
1191
|
*/
|
|
1209
|
-
|
|
1192
|
+
entries(): IterableIterator<[K, number]>;
|
|
1210
1193
|
/**
|
|
1211
|
-
*
|
|
1212
|
-
* @remarks Time O(
|
|
1194
|
+
* Expanded iteration (default). Each key is yielded `count(key)` times.
|
|
1195
|
+
* @remarks Time O(size), Space O(1) where size is total occurrences
|
|
1213
1196
|
*/
|
|
1214
|
-
|
|
1197
|
+
[Symbol.iterator](): Iterator<K>;
|
|
1215
1198
|
/**
|
|
1216
|
-
*
|
|
1217
|
-
* @remarks Time O(
|
|
1218
|
-
|
|
1199
|
+
* Returns an array with all elements (expanded).
|
|
1200
|
+
* @remarks Time O(size), Space O(size)
|
|
1219
1201
|
|
|
1220
1202
|
|
|
1221
1203
|
|
|
@@ -1359,16 +1341,412 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1359
1341
|
|
|
1360
1342
|
|
|
1361
1343
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
* @example
|
|
1380
|
+
* // All elements (with duplicates)
|
|
1381
|
+
* const ms = new TreeMultiSet<number>();
|
|
1382
|
+
* ms.add(1, 2);
|
|
1383
|
+
* ms.add(2);
|
|
1384
|
+
* console.log(ms.toArray()); // [1, 1, 2];
|
|
1385
|
+
*/
|
|
1386
|
+
toArray(): K[];
|
|
1387
|
+
/**
|
|
1388
|
+
* Returns an array with distinct keys only.
|
|
1389
|
+
* @remarks Time O(n), Space O(n)
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
* @example
|
|
1421
|
+
* // Unique keys only
|
|
1422
|
+
* const ms = new TreeMultiSet<number>();
|
|
1423
|
+
* ms.add(1, 3);
|
|
1424
|
+
* ms.add(2);
|
|
1425
|
+
* console.log(ms.toDistinctArray()); // [1, 2];
|
|
1426
|
+
*/
|
|
1427
|
+
toDistinctArray(): K[];
|
|
1428
|
+
/**
|
|
1429
|
+
* Returns an array of [key, count] entries.
|
|
1430
|
+
* @remarks Time O(n), Space O(n)
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
* @example
|
|
1462
|
+
* // Key-count pairs
|
|
1463
|
+
* const ms = new TreeMultiSet<number>();
|
|
1464
|
+
* ms.add(1, 2);
|
|
1465
|
+
* ms.add(3);
|
|
1466
|
+
* console.log(ms.toEntries()); // [[1, 2], [3, 1]];
|
|
1467
|
+
*/
|
|
1468
|
+
toEntries(): Array<[K, number]>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Expose comparator for advanced usage/testing (read-only).
|
|
1471
|
+
* @remarks Time O(1), Space O(1)
|
|
1472
|
+
*/
|
|
1473
|
+
get comparator(): Comparator<K>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Remove all elements from the multiset.
|
|
1476
|
+
* @remarks Time O(1), Space O(1)
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
|
|
1655
|
+
|
|
1656
|
+
* @example
|
|
1657
|
+
* // Remove all
|
|
1658
|
+
* const ms = new TreeMultiSet<number>();
|
|
1659
|
+
* ms.add(1);
|
|
1660
|
+
* ms.clear();
|
|
1661
|
+
* console.log(ms.isEmpty()); // true;
|
|
1662
|
+
*/
|
|
1663
|
+
clear(): void;
|
|
1664
|
+
/**
|
|
1665
|
+
* Returns the smallest key, or undefined if empty.
|
|
1666
|
+
* @remarks Time O(log n), Space O(1)
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
* @example
|
|
1699
|
+
* // Smallest element
|
|
1700
|
+
* const ms = new TreeMultiSet<number>();
|
|
1701
|
+
* ms.add(3);
|
|
1702
|
+
* ms.add(1);
|
|
1703
|
+
* console.log(ms.first()); // 1;
|
|
1704
|
+
*/
|
|
1705
|
+
first(): K | undefined;
|
|
1706
|
+
/**
|
|
1707
|
+
* Returns the largest key, or undefined if empty.
|
|
1708
|
+
* @remarks Time O(log n), Space O(1)
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
* @example
|
|
1741
|
+
* // Largest element
|
|
1364
1742
|
* const ms = new TreeMultiSet<number>();
|
|
1365
1743
|
* ms.add(1);
|
|
1366
|
-
* ms.
|
|
1367
|
-
* console.log(ms.
|
|
1744
|
+
* ms.add(3);
|
|
1745
|
+
* console.log(ms.last()); // 3;
|
|
1368
1746
|
*/
|
|
1369
|
-
|
|
1747
|
+
last(): K | undefined;
|
|
1370
1748
|
/**
|
|
1371
|
-
*
|
|
1749
|
+
* Removes all occurrences of the smallest key and returns it.
|
|
1372
1750
|
* @remarks Time O(log n), Space O(1)
|
|
1373
1751
|
|
|
1374
1752
|
|
|
@@ -1386,6 +1764,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1386
1764
|
|
|
1387
1765
|
|
|
1388
1766
|
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1389
1774
|
|
|
1390
1775
|
|
|
1391
1776
|
|
|
@@ -1395,15 +1780,16 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1395
1780
|
|
|
1396
1781
|
|
|
1397
1782
|
* @example
|
|
1398
|
-
* //
|
|
1783
|
+
* // Remove and return smallest
|
|
1399
1784
|
* const ms = new TreeMultiSet<number>();
|
|
1400
|
-
* ms.add(
|
|
1785
|
+
* ms.add(2);
|
|
1401
1786
|
* ms.add(1);
|
|
1402
|
-
* console.log(ms.
|
|
1787
|
+
* console.log(ms.pollFirst()); // 1;
|
|
1788
|
+
* console.log(ms.has(1)); // false;
|
|
1403
1789
|
*/
|
|
1404
|
-
|
|
1790
|
+
pollFirst(): K | undefined;
|
|
1405
1791
|
/**
|
|
1406
|
-
*
|
|
1792
|
+
* Removes all occurrences of the largest key and returns it.
|
|
1407
1793
|
* @remarks Time O(log n), Space O(1)
|
|
1408
1794
|
|
|
1409
1795
|
|
|
@@ -1421,6 +1807,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1421
1807
|
|
|
1422
1808
|
|
|
1423
1809
|
|
|
1810
|
+
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
|
|
1816
|
+
|
|
1424
1817
|
|
|
1425
1818
|
|
|
1426
1819
|
|
|
@@ -1430,15 +1823,15 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1430
1823
|
|
|
1431
1824
|
|
|
1432
1825
|
* @example
|
|
1433
|
-
* //
|
|
1826
|
+
* // Remove and return largest
|
|
1434
1827
|
* const ms = new TreeMultiSet<number>();
|
|
1435
1828
|
* ms.add(1);
|
|
1436
1829
|
* ms.add(3);
|
|
1437
|
-
* console.log(ms.
|
|
1830
|
+
* console.log(ms.pollLast()); // 3;
|
|
1438
1831
|
*/
|
|
1439
|
-
|
|
1832
|
+
pollLast(): K | undefined;
|
|
1440
1833
|
/**
|
|
1441
|
-
*
|
|
1834
|
+
* Returns the smallest key >= given key, or undefined.
|
|
1442
1835
|
* @remarks Time O(log n), Space O(1)
|
|
1443
1836
|
|
|
1444
1837
|
|
|
@@ -1464,19 +1857,101 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1464
1857
|
|
|
1465
1858
|
|
|
1466
1859
|
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
|
|
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
|
+
|
|
1480
1955
|
|
|
1481
1956
|
|
|
1482
1957
|
|
|
@@ -1501,15 +1976,16 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1501
1976
|
|
|
1502
1977
|
|
|
1503
1978
|
* @example
|
|
1504
|
-
* //
|
|
1979
|
+
* // Least key ≥ target
|
|
1505
1980
|
* const ms = new TreeMultiSet<number>();
|
|
1506
|
-
* ms.add(
|
|
1507
|
-
* ms.add(
|
|
1508
|
-
*
|
|
1981
|
+
* ms.add(10);
|
|
1982
|
+
* ms.add(20);
|
|
1983
|
+
* ms.add(30);
|
|
1984
|
+
* console.log(ms.ceiling(15)); // 20;
|
|
1509
1985
|
*/
|
|
1510
|
-
|
|
1986
|
+
ceiling(key: K): K | undefined;
|
|
1511
1987
|
/**
|
|
1512
|
-
* Returns the
|
|
1988
|
+
* Returns the largest key <= given key, or undefined.
|
|
1513
1989
|
* @remarks Time O(log n), Space O(1)
|
|
1514
1990
|
|
|
1515
1991
|
|
|
@@ -1625,19 +2101,102 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1625
2101
|
|
|
1626
2102
|
|
|
1627
2103
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
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
|
+
* @example
|
|
2133
|
+
* // Greatest key ≤ target
|
|
2134
|
+
* const ms = new TreeMultiSet<number>();
|
|
2135
|
+
* ms.add(10);
|
|
2136
|
+
* ms.add(20);
|
|
2137
|
+
* ms.add(30);
|
|
2138
|
+
* console.log(ms.floor(25)); // 20;
|
|
2139
|
+
*/
|
|
2140
|
+
floor(key: K): K | undefined;
|
|
2141
|
+
/**
|
|
2142
|
+
* Returns the smallest key > given key, or undefined.
|
|
2143
|
+
* @remarks Time O(log n), Space O(1)
|
|
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
|
+
|
|
1641
2200
|
|
|
1642
2201
|
|
|
1643
2202
|
|
|
@@ -1724,6 +2283,19 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1724
2283
|
|
|
1725
2284
|
|
|
1726
2285
|
|
|
2286
|
+
* @example
|
|
2287
|
+
* // Least key > target
|
|
2288
|
+
* const ms = new TreeMultiSet<number>();
|
|
2289
|
+
* ms.add(10);
|
|
2290
|
+
* ms.add(20);
|
|
2291
|
+
* console.log(ms.higher(10)); // 20;
|
|
2292
|
+
*/
|
|
2293
|
+
higher(key: K): K | undefined;
|
|
2294
|
+
/**
|
|
2295
|
+
* Returns the largest key < given key, or undefined.
|
|
2296
|
+
* @remarks Time O(log n), Space O(1)
|
|
2297
|
+
|
|
2298
|
+
|
|
1727
2299
|
|
|
1728
2300
|
|
|
1729
2301
|
|
|
@@ -1751,19 +2323,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1751
2323
|
|
|
1752
2324
|
|
|
1753
2325
|
|
|
1754
|
-
* @example
|
|
1755
|
-
* // Greatest key ≤ target
|
|
1756
|
-
* const ms = new TreeMultiSet<number>();
|
|
1757
|
-
* ms.add(10);
|
|
1758
|
-
* ms.add(20);
|
|
1759
|
-
* ms.add(30);
|
|
1760
|
-
* console.log(ms.floor(25)); // 20;
|
|
1761
|
-
*/
|
|
1762
|
-
floor(key: K): K | undefined;
|
|
1763
|
-
/**
|
|
1764
|
-
* Returns the smallest key > given key, or undefined.
|
|
1765
|
-
* @remarks Time O(log n), Space O(1)
|
|
1766
|
-
|
|
1767
2326
|
|
|
1768
2327
|
|
|
1769
2328
|
|
|
@@ -1878,16 +2437,16 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
1878
2437
|
|
|
1879
2438
|
|
|
1880
2439
|
* @example
|
|
1881
|
-
* //
|
|
2440
|
+
* // Greatest key < target
|
|
1882
2441
|
* const ms = new TreeMultiSet<number>();
|
|
1883
2442
|
* ms.add(10);
|
|
1884
2443
|
* ms.add(20);
|
|
1885
|
-
* console.log(ms.
|
|
2444
|
+
* console.log(ms.lower(20)); // 10;
|
|
1886
2445
|
*/
|
|
1887
|
-
|
|
2446
|
+
lower(key: K): K | undefined;
|
|
1888
2447
|
/**
|
|
1889
|
-
*
|
|
1890
|
-
* @remarks Time O(
|
|
2448
|
+
* Iterates over distinct keys with their counts.
|
|
2449
|
+
* @remarks Time O(n), Space O(1)
|
|
1891
2450
|
|
|
1892
2451
|
|
|
1893
2452
|
|
|
@@ -2002,26 +2561,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2002
2561
|
|
|
2003
2562
|
|
|
2004
2563
|
|
|
2005
|
-
* @example
|
|
2006
|
-
* // Greatest key < target
|
|
2007
|
-
* const ms = new TreeMultiSet<number>();
|
|
2008
|
-
* ms.add(10);
|
|
2009
|
-
* ms.add(20);
|
|
2010
|
-
* console.log(ms.lower(20)); // 10;
|
|
2011
|
-
*/
|
|
2012
|
-
lower(key: K): K | undefined;
|
|
2013
|
-
/**
|
|
2014
|
-
* Iterates over distinct keys with their counts.
|
|
2015
|
-
* @remarks Time O(n), Space O(1)
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
2564
|
|
|
2026
2565
|
|
|
2027
2566
|
|
|
@@ -2087,6 +2626,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2087
2626
|
|
|
2088
2627
|
|
|
2089
2628
|
|
|
2629
|
+
* @example
|
|
2630
|
+
* // Iterate
|
|
2631
|
+
* const ms = new TreeMultiSet<number>();
|
|
2632
|
+
* ms.add(1, 2);
|
|
2633
|
+
* ms.add(2);
|
|
2634
|
+
* const pairs: [number, number][] = [];
|
|
2635
|
+
* ms.forEach((k, c) => pairs.push([k, c]));
|
|
2636
|
+
* console.log(pairs); // [[1, 2], [2, 1]];
|
|
2637
|
+
*/
|
|
2638
|
+
forEach(callback: (key: K, count: number) => void): void;
|
|
2639
|
+
/**
|
|
2640
|
+
* Creates a new TreeMultiSet with entries that match the predicate.
|
|
2641
|
+
* @remarks Time O(n log n), Space O(n)
|
|
2642
|
+
|
|
2090
2643
|
|
|
2091
2644
|
|
|
2092
2645
|
|
|
@@ -2157,20 +2710,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2157
2710
|
|
|
2158
2711
|
|
|
2159
2712
|
|
|
2160
|
-
* @example
|
|
2161
|
-
* // Iterate
|
|
2162
|
-
* const ms = new TreeMultiSet<number>();
|
|
2163
|
-
* ms.add(1, 2);
|
|
2164
|
-
* ms.add(2);
|
|
2165
|
-
* const pairs: [number, number][] = [];
|
|
2166
|
-
* ms.forEach((k, c) => pairs.push([k, c]));
|
|
2167
|
-
* console.log(pairs); // [[1, 2], [2, 1]];
|
|
2168
|
-
*/
|
|
2169
|
-
forEach(callback: (key: K, count: number) => void): void;
|
|
2170
|
-
/**
|
|
2171
|
-
* Creates a new TreeMultiSet with entries that match the predicate.
|
|
2172
|
-
* @remarks Time O(n log n), Space O(n)
|
|
2173
|
-
|
|
2174
2713
|
|
|
2175
2714
|
|
|
2176
2715
|
|
|
@@ -2279,6 +2818,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2279
2818
|
|
|
2280
2819
|
|
|
2281
2820
|
|
|
2821
|
+
* @example
|
|
2822
|
+
* // Filter
|
|
2823
|
+
* const ms = new TreeMultiSet<number>();
|
|
2824
|
+
* ms.add(1, 3);
|
|
2825
|
+
* ms.add(2, 1);
|
|
2826
|
+
* ms.add(3, 2);
|
|
2827
|
+
* const filtered = ms.filter((k, c) => c > 1);
|
|
2828
|
+
* console.log([...filtered.keysDistinct()]); // [1, 3];
|
|
2829
|
+
*/
|
|
2830
|
+
filter(predicate: (key: K, count: number) => boolean): TreeMultiSet<K>;
|
|
2831
|
+
/**
|
|
2832
|
+
* Reduces the multiset to a single value.
|
|
2833
|
+
* @remarks Time O(n), Space O(1)
|
|
2834
|
+
|
|
2282
2835
|
|
|
2283
2836
|
|
|
2284
2837
|
|
|
@@ -2314,20 +2867,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2314
2867
|
|
|
2315
2868
|
|
|
2316
2869
|
|
|
2317
|
-
* @example
|
|
2318
|
-
* // Filter
|
|
2319
|
-
* const ms = new TreeMultiSet<number>();
|
|
2320
|
-
* ms.add(1, 3);
|
|
2321
|
-
* ms.add(2, 1);
|
|
2322
|
-
* ms.add(3, 2);
|
|
2323
|
-
* const filtered = ms.filter((k, c) => c > 1);
|
|
2324
|
-
* console.log([...filtered.keysDistinct()]); // [1, 3];
|
|
2325
|
-
*/
|
|
2326
|
-
filter(predicate: (key: K, count: number) => boolean): TreeMultiSet<K>;
|
|
2327
|
-
/**
|
|
2328
|
-
* Reduces the multiset to a single value.
|
|
2329
|
-
* @remarks Time O(n), Space O(1)
|
|
2330
|
-
|
|
2331
2870
|
|
|
2332
2871
|
|
|
2333
2872
|
|
|
@@ -2607,6 +3146,41 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2607
3146
|
|
|
2608
3147
|
|
|
2609
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
|
+
|
|
2610
3184
|
|
|
2611
3185
|
|
|
2612
3186
|
|
|
@@ -2772,6 +3346,19 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2772
3346
|
|
|
2773
3347
|
|
|
2774
3348
|
|
|
3349
|
+
|
|
3350
|
+
|
|
3351
|
+
|
|
3352
|
+
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
|
|
3356
|
+
|
|
3357
|
+
|
|
3358
|
+
|
|
3359
|
+
|
|
3360
|
+
|
|
3361
|
+
|
|
2775
3362
|
|
|
2776
3363
|
|
|
2777
3364
|
|
|
@@ -2787,13 +3374,88 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2787
3374
|
|
|
2788
3375
|
|
|
2789
3376
|
* @example
|
|
2790
|
-
* //
|
|
2791
|
-
* const
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
2794
|
-
*
|
|
2795
|
-
* console.log(ms.has(1)); // true;
|
|
3377
|
+
* // Order-statistic on BST
|
|
3378
|
+
* const tree = new TreeMultiSet<number>([30, 10, 50, 20, 40], { enableOrderStatistic: true });
|
|
3379
|
+
* console.log(tree.getByRank(0)); // 10;
|
|
3380
|
+
* console.log(tree.getByRank(4)); // 50;
|
|
3381
|
+
* console.log(tree.getRank(30)); // 2;
|
|
2796
3382
|
*/
|
|
3383
|
+
getByRank(k: number): K | undefined;
|
|
3384
|
+
/**
|
|
3385
|
+
* Get the rank of a key in sorted order
|
|
3386
|
+
* @example
|
|
3387
|
+
* // Get the rank of a key in sorted order
|
|
3388
|
+
* const tree = new TreeMultiSet<number>(
|
|
3389
|
+
* [10, 20, 30, 40, 50],
|
|
3390
|
+
* { enableOrderStatistic: true }
|
|
3391
|
+
* );
|
|
3392
|
+
* console.log(tree.getRank(10)); // 0; // smallest → rank 0
|
|
3393
|
+
* console.log(tree.getRank(30)); // 2; // 2 elements before 30 in tree order
|
|
3394
|
+
* console.log(tree.getRank(50)); // 4; // largest → rank 4
|
|
3395
|
+
* console.log(tree.getRank(25)); // 2;
|
|
3396
|
+
*/
|
|
3397
|
+
getRank(key: K): number;
|
|
3398
|
+
/**
|
|
3399
|
+
* Get elements by rank range
|
|
3400
|
+
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
|
|
3405
|
+
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
|
|
3409
|
+
* @example
|
|
3410
|
+
* // Pagination by position in tree order
|
|
3411
|
+
* const tree = new TreeMultiSet<number>(
|
|
3412
|
+
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
3413
|
+
* { enableOrderStatistic: true }
|
|
3414
|
+
* );
|
|
3415
|
+
* const pageSize = 3;
|
|
3416
|
+
*
|
|
3417
|
+
* // Page 1
|
|
3418
|
+
* console.log(tree.rangeByRank(0, pageSize - 1)); // [10, 20, 30];
|
|
3419
|
+
* // Page 2
|
|
3420
|
+
* console.log(tree.rangeByRank(pageSize, 2 * pageSize - 1)); // [40, 50, 60];
|
|
3421
|
+
* // Page 3
|
|
3422
|
+
* console.log(tree.rangeByRank(2 * pageSize, 3 * pageSize - 1)); // [70, 80, 90];
|
|
3423
|
+
*/
|
|
3424
|
+
rangeByRank(start: number, end: number): K[];
|
|
3425
|
+
/**
|
|
3426
|
+
* Deep copy
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
|
|
3430
|
+
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
|
|
3434
|
+
|
|
3435
|
+
|
|
3436
|
+
|
|
3437
|
+
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
|
|
3441
|
+
|
|
3442
|
+
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
|
|
3451
|
+
* @example
|
|
3452
|
+
* // Deep clone
|
|
3453
|
+
* const ms = new TreeMultiSet<number>();
|
|
3454
|
+
* ms.add(1, 3);
|
|
3455
|
+
* const copy = ms.clone();
|
|
3456
|
+
* copy.deleteAll(1);
|
|
3457
|
+
* console.log(ms.has(1)); // true;
|
|
3458
|
+
*/
|
|
2797
3459
|
clone(): TreeMultiSet<K>;
|
|
2798
3460
|
/**
|
|
2799
3461
|
* Returns keys within the given range.
|
|
@@ -2891,6 +3553,34 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
2891
3553
|
|
|
2892
3554
|
|
|
2893
3555
|
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
|
|
3559
|
+
|
|
3560
|
+
|
|
3561
|
+
|
|
3562
|
+
|
|
3563
|
+
|
|
3564
|
+
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
|
|
3568
|
+
|
|
3569
|
+
|
|
3570
|
+
|
|
3571
|
+
|
|
3572
|
+
|
|
3573
|
+
|
|
3574
|
+
|
|
3575
|
+
|
|
3576
|
+
|
|
3577
|
+
|
|
3578
|
+
|
|
3579
|
+
|
|
3580
|
+
|
|
3581
|
+
|
|
3582
|
+
|
|
3583
|
+
|
|
2894
3584
|
|
|
2895
3585
|
|
|
2896
3586
|
|
|
@@ -3048,6 +3738,41 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
|
|
|
3048
3738
|
|
|
3049
3739
|
|
|
3050
3740
|
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3749
|
+
|
|
3750
|
+
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
|
|
3758
|
+
|
|
3759
|
+
|
|
3760
|
+
|
|
3761
|
+
|
|
3762
|
+
|
|
3763
|
+
|
|
3764
|
+
|
|
3765
|
+
|
|
3766
|
+
|
|
3767
|
+
|
|
3768
|
+
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
|
|
3772
|
+
|
|
3773
|
+
|
|
3774
|
+
|
|
3775
|
+
|
|
3051
3776
|
|
|
3052
3777
|
|
|
3053
3778
|
|