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
@@ -192,6 +192,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
192
192
 
193
193
 
194
194
 
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
195
215
 
196
216
 
197
217
 
@@ -367,6 +387,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
367
387
 
368
388
 
369
389
 
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
370
410
 
371
411
 
372
412
 
@@ -410,6 +450,34 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
410
450
  * // ];
411
451
  */
412
452
  set(key: K, value: V | undefined): this;
453
+ /**
454
+ * Set multiple key-value pairs at once.
455
+ * @remarks Expected time O(m log n), where m is the number of entries.
456
+ * @param entries - Iterable of `[key, value]` tuples.
457
+ * @returns Array of booleans indicating whether each entry was successfully set.
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+ * @example
475
+ * // Set multiple key-value pairs
476
+ * const tm = new TreeMap<number, string>();
477
+ * tm.setMany([[1, 'a'], [2, 'b'], [3, 'c']]);
478
+ * console.log(tm.size); // 3;
479
+ */
480
+ setMany(entries: Iterable<[K, V | undefined]>): boolean[];
413
481
  /**
414
482
  * Get the value under a key.
415
483
  * @remarks Expected time O(log n)
@@ -561,6 +629,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
561
629
 
562
630
 
563
631
 
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
564
652
 
565
653
 
566
654
 
@@ -746,6 +834,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
746
834
 
747
835
 
748
836
 
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+
851
+
852
+
853
+
854
+
855
+
856
+
749
857
 
750
858
 
751
859
 
@@ -931,6 +1039,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
931
1039
 
932
1040
 
933
1041
 
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
1061
+
934
1062
 
935
1063
 
936
1064
 
@@ -966,6 +1094,13 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
966
1094
  * console.log(sessions.size); // 2;
967
1095
  */
968
1096
  delete(key: K): boolean;
1097
+ /**
1098
+ * Delete all entries matching a predicate.
1099
+ * @remarks Time O(N), Space O(N)
1100
+ * @param predicate - Function (key, value, index, map) → boolean; return true to delete.
1101
+ * @returns True if at least one entry was deleted.
1102
+ */
1103
+ deleteWhere(predicate: (key: K, value: V | undefined, index: number, map: this) => boolean): boolean;
969
1104
  /**
970
1105
  * Remove all entries.
971
1106
 
@@ -1105,6 +1240,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1105
1240
 
1106
1241
 
1107
1242
 
1243
+
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1108
1263
 
1109
1264
 
1110
1265
 
@@ -1272,6 +1427,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1272
1427
 
1273
1428
 
1274
1429
 
1430
+
1431
+
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1442
+
1443
+
1444
+
1445
+
1446
+
1447
+
1448
+
1449
+
1275
1450
 
1276
1451
 
1277
1452
 
@@ -1441,6 +1616,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1441
1616
 
1442
1617
 
1443
1618
 
1619
+
1620
+
1621
+
1622
+
1623
+
1624
+
1625
+
1626
+
1627
+
1628
+
1629
+
1630
+
1631
+
1632
+
1633
+
1634
+
1635
+
1636
+
1637
+
1638
+
1444
1639
 
1445
1640
 
1446
1641
 
@@ -1609,6 +1804,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1609
1804
 
1610
1805
 
1611
1806
 
1807
+
1808
+
1809
+
1810
+
1811
+
1812
+
1813
+
1814
+
1815
+
1816
+
1817
+
1818
+
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+
1826
+
1612
1827
 
1613
1828
 
1614
1829
 
@@ -1778,6 +1993,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1778
1993
 
1779
1994
 
1780
1995
 
1996
+
1997
+
1998
+
1999
+
2000
+
2001
+
2002
+
2003
+
2004
+
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+
2011
+
2012
+
2013
+
2014
+
2015
+
1781
2016
 
1782
2017
 
1783
2018
 
@@ -1949,6 +2184,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
1949
2184
 
1950
2185
 
1951
2186
 
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
2195
+
2196
+
2197
+
2198
+
2199
+
2200
+
2201
+
2202
+
2203
+
2204
+
2205
+
2206
+
1952
2207
 
1953
2208
 
1954
2209
 
@@ -2119,6 +2374,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2119
2374
 
2120
2375
 
2121
2376
 
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2122
2397
 
2123
2398
 
2124
2399
 
@@ -2287,6 +2562,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2287
2562
 
2288
2563
 
2289
2564
 
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2290
2585
 
2291
2586
 
2292
2587
 
@@ -2452,6 +2747,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2452
2747
 
2453
2748
 
2454
2749
 
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2769
+
2455
2770
 
2456
2771
 
2457
2772
 
@@ -2617,6 +2932,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2617
2932
 
2618
2933
 
2619
2934
 
2935
+
2936
+
2937
+
2938
+
2939
+
2940
+
2941
+
2942
+
2943
+
2944
+
2945
+
2946
+
2947
+
2948
+
2949
+
2950
+
2951
+
2952
+
2953
+
2954
+
2620
2955
 
2621
2956
 
2622
2957
 
@@ -2783,6 +3118,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2783
3118
 
2784
3119
 
2785
3120
 
3121
+
3122
+
3123
+
3124
+
3125
+
3126
+
3127
+
3128
+
3129
+
3130
+
3131
+
3132
+
3133
+
3134
+
3135
+
3136
+
3137
+
3138
+
3139
+
3140
+
2786
3141
 
2787
3142
 
2788
3143
 
@@ -2950,6 +3305,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
2950
3305
 
2951
3306
 
2952
3307
 
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3319
+
3320
+
3321
+
3322
+
3323
+
3324
+
3325
+
3326
+
3327
+
2953
3328
 
2954
3329
 
2955
3330
 
@@ -3117,6 +3492,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3117
3492
 
3118
3493
 
3119
3494
 
3495
+
3496
+
3497
+
3498
+
3499
+
3500
+
3501
+
3502
+
3503
+
3504
+
3505
+
3506
+
3507
+
3508
+
3509
+
3510
+
3511
+
3512
+
3513
+
3514
+
3120
3515
 
3121
3516
 
3122
3517
 
@@ -3176,6 +3571,10 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3176
3571
 
3177
3572
 
3178
3573
 
3574
+
3575
+
3576
+
3577
+
3179
3578
 
3180
3579
 
3181
3580
 
@@ -3241,6 +3640,10 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3241
3640
 
3242
3641
 
3243
3642
 
3643
+
3644
+
3645
+
3646
+
3244
3647
 
3245
3648
 
3246
3649
 
@@ -3290,6 +3693,10 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3290
3693
 
3291
3694
 
3292
3695
 
3696
+
3697
+
3698
+
3699
+
3293
3700
 
3294
3701
 
3295
3702
 
@@ -3341,6 +3748,10 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3341
3748
 
3342
3749
 
3343
3750
 
3751
+
3752
+
3753
+
3754
+
3344
3755
 
3345
3756
 
3346
3757
 
@@ -3479,6 +3890,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3479
3890
 
3480
3891
 
3481
3892
 
3893
+
3894
+
3895
+
3896
+
3897
+
3898
+
3899
+
3900
+
3901
+
3902
+
3903
+
3904
+
3905
+
3906
+
3907
+
3908
+
3482
3909
 
3483
3910
 
3484
3911
 
@@ -3648,6 +4075,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3648
4075
 
3649
4076
 
3650
4077
 
4078
+
4079
+
4080
+
4081
+
4082
+
4083
+
4084
+
4085
+
4086
+
4087
+
4088
+
4089
+
4090
+
4091
+
4092
+
4093
+
3651
4094
 
3652
4095
 
3653
4096
 
@@ -3801,6 +4244,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3801
4244
 
3802
4245
 
3803
4246
 
4247
+
4248
+
4249
+
4250
+
4251
+
4252
+
4253
+
4254
+
4255
+
4256
+
4257
+
4258
+
4259
+
4260
+
4261
+
4262
+
3804
4263
 
3805
4264
 
3806
4265
 
@@ -3954,6 +4413,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
3954
4413
 
3955
4414
 
3956
4415
 
4416
+
4417
+
4418
+
4419
+
4420
+
4421
+
4422
+
4423
+
4424
+
4425
+
4426
+
4427
+
4428
+
4429
+
4430
+
4431
+
3957
4432
 
3958
4433
 
3959
4434
 
@@ -4108,6 +4583,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
4108
4583
 
4109
4584
 
4110
4585
 
4586
+
4587
+
4588
+
4589
+
4590
+
4591
+
4592
+
4593
+
4594
+
4595
+
4596
+
4597
+
4598
+
4599
+
4600
+
4601
+
4111
4602
 
4112
4603
 
4113
4604
 
@@ -4193,8 +4684,16 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
4193
4684
  * Returns keys by rank range (0-indexed, inclusive on both ends).
4194
4685
  * @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
4195
4686
 
4687
+
4688
+
4689
+
4690
+
4691
+
4692
+
4693
+
4694
+
4196
4695
  * @example
4197
- * // Pagination with rangeByRank
4696
+ * // Pagination by position in tree order
4198
4697
  * const tree = new TreeMap<number>(
4199
4698
  * [10, 20, 30, 40, 50, 60, 70, 80, 90],
4200
4699
  * { enableOrderStatistic: true }
@@ -4350,6 +4849,26 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
4350
4849
 
4351
4850
 
4352
4851
 
4852
+
4853
+
4854
+
4855
+
4856
+
4857
+
4858
+
4859
+
4860
+
4861
+
4862
+
4863
+
4864
+
4865
+
4866
+
4867
+
4868
+
4869
+
4870
+
4871
+
4353
4872
 
4354
4873
 
4355
4874