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.
- package/dist/cjs/index.cjs +294 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +294 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +294 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +294 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/max-priority-queue-typed.js +294 -0
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -350,7 +350,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
350
350
|
* @param key - The key to validate.
|
|
351
351
|
* @returns True if the key is valid, false otherwise.
|
|
352
352
|
*/
|
|
353
|
-
isValidKey(key:
|
|
353
|
+
isValidKey(key: unknown): key is K;
|
|
354
354
|
/**
|
|
355
355
|
* Adds a new node to the tree.
|
|
356
356
|
* @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
|
|
@@ -363,6 +363,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
363
363
|
|
|
364
364
|
|
|
365
365
|
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
366
387
|
* @example
|
|
367
388
|
* // Add a single node
|
|
368
389
|
* const tree = new BinaryTree<number>();
|
|
@@ -391,6 +412,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
391
412
|
|
|
392
413
|
|
|
393
414
|
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
394
436
|
* @example
|
|
395
437
|
* // basic BinaryTree creation and insertion
|
|
396
438
|
* // Create a BinaryTree with entries
|
|
@@ -431,6 +473,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
431
473
|
|
|
432
474
|
|
|
433
475
|
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
434
497
|
* @example
|
|
435
498
|
* // Bulk add
|
|
436
499
|
* const tree = new BinaryTree<number>();
|
|
@@ -447,6 +510,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
447
510
|
* @returns An array of booleans indicating the success of each individual `set` operation.
|
|
448
511
|
|
|
449
512
|
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
450
534
|
* @example
|
|
451
535
|
* // Set multiple entries
|
|
452
536
|
* const tree = new BinaryTree<number, string>();
|
|
@@ -468,6 +552,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
468
552
|
|
|
469
553
|
|
|
470
554
|
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
471
576
|
* @example
|
|
472
577
|
* // Combine trees
|
|
473
578
|
* const t1 = new BinaryTree<number>([1, 2]);
|
|
@@ -501,6 +606,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
501
606
|
|
|
502
607
|
|
|
503
608
|
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
504
630
|
* @example
|
|
505
631
|
* // Remove a node
|
|
506
632
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -513,6 +639,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
513
639
|
* Search by predicate
|
|
514
640
|
|
|
515
641
|
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
516
663
|
* @example
|
|
517
664
|
* // Search by predicate
|
|
518
665
|
* const tree = new BinaryTree<number>([5, 3, 7, 1, 9]);
|
|
@@ -538,6 +685,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
538
685
|
|
|
539
686
|
|
|
540
687
|
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
541
709
|
* @example
|
|
542
710
|
* // Get nodes by condition
|
|
543
711
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -562,6 +730,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
562
730
|
|
|
563
731
|
|
|
564
732
|
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
565
754
|
* @example
|
|
566
755
|
* // Get node by key
|
|
567
756
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
|
|
@@ -587,6 +776,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
587
776
|
|
|
588
777
|
|
|
589
778
|
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
590
800
|
* @example
|
|
591
801
|
* // Retrieve value by key
|
|
592
802
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
|
|
@@ -613,6 +823,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
613
823
|
|
|
614
824
|
|
|
615
825
|
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
616
847
|
* @example
|
|
617
848
|
* // BinaryTree get and has operations
|
|
618
849
|
* const tree = new BinaryTree(
|
|
@@ -655,6 +886,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
655
886
|
|
|
656
887
|
|
|
657
888
|
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
658
910
|
* @example
|
|
659
911
|
* // Remove all nodes
|
|
660
912
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -676,6 +928,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
676
928
|
|
|
677
929
|
|
|
678
930
|
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
679
952
|
* @example
|
|
680
953
|
* // Check empty
|
|
681
954
|
* console.log(new BinaryTree().isEmpty()); // true;
|
|
@@ -705,6 +978,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
705
978
|
|
|
706
979
|
|
|
707
980
|
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
708
1002
|
* @example
|
|
709
1003
|
* // Check BST property
|
|
710
1004
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -730,6 +1024,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
730
1024
|
|
|
731
1025
|
|
|
732
1026
|
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
733
1048
|
* @example
|
|
734
1049
|
* // Get depth of a node
|
|
735
1050
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -755,6 +1070,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
755
1070
|
|
|
756
1071
|
|
|
757
1072
|
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
|
|
758
1094
|
* @example
|
|
759
1095
|
* // Get tree height
|
|
760
1096
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -805,6 +1141,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
805
1141
|
|
|
806
1142
|
|
|
807
1143
|
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
808
1165
|
* @example
|
|
809
1166
|
* // Depth-first search traversal
|
|
810
1167
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -827,6 +1184,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
827
1184
|
|
|
828
1185
|
|
|
829
1186
|
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
830
1208
|
* @example
|
|
831
1209
|
* // BinaryTree level-order traversal
|
|
832
1210
|
* const tree = new BinaryTree([
|
|
@@ -869,6 +1247,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
869
1247
|
|
|
870
1248
|
|
|
871
1249
|
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
872
1271
|
* @example
|
|
873
1272
|
* // Get leaf nodes
|
|
874
1273
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -887,6 +1286,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
887
1286
|
|
|
888
1287
|
|
|
889
1288
|
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
|
|
890
1310
|
* @example
|
|
891
1311
|
* // Level-order grouping
|
|
892
1312
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -907,6 +1327,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
907
1327
|
|
|
908
1328
|
|
|
909
1329
|
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
910
1351
|
* @example
|
|
911
1352
|
* // Morris traversal (O(1) space)
|
|
912
1353
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -929,6 +1370,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
929
1370
|
|
|
930
1371
|
|
|
931
1372
|
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
|
|
932
1394
|
* @example
|
|
933
1395
|
* // Deep copy
|
|
934
1396
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -953,6 +1415,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
953
1415
|
|
|
954
1416
|
|
|
955
1417
|
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
956
1439
|
* @example
|
|
957
1440
|
* // Filter nodes by condition
|
|
958
1441
|
* const tree = new BinaryTree<number>([1, 2, 3, 4]);
|
|
@@ -980,6 +1463,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
980
1463
|
|
|
981
1464
|
|
|
982
1465
|
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
983
1487
|
* @example
|
|
984
1488
|
* // Transform to new tree
|
|
985
1489
|
* const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
|
|
@@ -1011,6 +1515,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
1011
1515
|
|
|
1012
1516
|
|
|
1013
1517
|
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
|
|
1014
1539
|
* @example
|
|
1015
1540
|
* // Display tree
|
|
1016
1541
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -1136,7 +1661,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
1136
1661
|
* @param p - The item to check.
|
|
1137
1662
|
* @returns True if it's a function.
|
|
1138
1663
|
*/
|
|
1139
|
-
protected _isPredicate(p:
|
|
1664
|
+
protected _isPredicate(p: unknown): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
1140
1665
|
/**
|
|
1141
1666
|
* (Protected) Extracts the key from a key, node, or entry.
|
|
1142
1667
|
* @remarks Time O(1)
|