max-priority-queue-typed 2.5.0 → 2.5.1

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 (74) hide show
  1. package/dist/cjs/index.cjs +294 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +294 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +294 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +294 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/index.d.ts +1 -0
  10. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  11. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
  13. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
  14. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
  15. package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
  16. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
  17. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
  18. package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
  19. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
  20. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
  21. package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
  22. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  23. package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
  24. package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
  25. package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
  26. package/dist/types/data-structures/heap/heap.d.ts +294 -0
  27. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
  28. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
  29. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
  30. package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
  31. package/dist/types/data-structures/queue/deque.d.ts +319 -4
  32. package/dist/types/data-structures/queue/queue.d.ts +252 -0
  33. package/dist/types/data-structures/stack/stack.d.ts +210 -0
  34. package/dist/types/data-structures/trie/trie.d.ts +256 -4
  35. package/dist/types/interfaces/graph.d.ts +1 -1
  36. package/dist/types/types/common.d.ts +2 -2
  37. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  38. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  39. package/dist/types/types/utils/validate-type.d.ts +4 -4
  40. package/dist/umd/max-priority-queue-typed.js +294 -0
  41. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  42. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/data-structures/base/index.ts +1 -0
  45. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  46. package/src/data-structures/base/linear-base.ts +3 -3
  47. package/src/data-structures/binary-tree/avl-tree.ts +252 -0
  48. package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
  49. package/src/data-structures/binary-tree/binary-tree.ts +527 -2
  50. package/src/data-structures/binary-tree/bst.ts +505 -1
  51. package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
  52. package/src/data-structures/binary-tree/segment-tree.ts +127 -2
  53. package/src/data-structures/binary-tree/tree-map.ts +2958 -459
  54. package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
  55. package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
  56. package/src/data-structures/binary-tree/tree-set.ts +2816 -422
  57. package/src/data-structures/graph/abstract-graph.ts +4 -4
  58. package/src/data-structures/graph/directed-graph.ts +210 -0
  59. package/src/data-structures/graph/undirected-graph.ts +189 -0
  60. package/src/data-structures/hash/hash-map.ts +246 -15
  61. package/src/data-structures/heap/heap.ts +294 -0
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
  63. package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
  64. package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
  65. package/src/data-structures/matrix/matrix.ts +169 -1
  66. package/src/data-structures/queue/deque.ts +320 -5
  67. package/src/data-structures/queue/queue.ts +252 -0
  68. package/src/data-structures/stack/stack.ts +210 -0
  69. package/src/data-structures/trie/trie.ts +257 -5
  70. package/src/interfaces/graph.ts +1 -1
  71. package/src/types/common.ts +2 -2
  72. package/src/types/data-structures/heap/heap.ts +1 -0
  73. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  74. package/src/types/utils/validate-type.ts +4 -4
@@ -555,7 +555,7 @@ export class BinaryTree<K = any, V = any, R = any>
555
555
  * @param key - The key to validate.
556
556
  * @returns True if the key is valid, false otherwise.
557
557
  */
558
- isValidKey(key: any): key is K {
558
+ isValidKey(key: unknown): key is K {
559
559
  if (key === null) return true;
560
560
  return isComparable(key);
561
561
  }
@@ -572,6 +572,27 @@ export class BinaryTree<K = any, V = any, R = any>
572
572
 
573
573
 
574
574
 
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
575
596
  * @example
576
597
  * // Add a single node
577
598
  * const tree = new BinaryTree<number>();
@@ -605,6 +626,27 @@ export class BinaryTree<K = any, V = any, R = any>
605
626
 
606
627
 
607
628
 
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
608
650
  * @example
609
651
  * // basic BinaryTree creation and insertion
610
652
  * // Create a BinaryTree with entries
@@ -700,6 +742,27 @@ export class BinaryTree<K = any, V = any, R = any>
700
742
 
701
743
 
702
744
 
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
703
766
  * @example
704
767
  * // Bulk add
705
768
  * const tree = new BinaryTree<number>();
@@ -723,6 +786,27 @@ export class BinaryTree<K = any, V = any, R = any>
723
786
  * @returns An array of booleans indicating the success of each individual `set` operation.
724
787
 
725
788
 
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
726
810
  * @example
727
811
  * // Set multiple entries
728
812
  * const tree = new BinaryTree<number, string>();
@@ -772,6 +856,27 @@ export class BinaryTree<K = any, V = any, R = any>
772
856
 
773
857
 
774
858
 
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+
875
+
876
+
877
+
878
+
879
+
775
880
  * @example
776
881
  * // Combine trees
777
882
  * const t1 = new BinaryTree<number>([1, 2]);
@@ -817,6 +922,27 @@ export class BinaryTree<K = any, V = any, R = any>
817
922
 
818
923
 
819
924
 
925
+
926
+
927
+
928
+
929
+
930
+
931
+
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
820
946
  * @example
821
947
  * // Remove a node
822
948
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -892,6 +1018,27 @@ export class BinaryTree<K = any, V = any, R = any>
892
1018
  * Search by predicate
893
1019
 
894
1020
 
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
895
1042
  * @example
896
1043
  * // Search by predicate
897
1044
  * const tree = new BinaryTree<number>([5, 3, 7, 1, 9]);
@@ -1004,6 +1151,27 @@ export class BinaryTree<K = any, V = any, R = any>
1004
1151
 
1005
1152
 
1006
1153
 
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+
1164
+
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+
1007
1175
  * @example
1008
1176
  * // Get nodes by condition
1009
1177
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1055,6 +1223,27 @@ export class BinaryTree<K = any, V = any, R = any>
1055
1223
 
1056
1224
 
1057
1225
 
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1058
1247
  * @example
1059
1248
  * // Get node by key
1060
1249
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
@@ -1100,6 +1289,27 @@ export class BinaryTree<K = any, V = any, R = any>
1100
1289
 
1101
1290
 
1102
1291
 
1292
+
1293
+
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+
1308
+
1309
+
1310
+
1311
+
1312
+
1103
1313
  * @example
1104
1314
  * // Retrieve value by key
1105
1315
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
@@ -1138,6 +1348,27 @@ export class BinaryTree<K = any, V = any, R = any>
1138
1348
 
1139
1349
 
1140
1350
 
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1357
+
1358
+
1359
+
1360
+
1361
+
1362
+
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1371
+
1141
1372
  * @example
1142
1373
  * // BinaryTree get and has operations
1143
1374
  * const tree = new BinaryTree(
@@ -1212,6 +1443,27 @@ export class BinaryTree<K = any, V = any, R = any>
1212
1443
 
1213
1444
 
1214
1445
 
1446
+
1447
+
1448
+
1449
+
1450
+
1451
+
1452
+
1453
+
1454
+
1455
+
1456
+
1457
+
1458
+
1459
+
1460
+
1461
+
1462
+
1463
+
1464
+
1465
+
1466
+
1215
1467
  * @example
1216
1468
  * // Remove all nodes
1217
1469
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -1237,6 +1489,27 @@ export class BinaryTree<K = any, V = any, R = any>
1237
1489
 
1238
1490
 
1239
1491
 
1492
+
1493
+
1494
+
1495
+
1496
+
1497
+
1498
+
1499
+
1500
+
1501
+
1502
+
1503
+
1504
+
1505
+
1506
+
1507
+
1508
+
1509
+
1510
+
1511
+
1512
+
1240
1513
  * @example
1241
1514
  * // Check empty
1242
1515
  * console.log(new BinaryTree().isEmpty()); // true;
@@ -1274,6 +1547,27 @@ export class BinaryTree<K = any, V = any, R = any>
1274
1547
 
1275
1548
 
1276
1549
 
1550
+
1551
+
1552
+
1553
+
1554
+
1555
+
1556
+
1557
+
1558
+
1559
+
1560
+
1561
+
1562
+
1563
+
1564
+
1565
+
1566
+
1567
+
1568
+
1569
+
1570
+
1277
1571
  * @example
1278
1572
  * // Check BST property
1279
1573
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -1341,6 +1635,27 @@ export class BinaryTree<K = any, V = any, R = any>
1341
1635
 
1342
1636
 
1343
1637
 
1638
+
1639
+
1640
+
1641
+
1642
+
1643
+
1644
+
1645
+
1646
+
1647
+
1648
+
1649
+
1650
+
1651
+
1652
+
1653
+
1654
+
1655
+
1656
+
1657
+
1658
+
1344
1659
  * @example
1345
1660
  * // Get depth of a node
1346
1661
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1382,6 +1697,27 @@ export class BinaryTree<K = any, V = any, R = any>
1382
1697
 
1383
1698
 
1384
1699
 
1700
+
1701
+
1702
+
1703
+
1704
+
1705
+
1706
+
1707
+
1708
+
1709
+
1710
+
1711
+
1712
+
1713
+
1714
+
1715
+
1716
+
1717
+
1718
+
1719
+
1720
+
1385
1721
  * @example
1386
1722
  * // Get tree height
1387
1723
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1664,6 +2000,27 @@ export class BinaryTree<K = any, V = any, R = any>
1664
2000
 
1665
2001
 
1666
2002
 
2003
+
2004
+
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+
2011
+
2012
+
2013
+
2014
+
2015
+
2016
+
2017
+
2018
+
2019
+
2020
+
2021
+
2022
+
2023
+
1667
2024
  * @example
1668
2025
  * // Depth-first search traversal
1669
2026
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1728,6 +2085,27 @@ export class BinaryTree<K = any, V = any, R = any>
1728
2085
 
1729
2086
 
1730
2087
 
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
2096
+
2097
+
2098
+
2099
+
2100
+
2101
+
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+
2108
+
1731
2109
  * @example
1732
2110
  * // BinaryTree level-order traversal
1733
2111
  * const tree = new BinaryTree([
@@ -1851,6 +2229,27 @@ export class BinaryTree<K = any, V = any, R = any>
1851
2229
 
1852
2230
 
1853
2231
 
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
1854
2253
  * @example
1855
2254
  * // Get leaf nodes
1856
2255
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1927,6 +2326,27 @@ export class BinaryTree<K = any, V = any, R = any>
1927
2326
 
1928
2327
 
1929
2328
 
2329
+
2330
+
2331
+
2332
+
2333
+
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+
1930
2350
  * @example
1931
2351
  * // Level-order grouping
1932
2352
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2021,6 +2441,27 @@ export class BinaryTree<K = any, V = any, R = any>
2021
2441
 
2022
2442
 
2023
2443
 
2444
+
2445
+
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+
2452
+
2453
+
2454
+
2455
+
2456
+
2457
+
2458
+
2459
+
2460
+
2461
+
2462
+
2463
+
2464
+
2024
2465
  * @example
2025
2466
  * // Morris traversal (O(1) space)
2026
2467
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2159,6 +2600,27 @@ export class BinaryTree<K = any, V = any, R = any>
2159
2600
 
2160
2601
 
2161
2602
 
2603
+
2604
+
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2613
+
2614
+
2615
+
2616
+
2617
+
2618
+
2619
+
2620
+
2621
+
2622
+
2623
+
2162
2624
  * @example
2163
2625
  * // Deep copy
2164
2626
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2188,6 +2650,27 @@ export class BinaryTree<K = any, V = any, R = any>
2188
2650
 
2189
2651
 
2190
2652
 
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2191
2674
  * @example
2192
2675
  * // Filter nodes by condition
2193
2676
  * const tree = new BinaryTree<number>([1, 2, 3, 4]);
@@ -2221,6 +2704,27 @@ export class BinaryTree<K = any, V = any, R = any>
2221
2704
 
2222
2705
 
2223
2706
 
2707
+
2708
+
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2224
2728
  * @example
2225
2729
  * // Transform to new tree
2226
2730
  * const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
@@ -2287,6 +2791,27 @@ export class BinaryTree<K = any, V = any, R = any>
2287
2791
 
2288
2792
 
2289
2793
 
2794
+
2795
+
2796
+
2797
+
2798
+
2799
+
2800
+
2801
+
2802
+
2803
+
2804
+
2805
+
2806
+
2807
+
2808
+
2809
+
2810
+
2811
+
2812
+
2813
+
2814
+
2290
2815
  * @example
2291
2816
  * // Display tree
2292
2817
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2877,7 +3402,7 @@ export class BinaryTree<K = any, V = any, R = any>
2877
3402
  * @param p - The item to check.
2878
3403
  * @returns True if it's a function.
2879
3404
  */
2880
- protected _isPredicate(p: any): p is NodePredicate<BinaryTreeNode<K, V>> {
3405
+ protected _isPredicate(p: unknown): p is NodePredicate<BinaryTreeNode<K, V>> {
2881
3406
  return typeof p === 'function';
2882
3407
  }
2883
3408