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.
Files changed (63) hide show
  1. package/dist/cjs/index.cjs +320 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +320 -55
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +320 -55
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +320 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/umd/binary-tree-typed.js +320 -55
  35. package/dist/umd/binary-tree-typed.js.map +1 -1
  36. package/dist/umd/binary-tree-typed.min.js +5 -5
  37. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/data-structures/base/iterable-element-base.ts +32 -0
  40. package/src/data-structures/base/linear-base.ts +11 -0
  41. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  42. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  43. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  44. package/src/data-structures/binary-tree/bst.ts +173 -7
  45. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  46. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  47. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  48. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  49. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  50. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  51. package/src/data-structures/graph/directed-graph.ts +71 -1
  52. package/src/data-structures/graph/undirected-graph.ts +64 -1
  53. package/src/data-structures/hash/hash-map.ts +100 -12
  54. package/src/data-structures/heap/heap.ts +149 -19
  55. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  56. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  57. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  58. package/src/data-structures/matrix/matrix.ts +56 -0
  59. package/src/data-structures/queue/deque.ts +187 -0
  60. package/src/data-structures/queue/queue.ts +109 -0
  61. package/src/data-structures/stack/stack.ts +75 -5
  62. package/src/data-structures/trie/trie.ts +84 -0
  63. package/src/interfaces/binary-tree.ts +1 -9
@@ -61,6 +61,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
61
61
 
62
62
 
63
63
 
64
+
65
+
66
+
67
+
68
+
69
+
70
+
64
71
 
65
72
 
66
73
 
@@ -238,14 +245,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
238
245
 
239
246
 
240
247
 
241
- * @example
242
- * // Check empty
243
- * console.log(new TreeMultiSet().isEmpty()); // true;
244
- */
245
- isEmpty(): boolean;
246
- /**
247
- * Whether the multiset contains the given key.
248
- * @remarks Time O(log n), Space O(1)
249
248
 
250
249
 
251
250
 
@@ -281,6 +280,14 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
281
280
 
282
281
 
283
282
 
283
+ * @example
284
+ * // Check empty
285
+ * console.log(new TreeMultiSet().isEmpty()); // true;
286
+ */
287
+ isEmpty(): boolean;
288
+ /**
289
+ * Whether the multiset contains the given key.
290
+ * @remarks Time O(log n), Space O(1)
284
291
 
285
292
 
286
293
 
@@ -407,17 +414,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
407
414
 
408
415
 
409
416
 
410
- * @example
411
- * // Check existence
412
- * const ms = new TreeMultiSet<number>();
413
- * ms.add(1);
414
- * console.log(ms.has(1)); // true;
415
- * console.log(ms.has(2)); // false;
416
- */
417
- has(key: K): boolean;
418
- /**
419
- * Returns the count of occurrences for the given key.
420
- * @remarks Time O(log n), Space O(1)
421
417
 
422
418
 
423
419
 
@@ -444,17 +440,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
444
440
 
445
441
 
446
442
 
447
- * @example
448
- * // Get occurrence count
449
- * const ms = new TreeMultiSet<number>();
450
- * ms.add(1, 5);
451
- * console.log(ms.count(1)); // 5;
452
- */
453
- count(key: K): number;
454
- /**
455
- * Add `n` occurrences of `key`.
456
- * @returns True if the multiset changed.
457
- * @remarks Time O(log n), Space O(1)
458
443
 
459
444
 
460
445
 
@@ -499,6 +484,17 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
499
484
 
500
485
 
501
486
 
487
+ * @example
488
+ * // Check existence
489
+ * const ms = new TreeMultiSet<number>();
490
+ * ms.add(1);
491
+ * console.log(ms.has(1)); // true;
492
+ * console.log(ms.has(2)); // false;
493
+ */
494
+ has(key: K): boolean;
495
+ /**
496
+ * Returns the count of occurrences for the given key.
497
+ * @remarks Time O(log n), Space O(1)
502
498
 
503
499
 
504
500
 
@@ -532,6 +528,17 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
532
528
 
533
529
 
534
530
 
531
+ * @example
532
+ * // Get occurrence count
533
+ * const ms = new TreeMultiSet<number>();
534
+ * ms.add(1, 5);
535
+ * console.log(ms.count(1)); // 5;
536
+ */
537
+ count(key: K): number;
538
+ /**
539
+ * Add `n` occurrences of `key`.
540
+ * @returns True if the multiset changed.
541
+ * @remarks Time O(log n), Space O(1)
535
542
 
536
543
 
537
544
 
@@ -607,20 +614,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
607
614
 
608
615
 
609
616
 
610
- * @example
611
- * // Add elements
612
- * const ms = new TreeMultiSet<number>();
613
- * ms.add(1);
614
- * ms.add(1);
615
- * ms.add(2);
616
- * console.log(ms.count(1)); // 2;
617
- * console.log(ms.size); // 3;
618
- */
619
- add(key: K, n?: number): boolean;
620
- /**
621
- * Set count for `key` to exactly `n`.
622
- * @returns True if changed.
623
- * @remarks Time O(log n), Space O(1)
624
617
 
625
618
 
626
619
 
@@ -647,17 +640,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
647
640
 
648
641
 
649
642
 
650
- * @example
651
- * // Set occurrence count
652
- * const ms = new TreeMultiSet<number>();
653
- * ms.setCount(1, 3);
654
- * console.log(ms.count(1)); // 3;
655
- */
656
- setCount(key: K, n: number): boolean;
657
- /**
658
- * Delete `n` occurrences of `key` (default 1).
659
- * @returns True if any occurrence was removed.
660
- * @remarks Time O(log n), Space O(1)
661
643
 
662
644
 
663
645
 
@@ -744,6 +726,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
744
726
 
745
727
 
746
728
 
729
+ * @example
730
+ * // Add elements
731
+ * const ms = new TreeMultiSet<number>();
732
+ * ms.add(1);
733
+ * ms.add(1);
734
+ * ms.add(2);
735
+ * console.log(ms.count(1)); // 2;
736
+ * console.log(ms.size); // 3;
737
+ */
738
+ add(key: K, n?: number): boolean;
739
+ /**
740
+ * Set count for `key` to exactly `n`.
741
+ * @returns True if changed.
742
+ * @remarks Time O(log n), Space O(1)
747
743
 
748
744
 
749
745
 
@@ -777,6 +773,26 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
777
773
 
778
774
 
779
775
 
776
+ * @example
777
+ * // Set occurrence count
778
+ * const ms = new TreeMultiSet<number>();
779
+ * ms.setCount(1, 3);
780
+ * console.log(ms.count(1)); // 3;
781
+ */
782
+ setCount(key: K, n: number): boolean;
783
+ /**
784
+ * Delete `n` occurrences of `key` (default 1).
785
+ * @returns True if any occurrence was removed.
786
+ * @remarks Time O(log n), Space O(1)
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
780
796
 
781
797
 
782
798
 
@@ -819,18 +835,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
819
835
 
820
836
 
821
837
 
822
- * @example
823
- * // Remove one occurrence
824
- * const ms = new TreeMultiSet<number>();
825
- * ms.add(1, 3);
826
- * ms.delete(1);
827
- * console.log(ms.count(1)); // 2;
828
- */
829
- delete(key: K, n?: number): boolean;
830
- /**
831
- * Delete all occurrences of the given key.
832
- * @returns True if any occurrence was removed.
833
- * @remarks Time O(log n), Space O(1)
834
838
 
835
839
 
836
840
 
@@ -857,17 +861,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
857
861
 
858
862
 
859
863
 
860
- * @example
861
- * // Remove all occurrences
862
- * const ms = new TreeMultiSet<number>();
863
- * ms.add(1, 3);
864
- * ms.deleteAll(1);
865
- * console.log(ms.has(1)); // false;
866
- */
867
- deleteAll(key: K): boolean;
868
- /**
869
- * Iterates over distinct keys (each key yielded once).
870
- * @remarks Time O(n), Space O(1)
871
864
 
872
865
 
873
866
 
@@ -894,17 +887,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
894
887
 
895
888
 
896
889
 
897
- * @example
898
- * // Iterate unique keys
899
- * const ms = new TreeMultiSet<number>();
900
- * ms.add(1, 2);
901
- * ms.add(2);
902
- * console.log([...ms.keysDistinct()]); // [1, 2];
903
- */
904
- keysDistinct(): IterableIterator<K>;
905
- /**
906
- * Iterates over entries as [key, count] pairs.
907
- * @remarks Time O(n), Space O(1)
908
890
 
909
891
 
910
892
 
@@ -998,6 +980,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
998
980
 
999
981
 
1000
982
 
983
+ * @example
984
+ * // Remove one occurrence
985
+ * const ms = new TreeMultiSet<number>();
986
+ * ms.add(1, 3);
987
+ * ms.delete(1);
988
+ * console.log(ms.count(1)); // 2;
989
+ */
990
+ delete(key: K, n?: number): boolean;
991
+ /**
992
+ * Delete all occurrences of the given key.
993
+ * @returns True if any occurrence was removed.
994
+ * @remarks Time O(log n), Space O(1)
1001
995
 
1002
996
 
1003
997
 
@@ -1031,6 +1025,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1031
1025
 
1032
1026
 
1033
1027
 
1028
+ * @example
1029
+ * // Remove all occurrences
1030
+ * const ms = new TreeMultiSet<number>();
1031
+ * ms.add(1, 3);
1032
+ * ms.deleteAll(1);
1033
+ * console.log(ms.has(1)); // false;
1034
+ */
1035
+ deleteAll(key: K): boolean;
1036
+ /**
1037
+ * Iterates over distinct keys (each key yielded once).
1038
+ * @remarks Time O(n), Space O(1)
1039
+
1034
1040
 
1035
1041
 
1036
1042
 
@@ -1064,21 +1070,16 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1064
1070
 
1065
1071
 
1066
1072
  * @example
1067
- * // Iterate entries
1073
+ * // Iterate unique keys
1068
1074
  * const ms = new TreeMultiSet<number>();
1069
1075
  * ms.add(1, 2);
1070
- * console.log([...ms.entries()].length); // > 0;
1071
- */
1072
- entries(): IterableIterator<[K, number]>;
1073
- /**
1074
- * Expanded iteration (default). Each key is yielded `count(key)` times.
1075
- * @remarks Time O(size), Space O(1) where size is total occurrences
1076
+ * ms.add(2);
1077
+ * console.log([...ms.keysDistinct()]); // [1, 2];
1076
1078
  */
1077
- [Symbol.iterator](): Iterator<K>;
1079
+ keysDistinct(): IterableIterator<K>;
1078
1080
  /**
1079
- * Returns an array with all elements (expanded).
1080
- * @remarks Time O(size), Space O(size)
1081
-
1081
+ * Iterates over entries as [key, count] pairs.
1082
+ * @remarks Time O(n), Space O(1)
1082
1083
 
1083
1084
 
1084
1085
 
@@ -1236,17 +1237,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1236
1237
 
1237
1238
 
1238
1239
 
1239
- * @example
1240
- * // All elements (with duplicates)
1241
- * const ms = new TreeMultiSet<number>();
1242
- * ms.add(1, 2);
1243
- * ms.add(2);
1244
- * console.log(ms.toArray()); // [1, 1, 2];
1245
- */
1246
- toArray(): K[];
1247
- /**
1248
- * Returns an array with distinct keys only.
1249
- * @remarks Time O(n), Space O(n)
1250
1240
 
1251
1241
 
1252
1242
 
@@ -1273,17 +1263,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1273
1263
 
1274
1264
 
1275
1265
 
1276
- * @example
1277
- * // Unique keys only
1278
- * const ms = new TreeMultiSet<number>();
1279
- * ms.add(1, 3);
1280
- * ms.add(2);
1281
- * console.log(ms.toDistinctArray()); // [1, 2];
1282
- */
1283
- toDistinctArray(): K[];
1284
- /**
1285
- * Returns an array of [key, count] entries.
1286
- * @remarks Time O(n), Space O(n)
1287
1266
 
1288
1267
 
1289
1268
 
@@ -1294,6 +1273,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1294
1273
 
1295
1274
 
1296
1275
 
1276
+ * @example
1277
+ * // Iterate entries
1278
+ * const ms = new TreeMultiSet<number>();
1279
+ * ms.add(1, 2);
1280
+ * console.log([...ms.entries()].length); // > 0;
1281
+ */
1282
+ entries(): IterableIterator<[K, number]>;
1283
+ /**
1284
+ * Expanded iteration (default). Each key is yielded `count(key)` times.
1285
+ * @remarks Time O(size), Space O(1) where size is total occurrences
1286
+ */
1287
+ [Symbol.iterator](): Iterator<K>;
1288
+ /**
1289
+ * Iterate over all elements with multiplicity (Set-compatible, alias for `[Symbol.iterator]`).
1290
+ * @remarks Each key is yielded `count(key)` times. Time O(size), Space O(1) per step.
1297
1291
 
1298
1292
 
1299
1293
 
@@ -1302,6 +1296,16 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1302
1296
 
1303
1297
 
1304
1298
 
1299
+ * @example
1300
+ * // Iterate with multiplicity
1301
+ * const ms = new TreeMultiSet<number>();
1302
+ * ms.add(1); ms.add(1); ms.add(2); ms.add(3); ms.add(3); ms.add(3);
1303
+ * console.log([...ms.keys()]); // [1, 1, 2, 3, 3, 3];
1304
+ */
1305
+ keys(): IterableIterator<K>;
1306
+ /**
1307
+ * Iterate over all elements with multiplicity (Set-compatible, alias for `[Symbol.iterator]`).
1308
+ * @remarks Each key is yielded `count(key)` times. Time O(size), Space O(1) per step.
1305
1309
 
1306
1310
 
1307
1311
 
@@ -1311,22 +1315,15 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1311
1315
 
1312
1316
 
1313
1317
  * @example
1314
- * // Key-count pairs
1318
+ * // Iterate with multiplicity
1315
1319
  * const ms = new TreeMultiSet<number>();
1316
- * ms.add(1, 2);
1317
- * ms.add(3);
1318
- * console.log(ms.toEntries()); // [[1, 2], [3, 1]];
1319
- */
1320
- toEntries(): Array<[K, number]>;
1321
- /**
1322
- * Expose comparator for advanced usage/testing (read-only).
1323
- * @remarks Time O(1), Space O(1)
1320
+ * ms.add(5); ms.add(5); ms.add(10);
1321
+ * console.log([...ms.values()]); // [5, 5, 10];
1324
1322
  */
1325
- get comparator(): Comparator<K>;
1323
+ values(): IterableIterator<K>;
1326
1324
  /**
1327
- * Remove all elements from the multiset.
1328
- * @remarks Time O(1), Space O(1)
1329
-
1325
+ * Returns an array with all elements (expanded).
1326
+ * @remarks Time O(size), Space O(size)
1330
1327
 
1331
1328
 
1332
1329
 
@@ -1485,7 +1482,340 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1485
1482
 
1486
1483
 
1487
1484
 
1488
- * @example
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
+ * @example
1521
+ * // All elements (with duplicates)
1522
+ * const ms = new TreeMultiSet<number>();
1523
+ * ms.add(1, 2);
1524
+ * ms.add(2);
1525
+ * console.log(ms.toArray()); // [1, 1, 2];
1526
+ */
1527
+ toArray(): K[];
1528
+ /**
1529
+ * Returns an array with distinct keys only.
1530
+ * @remarks Time O(n), Space O(n)
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
+ * @example
1565
+ * // Unique keys only
1566
+ * const ms = new TreeMultiSet<number>();
1567
+ * ms.add(1, 3);
1568
+ * ms.add(2);
1569
+ * console.log(ms.toDistinctArray()); // [1, 2];
1570
+ */
1571
+ toDistinctArray(): K[];
1572
+ /**
1573
+ * Returns an array of [key, count] entries.
1574
+ * @remarks Time O(n), Space O(n)
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
+ * @example
1609
+ * // Key-count pairs
1610
+ * const ms = new TreeMultiSet<number>();
1611
+ * ms.add(1, 2);
1612
+ * ms.add(3);
1613
+ * console.log(ms.toEntries()); // [[1, 2], [3, 1]];
1614
+ */
1615
+ toEntries(): Array<[K, number]>;
1616
+ /**
1617
+ * Expose comparator for advanced usage/testing (read-only).
1618
+ * @remarks Time O(1), Space O(1)
1619
+ */
1620
+ get comparator(): Comparator<K>;
1621
+ /**
1622
+ * Remove all elements from the multiset.
1623
+ * @remarks Time O(1), Space O(1)
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
+
1657
+
1658
+
1659
+
1660
+
1661
+
1662
+
1663
+
1664
+
1665
+
1666
+
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
+
1699
+
1700
+
1701
+
1702
+
1703
+
1704
+
1705
+
1706
+
1707
+
1708
+
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
+
1741
+
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+
1754
+
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+
1795
+
1796
+
1797
+
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+
1812
+
1813
+
1814
+
1815
+
1816
+
1817
+
1818
+ * @example
1489
1819
  * // Remove all
1490
1820
  * const ms = new TreeMultiSet<number>();
1491
1821
  * ms.add(1);
@@ -1515,6 +1845,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1515
1845
 
1516
1846
 
1517
1847
 
1848
+
1849
+
1850
+
1851
+
1852
+
1853
+
1854
+
1518
1855
 
1519
1856
 
1520
1857
 
@@ -1553,6 +1890,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1553
1890
 
1554
1891
 
1555
1892
 
1893
+
1894
+
1895
+
1896
+
1897
+
1898
+
1899
+
1556
1900
 
1557
1901
 
1558
1902
 
@@ -1591,6 +1935,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1591
1935
 
1592
1936
 
1593
1937
 
1938
+
1939
+
1940
+
1941
+
1942
+
1943
+
1944
+
1594
1945
 
1595
1946
 
1596
1947
 
@@ -1630,6 +1981,13 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1630
1981
 
1631
1982
 
1632
1983
 
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1633
1991
 
1634
1992
 
1635
1993
 
@@ -1754,6 +2112,34 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1754
2112
 
1755
2113
 
1756
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
+
1757
2143
 
1758
2144
 
1759
2145
 
@@ -1892,6 +2278,200 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1892
2278
 
1893
2279
 
1894
2280
 
2281
+
2282
+
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+
2289
+
2290
+
2291
+
2292
+
2293
+
2294
+
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2306
+
2307
+
2308
+
2309
+
2310
+
2311
+
2312
+
2313
+
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+
2324
+
2325
+
2326
+
2327
+
2328
+
2329
+
2330
+ * @example
2331
+ * // Greatest key ≤ target
2332
+ * const ms = new TreeMultiSet<number>();
2333
+ * ms.add(10);
2334
+ * ms.add(20);
2335
+ * ms.add(30);
2336
+ * console.log(ms.floor(25)); // 20;
2337
+ */
2338
+ floor(key: K): K | undefined;
2339
+ /**
2340
+ * Returns the smallest key > given key, or undefined.
2341
+ * @remarks Time O(log n), Space O(1)
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+
2366
+
2367
+
2368
+
2369
+
2370
+
2371
+
2372
+
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+
2398
+
2399
+
2400
+
2401
+
2402
+
2403
+
2404
+
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
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
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
+
1895
2475
 
1896
2476
 
1897
2477
 
@@ -1914,16 +2494,15 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1914
2494
 
1915
2495
 
1916
2496
  * @example
1917
- * // Greatest key target
2497
+ * // Least key > target
1918
2498
  * const ms = new TreeMultiSet<number>();
1919
2499
  * ms.add(10);
1920
2500
  * ms.add(20);
1921
- * ms.add(30);
1922
- * console.log(ms.floor(25)); // 20;
2501
+ * console.log(ms.higher(10)); // 20;
1923
2502
  */
1924
- floor(key: K): K | undefined;
2503
+ higher(key: K): K | undefined;
1925
2504
  /**
1926
- * Returns the smallest key > given key, or undefined.
2505
+ * Returns the largest key < given key, or undefined.
1927
2506
  * @remarks Time O(log n), Space O(1)
1928
2507
 
1929
2508
 
@@ -2051,18 +2630,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2051
2630
 
2052
2631
 
2053
2632
 
2054
- * @example
2055
- * // Least key > target
2056
- * const ms = new TreeMultiSet<number>();
2057
- * ms.add(10);
2058
- * ms.add(20);
2059
- * console.log(ms.higher(10)); // 20;
2060
- */
2061
- higher(key: K): K | undefined;
2062
- /**
2063
- * Returns the largest key < given key, or undefined.
2064
- * @remarks Time O(log n), Space O(1)
2065
-
2066
2633
 
2067
2634
 
2068
2635
 
@@ -2091,6 +2658,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2091
2658
 
2092
2659
 
2093
2660
 
2661
+ * @example
2662
+ * // Greatest key < target
2663
+ * const ms = new TreeMultiSet<number>();
2664
+ * ms.add(10);
2665
+ * ms.add(20);
2666
+ * console.log(ms.lower(20)); // 10;
2667
+ */
2668
+ lower(key: K): K | undefined;
2669
+ /**
2670
+ * Iterates over distinct keys with their counts.
2671
+ * @remarks Time O(n), Space O(1)
2672
+
2094
2673
 
2095
2674
 
2096
2675
 
@@ -2188,18 +2767,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2188
2767
 
2189
2768
 
2190
2769
 
2191
- * @example
2192
- * // Greatest key < target
2193
- * const ms = new TreeMultiSet<number>();
2194
- * ms.add(10);
2195
- * ms.add(20);
2196
- * console.log(ms.lower(20)); // 10;
2197
- */
2198
- lower(key: K): K | undefined;
2199
- /**
2200
- * Iterates over distinct keys with their counts.
2201
- * @remarks Time O(n), Space O(1)
2202
-
2203
2770
 
2204
2771
 
2205
2772
 
@@ -2296,6 +2863,20 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2296
2863
 
2297
2864
 
2298
2865
 
2866
+ * @example
2867
+ * // Iterate
2868
+ * const ms = new TreeMultiSet<number>();
2869
+ * ms.add(1, 2);
2870
+ * ms.add(2);
2871
+ * const pairs: [number, number][] = [];
2872
+ * ms.forEach((k, c) => pairs.push([k, c]));
2873
+ * console.log(pairs); // [[1, 2], [2, 1]];
2874
+ */
2875
+ forEach(callback: (key: K, count: number) => void): void;
2876
+ /**
2877
+ * Creates a new TreeMultiSet with entries that match the predicate.
2878
+ * @remarks Time O(n log n), Space O(n)
2879
+
2299
2880
 
2300
2881
 
2301
2882
 
@@ -2358,20 +2939,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2358
2939
 
2359
2940
 
2360
2941
 
2361
- * @example
2362
- * // Iterate
2363
- * const ms = new TreeMultiSet<number>();
2364
- * ms.add(1, 2);
2365
- * ms.add(2);
2366
- * const pairs: [number, number][] = [];
2367
- * ms.forEach((k, c) => pairs.push([k, c]));
2368
- * console.log(pairs); // [[1, 2], [2, 1]];
2369
- */
2370
- forEach(callback: (key: K, count: number) => void): void;
2371
- /**
2372
- * Creates a new TreeMultiSet with entries that match the predicate.
2373
- * @remarks Time O(n log n), Space O(n)
2374
-
2375
2942
 
2376
2943
 
2377
2944
 
@@ -2503,6 +3070,28 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2503
3070
 
2504
3071
 
2505
3072
 
3073
+ * @example
3074
+ * // Filter
3075
+ * const ms = new TreeMultiSet<number>();
3076
+ * ms.add(1, 3);
3077
+ * ms.add(2, 1);
3078
+ * ms.add(3, 2);
3079
+ * const filtered = ms.filter((k, c) => c > 1);
3080
+ * console.log([...filtered.keysDistinct()]); // [1, 3];
3081
+ */
3082
+ filter(predicate: (key: K, count: number) => boolean): TreeMultiSet<K>;
3083
+ /**
3084
+ * Reduces the multiset to a single value.
3085
+ * @remarks Time O(n), Space O(1)
3086
+
3087
+
3088
+
3089
+
3090
+
3091
+
3092
+
3093
+
3094
+
2506
3095
 
2507
3096
 
2508
3097
 
@@ -2530,20 +3119,6 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2530
3119
 
2531
3120
 
2532
3121
 
2533
- * @example
2534
- * // Filter
2535
- * const ms = new TreeMultiSet<number>();
2536
- * ms.add(1, 3);
2537
- * ms.add(2, 1);
2538
- * ms.add(3, 2);
2539
- * const filtered = ms.filter((k, c) => c > 1);
2540
- * console.log([...filtered.keysDistinct()]); // [1, 3];
2541
- */
2542
- filter(predicate: (key: K, count: number) => boolean): TreeMultiSet<K>;
2543
- /**
2544
- * Reduces the multiset to a single value.
2545
- * @remarks Time O(n), Space O(1)
2546
-
2547
3122
 
2548
3123
 
2549
3124
 
@@ -2853,6 +3428,41 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2853
3428
 
2854
3429
 
2855
3430
 
3431
+
3432
+
3433
+
3434
+
3435
+
3436
+
3437
+
3438
+
3439
+
3440
+
3441
+
3442
+
3443
+
3444
+
3445
+
3446
+
3447
+
3448
+
3449
+
3450
+
3451
+
3452
+
3453
+
3454
+
3455
+
3456
+
3457
+
3458
+
3459
+
3460
+
3461
+
3462
+
3463
+
3464
+
3465
+
2856
3466
 
2857
3467
 
2858
3468
 
@@ -3070,8 +3680,22 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
3070
3680
  /**
3071
3681
  * Get elements by rank range
3072
3682
 
3683
+
3684
+
3685
+
3686
+
3687
+
3688
+
3689
+
3690
+
3691
+
3692
+
3693
+
3694
+
3695
+
3696
+
3073
3697
  * @example
3074
- * // Pagination with rangeByRank
3698
+ * // Pagination by position in tree order
3075
3699
  * const tree = new TreeMultiSet<number>(
3076
3700
  * [10, 20, 30, 40, 50, 60, 70, 80, 90],
3077
3701
  * { enableOrderStatistic: true }
@@ -3092,6 +3716,41 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
3092
3716
 
3093
3717
 
3094
3718
 
3719
+
3720
+
3721
+
3722
+
3723
+
3724
+
3725
+
3726
+
3727
+
3728
+
3729
+
3730
+
3731
+
3732
+
3733
+
3734
+
3735
+
3736
+
3737
+
3738
+
3739
+
3740
+
3741
+
3742
+
3743
+
3744
+
3745
+
3746
+
3747
+
3748
+
3749
+
3750
+
3751
+
3752
+
3753
+
3095
3754
  * @example
3096
3755
  * // Deep clone
3097
3756
  * const ms = new TreeMultiSet<number>();
@@ -3209,6 +3868,34 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
3209
3868
 
3210
3869
 
3211
3870
 
3871
+
3872
+
3873
+
3874
+
3875
+
3876
+
3877
+
3878
+
3879
+
3880
+
3881
+
3882
+
3883
+
3884
+
3885
+
3886
+
3887
+
3888
+
3889
+
3890
+
3891
+
3892
+
3893
+
3894
+
3895
+
3896
+
3897
+
3898
+
3212
3899
 
3213
3900
 
3214
3901
 
@@ -3381,6 +4068,41 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
3381
4068
 
3382
4069
 
3383
4070
 
4071
+
4072
+
4073
+
4074
+
4075
+
4076
+
4077
+
4078
+
4079
+
4080
+
4081
+
4082
+
4083
+
4084
+
4085
+
4086
+
4087
+
4088
+
4089
+
4090
+
4091
+
4092
+
4093
+
4094
+
4095
+
4096
+
4097
+
4098
+
4099
+
4100
+
4101
+
4102
+
4103
+
4104
+
4105
+
3384
4106
 
3385
4107
 
3386
4108