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
@@ -307,7 +307,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
307
307
  * @param key - The key to validate.
308
308
  * @returns True if the key is valid, false otherwise.
309
309
  */
310
- isValidKey(key: any): key is K;
310
+ isValidKey(key: unknown): key is K;
311
311
  /**
312
312
  * Depth-first search traversal
313
313
 
@@ -330,6 +330,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
330
330
 
331
331
 
332
332
 
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
333
375
 
334
376
 
335
377
  * @example
@@ -356,6 +398,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
356
398
 
357
399
 
358
400
 
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
359
443
  * @example
360
444
  * // Breadth-first traversal
361
445
  * const bst = new BST<number>([5, 3, 7]);
@@ -383,6 +467,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
383
467
 
384
468
 
385
469
 
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
386
512
  * @example
387
513
  * // Level-order grouping
388
514
  * const bst = new BST<number>([5, 3, 7, 1, 4]);
@@ -421,6 +547,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
421
547
 
422
548
 
423
549
 
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
424
592
  * @example
425
593
  * // Get node object by key
426
594
  * const bst = new BST<number, string>([[5, 'root'], [3, 'left'], [7, 'right']]);
@@ -443,6 +611,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
443
611
 
444
612
 
445
613
 
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
446
656
  * @example
447
657
  * // Search nodes by predicate
448
658
  * const bst = new BST<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd']]);
@@ -464,6 +674,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
464
674
 
465
675
 
466
676
 
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
467
698
  * @example
468
699
  * // Find all keys in a range
469
700
  * const bst = new BST<number>([10, 20, 30, 40, 50]);
@@ -498,6 +729,69 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
498
729
 
499
730
 
500
731
 
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
501
795
 
502
796
 
503
797
 
@@ -533,6 +827,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
533
827
 
534
828
 
535
829
 
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+
851
+
852
+
853
+
854
+
855
+
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
536
872
  * @example
537
873
  * // Set multiple key-value pairs
538
874
  * const bst = new BST<number, string>();
@@ -557,6 +893,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
557
893
 
558
894
 
559
895
 
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
560
917
  * @example
561
918
  * // Find the least key ≥ target
562
919
  * const bst = new BST<number>([10, 20, 30, 40, 50]);
@@ -587,6 +944,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
587
944
 
588
945
 
589
946
 
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
965
+
966
+
967
+
590
968
  * @example
591
969
  * // Find the least key strictly > target
592
970
  * const bst = new BST<number>([10, 20, 30, 40]);
@@ -616,6 +994,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
616
994
 
617
995
 
618
996
 
997
+
998
+
999
+
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
619
1018
  * @example
620
1019
  * // Find the greatest key ≤ target
621
1020
  * const bst = new BST<number>([10, 20, 30, 40, 50]);
@@ -646,6 +1045,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
646
1045
 
647
1046
 
648
1047
 
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
649
1069
  * @example
650
1070
  * // Find the greatest key strictly < target
651
1071
  * const bst = new BST<number>([10, 20, 30, 40]);
@@ -676,6 +1096,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
676
1096
 
677
1097
 
678
1098
 
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
679
1120
  * @example
680
1121
  * // Rebalance the tree
681
1122
  * const bst = new BST<number>();
@@ -701,6 +1142,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
701
1142
 
702
1143
 
703
1144
 
1145
+
1146
+
1147
+
1148
+
1149
+
1150
+
1151
+
1152
+
1153
+
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+
1164
+
1165
+
704
1166
  * @example
705
1167
  * // Check if tree is height-balanced
706
1168
  * const bst = new BST<number>([3, 1, 5, 2, 4]);
@@ -738,6 +1200,48 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
738
1200
 
739
1201
 
740
1202
 
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+
1225
+
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
741
1245
  * @example
742
1246
  * // Transform to new tree
743
1247
  * const bst = new BST<number, number>([[1, 10], [2, 20], [3, 30]]);