max-priority-queue-typed 2.5.1 → 2.5.2

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 (73) hide show
  1. package/dist/cjs/index.cjs +104 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +103 -54
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +104 -56
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +103 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +77 -2
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +409 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +51 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +45 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  34. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  37. package/dist/umd/max-priority-queue-typed.js +101 -53
  38. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  39. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/common/error.ts +19 -1
  43. package/src/common/index.ts +1 -1
  44. package/src/data-structures/base/iterable-element-base.ts +3 -2
  45. package/src/data-structures/binary-tree/avl-tree.ts +47 -0
  46. package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
  47. package/src/data-structures/binary-tree/binary-tree.ts +79 -4
  48. package/src/data-structures/binary-tree/bst.ts +441 -6
  49. package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
  50. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  51. package/src/data-structures/binary-tree/tree-map.ts +434 -9
  52. package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
  53. package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
  54. package/src/data-structures/binary-tree/tree-set.ts +410 -8
  55. package/src/data-structures/graph/abstract-graph.ts +2 -2
  56. package/src/data-structures/graph/directed-graph.ts +30 -0
  57. package/src/data-structures/graph/undirected-graph.ts +27 -0
  58. package/src/data-structures/hash/hash-map.ts +35 -4
  59. package/src/data-structures/heap/heap.ts +46 -4
  60. package/src/data-structures/heap/max-heap.ts +2 -2
  61. package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
  62. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  63. package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
  64. package/src/data-structures/matrix/matrix.ts +33 -9
  65. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  66. package/src/data-structures/queue/deque.ts +45 -0
  67. package/src/data-structures/queue/queue.ts +36 -0
  68. package/src/data-structures/stack/stack.ts +30 -0
  69. package/src/data-structures/trie/trie.ts +38 -2
  70. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  71. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  72. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  73. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -62,6 +62,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
62
62
 
63
63
 
64
64
 
65
+
66
+
67
+
65
68
 
66
69
 
67
70
 
@@ -204,6 +207,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
204
207
 
205
208
 
206
209
 
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
207
225
 
208
226
 
209
227
 
@@ -358,6 +376,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
358
376
 
359
377
 
360
378
 
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
361
394
 
362
395
 
363
396
 
@@ -404,6 +437,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
404
437
 
405
438
 
406
439
 
440
+
441
+
442
+
407
443
 
408
444
 
409
445
 
@@ -540,6 +576,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
540
576
 
541
577
 
542
578
 
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
543
594
 
544
595
 
545
596
 
@@ -589,6 +640,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
589
640
 
590
641
 
591
642
 
643
+
644
+
645
+
592
646
 
593
647
 
594
648
 
@@ -734,6 +788,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
734
788
 
735
789
 
736
790
 
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
737
806
 
738
807
 
739
808
 
@@ -781,6 +850,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
781
850
 
782
851
 
783
852
 
853
+
854
+
855
+
784
856
 
785
857
 
786
858
 
@@ -815,6 +887,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
815
887
 
816
888
 
817
889
 
890
+
891
+
892
+
818
893
 
819
894
 
820
895
 
@@ -957,6 +1032,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
957
1032
 
958
1033
 
959
1034
 
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
960
1050
 
961
1051
 
962
1052
 
@@ -1115,6 +1205,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1115
1205
 
1116
1206
 
1117
1207
 
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1118
1223
 
1119
1224
 
1120
1225
 
@@ -1161,6 +1266,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1161
1266
 
1162
1267
 
1163
1268
 
1269
+
1270
+
1271
+
1164
1272
 
1165
1273
 
1166
1274
 
@@ -1195,6 +1303,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1195
1303
 
1196
1304
 
1197
1305
 
1306
+
1307
+
1308
+
1198
1309
 
1199
1310
 
1200
1311
 
@@ -1343,6 +1454,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1343
1454
 
1344
1455
 
1345
1456
 
1457
+
1458
+
1459
+
1460
+
1461
+
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+
1468
+
1469
+
1470
+
1471
+
1346
1472
 
1347
1473
 
1348
1474
 
@@ -1390,6 +1516,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1390
1516
 
1391
1517
 
1392
1518
 
1519
+
1520
+
1521
+
1393
1522
 
1394
1523
 
1395
1524
 
@@ -1425,6 +1554,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1425
1554
 
1426
1555
 
1427
1556
 
1557
+
1558
+
1559
+
1428
1560
 
1429
1561
 
1430
1562
 
@@ -1460,6 +1592,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1460
1592
 
1461
1593
 
1462
1594
 
1595
+
1596
+
1597
+
1463
1598
 
1464
1599
 
1465
1600
 
@@ -1496,6 +1631,9 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1496
1631
 
1497
1632
 
1498
1633
 
1634
+
1635
+
1636
+
1499
1637
 
1500
1638
 
1501
1639
 
@@ -1612,6 +1750,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1612
1750
 
1613
1751
 
1614
1752
 
1753
+
1754
+
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1615
1765
 
1616
1766
 
1617
1767
 
@@ -1738,6 +1888,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1738
1888
 
1739
1889
 
1740
1890
 
1891
+
1892
+
1893
+
1894
+
1895
+
1896
+
1897
+
1898
+
1899
+
1900
+
1901
+
1902
+
1741
1903
 
1742
1904
 
1743
1905
 
@@ -1864,6 +2026,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1864
2026
 
1865
2027
 
1866
2028
 
2029
+
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+
2036
+
2037
+
2038
+
2039
+
2040
+
1867
2041
 
1868
2042
 
1869
2043
 
@@ -1989,6 +2163,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
1989
2163
 
1990
2164
 
1991
2165
 
2166
+
2167
+
2168
+
2169
+
2170
+
2171
+
2172
+
2173
+
2174
+
2175
+
2176
+
2177
+
1992
2178
 
1993
2179
 
1994
2180
 
@@ -2141,6 +2327,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2141
2327
 
2142
2328
 
2143
2329
 
2330
+
2331
+
2332
+
2333
+
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2144
2345
 
2145
2346
 
2146
2347
 
@@ -2298,6 +2499,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2298
2499
 
2299
2500
 
2300
2501
 
2502
+
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2516
+
2301
2517
 
2302
2518
 
2303
2519
 
@@ -2455,6 +2671,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2455
2671
 
2456
2672
 
2457
2673
 
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2458
2689
 
2459
2690
 
2460
2691
 
@@ -2612,6 +2843,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2612
2843
 
2613
2844
 
2614
2845
 
2846
+
2847
+
2848
+
2849
+
2850
+
2851
+
2852
+
2853
+
2854
+
2855
+
2856
+
2857
+
2858
+
2859
+
2860
+
2615
2861
 
2616
2862
 
2617
2863
 
@@ -2772,6 +3018,19 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2772
3018
 
2773
3019
 
2774
3020
 
3021
+
3022
+
3023
+
3024
+
3025
+
3026
+
3027
+
3028
+
3029
+
3030
+
3031
+
3032
+
3033
+
2775
3034
 
2776
3035
 
2777
3036
 
@@ -2787,13 +3046,60 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2787
3046
 
2788
3047
 
2789
3048
  * @example
2790
- * // Deep clone
2791
- * const ms = new TreeMultiSet<number>();
2792
- * ms.add(1, 3);
2793
- * const copy = ms.clone();
2794
- * copy.deleteAll(1);
2795
- * console.log(ms.has(1)); // true;
3049
+ * // Order-statistic on BST
3050
+ * const tree = new TreeMultiSet<number>([30, 10, 50, 20, 40], { enableOrderStatistic: true });
3051
+ * console.log(tree.getByRank(0)); // 10;
3052
+ * console.log(tree.getByRank(4)); // 50;
3053
+ * console.log(tree.getRank(30)); // 2;
2796
3054
  */
3055
+ getByRank(k: number): K | undefined;
3056
+ /**
3057
+ * Get the rank of a key in sorted order
3058
+ * @example
3059
+ * // Get the rank of a key in sorted order
3060
+ * const tree = new TreeMultiSet<number>(
3061
+ * [10, 20, 30, 40, 50],
3062
+ * { enableOrderStatistic: true }
3063
+ * );
3064
+ * console.log(tree.getRank(10)); // 0; // smallest → rank 0
3065
+ * console.log(tree.getRank(30)); // 2; // 2 elements before 30 in tree order
3066
+ * console.log(tree.getRank(50)); // 4; // largest → rank 4
3067
+ * console.log(tree.getRank(25)); // 2;
3068
+ */
3069
+ getRank(key: K): number;
3070
+ /**
3071
+ * Get elements by rank range
3072
+
3073
+ * @example
3074
+ * // Pagination with rangeByRank
3075
+ * const tree = new TreeMultiSet<number>(
3076
+ * [10, 20, 30, 40, 50, 60, 70, 80, 90],
3077
+ * { enableOrderStatistic: true }
3078
+ * );
3079
+ * const pageSize = 3;
3080
+ *
3081
+ * // Page 1
3082
+ * console.log(tree.rangeByRank(0, pageSize - 1)); // [10, 20, 30];
3083
+ * // Page 2
3084
+ * console.log(tree.rangeByRank(pageSize, 2 * pageSize - 1)); // [40, 50, 60];
3085
+ * // Page 3
3086
+ * console.log(tree.rangeByRank(2 * pageSize, 3 * pageSize - 1)); // [70, 80, 90];
3087
+ */
3088
+ rangeByRank(start: number, end: number): K[];
3089
+ /**
3090
+ * Deep copy
3091
+
3092
+
3093
+
3094
+
3095
+ * @example
3096
+ * // Deep clone
3097
+ * const ms = new TreeMultiSet<number>();
3098
+ * ms.add(1, 3);
3099
+ * const copy = ms.clone();
3100
+ * copy.deleteAll(1);
3101
+ * console.log(ms.has(1)); // true;
3102
+ */
2797
3103
  clone(): TreeMultiSet<K>;
2798
3104
  /**
2799
3105
  * Returns keys within the given range.
@@ -2899,6 +3205,18 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
2899
3205
 
2900
3206
 
2901
3207
 
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+
3218
+
3219
+
2902
3220
 
2903
3221
 
2904
3222
 
@@ -3053,6 +3371,21 @@ export declare class TreeMultiSet<K = any, R = K> implements Iterable<K> {
3053
3371
 
3054
3372
 
3055
3373
 
3374
+
3375
+
3376
+
3377
+
3378
+
3379
+
3380
+
3381
+
3382
+
3383
+
3384
+
3385
+
3386
+
3387
+
3388
+
3056
3389
 
3057
3390
 
3058
3391