max-priority-queue-typed 2.5.2 → 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.
Files changed (59) hide show
  1. package/dist/cjs/index.cjs +103 -16
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +103 -16
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +103 -16
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +103 -16
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
  10. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  15. package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
  17. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
  18. package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
  19. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  20. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  21. package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
  22. package/dist/types/data-structures/heap/heap.d.ts +98 -12
  23. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
  24. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
  25. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  26. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  27. package/dist/types/data-structures/queue/deque.d.ts +82 -0
  28. package/dist/types/data-structures/queue/queue.d.ts +61 -0
  29. package/dist/types/data-structures/stack/stack.d.ts +42 -2
  30. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  31. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  32. package/dist/umd/max-priority-queue-typed.js +103 -16
  33. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  34. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  35. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/data-structures/binary-tree/avl-tree.ts +52 -5
  38. package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
  39. package/src/data-structures/binary-tree/binary-tree.ts +167 -81
  40. package/src/data-structures/binary-tree/bst.ts +101 -7
  41. package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
  42. package/src/data-structures/binary-tree/segment-tree.ts +24 -0
  43. package/src/data-structures/binary-tree/tree-map.ts +540 -3
  44. package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
  45. package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
  46. package/src/data-structures/binary-tree/tree-set.ts +520 -3
  47. package/src/data-structures/graph/directed-graph.ts +41 -1
  48. package/src/data-structures/graph/undirected-graph.ts +37 -1
  49. package/src/data-structures/hash/hash-map.ts +67 -12
  50. package/src/data-structures/heap/heap.ts +107 -19
  51. package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
  52. package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
  53. package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
  54. package/src/data-structures/matrix/matrix.ts +32 -0
  55. package/src/data-structures/queue/deque.ts +85 -0
  56. package/src/data-structures/queue/queue.ts +73 -0
  57. package/src/data-structures/stack/stack.ts +45 -5
  58. package/src/data-structures/trie/trie.ts +48 -0
  59. package/src/interfaces/binary-tree.ts +1 -9
@@ -191,6 +191,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
191
191
 
192
192
 
193
193
 
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
194
214
 
195
215
 
196
216
 
@@ -361,6 +381,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
361
381
 
362
382
 
363
383
 
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
364
404
 
365
405
 
366
406
 
@@ -395,6 +435,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
395
435
  * console.log(tags.last()); // 'typescript';
396
436
  */
397
437
  add(key: K): this;
438
+ /**
439
+ * Add multiple keys at once.
440
+ * @remarks Expected time O(m log n), where m is the number of keys.
441
+ * @param keys - Iterable of keys to add.
442
+ * @returns Array of booleans indicating whether each key was newly added.
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+ * @example
460
+ * // Add multiple keys
461
+ * const ts = new TreeSet<number>();
462
+ * ts.addMany([5, 3, 7, 1, 9]);
463
+ * console.log(ts.size); // 5;
464
+ */
465
+ addMany(keys: Iterable<K>): boolean[];
398
466
  /**
399
467
  * Test whether a key exists.
400
468
  * @remarks Expected time O(log n)
@@ -546,6 +614,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
546
614
 
547
615
 
548
616
 
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
549
637
 
550
638
 
551
639
 
@@ -727,6 +815,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
727
815
 
728
816
 
729
817
 
818
+
819
+
820
+
821
+
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
730
838
 
731
839
 
732
840
 
@@ -757,6 +865,13 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
757
865
  * console.log([...nums]); // [1, 3, 7, 9];
758
866
  */
759
867
  delete(key: K): boolean;
868
+ /**
869
+ * Delete all keys matching a predicate.
870
+ * @remarks Time O(N), Space O(N)
871
+ * @param predicate - Function (key, index, set) → boolean; return true to delete.
872
+ * @returns True if at least one key was deleted.
873
+ */
874
+ deleteWhere(predicate: (key: K, index: number, set: this) => boolean): boolean;
760
875
  /**
761
876
  * Remove all keys.
762
877
 
@@ -896,6 +1011,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
896
1011
 
897
1012
 
898
1013
 
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
899
1034
 
900
1035
 
901
1036
 
@@ -1063,6 +1198,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1063
1198
 
1064
1199
 
1065
1200
 
1201
+
1202
+
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1066
1221
 
1067
1222
 
1068
1223
 
@@ -1231,6 +1386,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1231
1386
 
1232
1387
 
1233
1388
 
1389
+
1390
+
1391
+
1392
+
1393
+
1394
+
1395
+
1396
+
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1234
1409
 
1235
1410
 
1236
1411
 
@@ -1399,6 +1574,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1399
1574
 
1400
1575
 
1401
1576
 
1577
+
1578
+
1579
+
1580
+
1581
+
1582
+
1583
+
1584
+
1585
+
1586
+
1587
+
1588
+
1589
+
1590
+
1591
+
1592
+
1593
+
1594
+
1595
+
1596
+
1402
1597
 
1403
1598
 
1404
1599
 
@@ -1568,6 +1763,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1568
1763
 
1569
1764
 
1570
1765
 
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+
1571
1786
 
1572
1787
 
1573
1788
 
@@ -1739,6 +1954,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1739
1954
 
1740
1955
 
1741
1956
 
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+
1742
1977
 
1743
1978
 
1744
1979
 
@@ -1909,6 +2144,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1909
2144
 
1910
2145
 
1911
2146
 
2147
+
2148
+
2149
+
2150
+
2151
+
2152
+
2153
+
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+
2165
+
2166
+
1912
2167
 
1913
2168
 
1914
2169
 
@@ -2077,6 +2332,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2077
2332
 
2078
2333
 
2079
2334
 
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2080
2355
 
2081
2356
 
2082
2357
 
@@ -2243,6 +2518,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2243
2518
 
2244
2519
 
2245
2520
 
2521
+
2522
+
2523
+
2524
+
2525
+
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2246
2541
 
2247
2542
 
2248
2543
 
@@ -2408,6 +2703,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2408
2703
 
2409
2704
 
2410
2705
 
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2725
+
2411
2726
 
2412
2727
 
2413
2728
 
@@ -2573,6 +2888,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2573
2888
 
2574
2889
 
2575
2890
 
2891
+
2892
+
2893
+
2894
+
2895
+
2896
+
2897
+
2898
+
2899
+
2900
+
2901
+
2902
+
2903
+
2904
+
2905
+
2906
+
2907
+
2908
+
2909
+
2910
+
2576
2911
 
2577
2912
 
2578
2913
 
@@ -2741,6 +3076,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2741
3076
 
2742
3077
 
2743
3078
 
3079
+
3080
+
3081
+
3082
+
3083
+
3084
+
3085
+
3086
+
3087
+
3088
+
3089
+
3090
+
3091
+
3092
+
3093
+
3094
+
3095
+
3096
+
3097
+
3098
+
2744
3099
 
2745
3100
 
2746
3101
 
@@ -2908,6 +3263,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2908
3263
 
2909
3264
 
2910
3265
 
3266
+
3267
+
3268
+
3269
+
3270
+
3271
+
3272
+
3273
+
3274
+
3275
+
3276
+
3277
+
3278
+
3279
+
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
2911
3286
 
2912
3287
 
2913
3288
 
@@ -2967,6 +3342,10 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2967
3342
 
2968
3343
 
2969
3344
 
3345
+
3346
+
3347
+
3348
+
2970
3349
 
2971
3350
 
2972
3351
 
@@ -3033,6 +3412,10 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3033
3412
 
3034
3413
 
3035
3414
 
3415
+
3416
+
3417
+
3418
+
3036
3419
 
3037
3420
 
3038
3421
 
@@ -3077,6 +3460,10 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3077
3460
 
3078
3461
 
3079
3462
 
3463
+
3464
+
3465
+
3466
+
3080
3467
 
3081
3468
 
3082
3469
 
@@ -3123,6 +3510,10 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3123
3510
 
3124
3511
 
3125
3512
 
3513
+
3514
+
3515
+
3516
+
3126
3517
 
3127
3518
 
3128
3519
 
@@ -3255,6 +3646,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3255
3646
 
3256
3647
 
3257
3648
 
3649
+
3650
+
3651
+
3652
+
3653
+
3654
+
3655
+
3656
+
3657
+
3658
+
3659
+
3660
+
3661
+
3662
+
3663
+
3664
+
3258
3665
 
3259
3666
 
3260
3667
 
@@ -3409,6 +3816,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3409
3816
 
3410
3817
 
3411
3818
 
3819
+
3820
+
3821
+
3822
+
3823
+
3824
+
3825
+
3826
+
3827
+
3828
+
3829
+
3830
+
3831
+
3832
+
3833
+
3834
+
3412
3835
 
3413
3836
 
3414
3837
 
@@ -3555,6 +3978,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3555
3978
 
3556
3979
 
3557
3980
 
3981
+
3982
+
3983
+
3984
+
3985
+
3986
+
3987
+
3988
+
3989
+
3990
+
3991
+
3992
+
3993
+
3994
+
3995
+
3996
+
3558
3997
 
3559
3998
 
3560
3999
 
@@ -3699,6 +4138,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3699
4138
 
3700
4139
 
3701
4140
 
4141
+
4142
+
4143
+
4144
+
4145
+
4146
+
4147
+
4148
+
4149
+
4150
+
4151
+
4152
+
4153
+
4154
+
4155
+
4156
+
3702
4157
 
3703
4158
 
3704
4159
 
@@ -3846,6 +4301,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3846
4301
 
3847
4302
 
3848
4303
 
4304
+
4305
+
4306
+
4307
+
4308
+
4309
+
4310
+
4311
+
4312
+
4313
+
4314
+
4315
+
4316
+
4317
+
4318
+
4319
+
3849
4320
 
3850
4321
 
3851
4322
 
@@ -3915,8 +4386,16 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3915
4386
  * Returns elements by rank range (0-indexed, inclusive on both ends).
3916
4387
  * @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
3917
4388
 
4389
+
4390
+
4391
+
4392
+
4393
+
4394
+
4395
+
4396
+
3918
4397
  * @example
3919
- * // Pagination with rangeByRank
4398
+ * // Pagination by position in tree order
3920
4399
  * const tree = new TreeSet<number>(
3921
4400
  * [10, 20, 30, 40, 50, 60, 70, 80, 90],
3922
4401
  * { enableOrderStatistic: true }
@@ -4072,6 +4551,26 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4072
4551
 
4073
4552
 
4074
4553
 
4554
+
4555
+
4556
+
4557
+
4558
+
4559
+
4560
+
4561
+
4562
+
4563
+
4564
+
4565
+
4566
+
4567
+
4568
+
4569
+
4570
+
4571
+
4572
+
4573
+
4075
4574
 
4076
4575
 
4077
4576