binary-tree-typed 2.4.5 → 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 (94) hide show
  1. package/README.md +0 -84
  2. package/dist/cjs/index.cjs +1476 -404
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs-legacy/index.cjs +1473 -401
  5. package/dist/cjs-legacy/index.cjs.map +1 -1
  6. package/dist/esm/index.mjs +1476 -404
  7. package/dist/esm/index.mjs.map +1 -1
  8. package/dist/esm-legacy/index.mjs +1473 -401
  9. package/dist/esm-legacy/index.mjs.map +1 -1
  10. package/dist/types/data-structures/base/index.d.ts +1 -0
  11. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +380 -51
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +487 -147
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +956 -80
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +816 -29
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +610 -31
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +326 -135
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3781 -6
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3607 -201
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2874 -65
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3528 -6
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +429 -47
  26. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  27. package/dist/types/data-structures/graph/undirected-graph.d.ts +393 -59
  28. package/dist/types/data-structures/hash/hash-map.d.ts +473 -89
  29. package/dist/types/data-structures/heap/heap.d.ts +581 -99
  30. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  31. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  32. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +646 -47
  33. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +596 -68
  34. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +793 -12
  35. package/dist/types/data-structures/matrix/matrix.d.ts +499 -0
  36. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  37. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  38. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  39. package/dist/types/data-structures/queue/deque.d.ts +593 -71
  40. package/dist/types/data-structures/queue/queue.d.ts +463 -42
  41. package/dist/types/data-structures/stack/stack.d.ts +384 -32
  42. package/dist/types/data-structures/trie/trie.d.ts +470 -48
  43. package/dist/types/interfaces/graph.d.ts +1 -1
  44. package/dist/types/types/common.d.ts +2 -2
  45. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  46. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  47. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  48. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  49. package/dist/types/types/utils/validate-type.d.ts +4 -4
  50. package/dist/umd/binary-tree-typed.js +1469 -397
  51. package/dist/umd/binary-tree-typed.js.map +1 -1
  52. package/dist/umd/binary-tree-typed.min.js +5 -5
  53. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/data-structures/base/index.ts +1 -0
  56. package/src/data-structures/base/iterable-element-base.ts +4 -5
  57. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  58. package/src/data-structures/base/linear-base.ts +3 -3
  59. package/src/data-structures/binary-tree/avl-tree.ts +386 -51
  60. package/src/data-structures/binary-tree/binary-indexed-tree.ts +596 -247
  61. package/src/data-structures/binary-tree/binary-tree.ts +956 -81
  62. package/src/data-structures/binary-tree/bst.ts +840 -35
  63. package/src/data-structures/binary-tree/red-black-tree.ts +689 -97
  64. package/src/data-structures/binary-tree/segment-tree.ts +498 -249
  65. package/src/data-structures/binary-tree/tree-map.ts +3784 -7
  66. package/src/data-structures/binary-tree/tree-multi-map.ts +3614 -211
  67. package/src/data-structures/binary-tree/tree-multi-set.ts +2874 -65
  68. package/src/data-structures/binary-tree/tree-set.ts +3531 -10
  69. package/src/data-structures/graph/abstract-graph.ts +4 -4
  70. package/src/data-structures/graph/directed-graph.ts +429 -47
  71. package/src/data-structures/graph/map-graph.ts +59 -1
  72. package/src/data-structures/graph/undirected-graph.ts +393 -59
  73. package/src/data-structures/hash/hash-map.ts +476 -92
  74. package/src/data-structures/heap/heap.ts +581 -99
  75. package/src/data-structures/heap/max-heap.ts +46 -0
  76. package/src/data-structures/heap/min-heap.ts +59 -0
  77. package/src/data-structures/linked-list/doubly-linked-list.ts +646 -47
  78. package/src/data-structures/linked-list/singly-linked-list.ts +596 -68
  79. package/src/data-structures/linked-list/skip-linked-list.ts +1067 -90
  80. package/src/data-structures/matrix/matrix.ts +584 -12
  81. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  82. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  83. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  84. package/src/data-structures/queue/deque.ts +592 -70
  85. package/src/data-structures/queue/queue.ts +463 -42
  86. package/src/data-structures/stack/stack.ts +384 -32
  87. package/src/data-structures/trie/trie.ts +470 -48
  88. package/src/interfaces/graph.ts +1 -1
  89. package/src/types/common.ts +2 -2
  90. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  91. package/src/types/data-structures/heap/heap.ts +1 -0
  92. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
  93. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  94. package/src/types/utils/validate-type.ts +4 -4
@@ -126,34 +126,6 @@ export declare class BSTNode<K = any, V = any> {
126
126
  * 7. No Auto-Balancing: Standard BSTs don't automatically balance themselves.
127
127
  *
128
128
  * @example
129
- * // basic BST creation and add operation
130
- * // Create a simple BST with numeric keys
131
- * const bst = new BST<number>([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
132
- *
133
- * // Keep the example output in source comments but avoid noisy test logs.
134
- * await withMutedConsole(() => bst.print());
135
- * // _______8__________
136
- * // / \
137
- * // ___4___ ____12_____
138
- * // / \ / \
139
- * // _2_ _6_ _10__ _14__
140
- * // / \ / \ / \ / \
141
- * // 1 3 5 7 9 11 13 15__
142
- * // \
143
- * // 16
144
- *
145
- * // Verify size
146
- * console.log(bst.size); // 16;
147
- *
148
- * // Add new elements
149
- * bst.set(17);
150
- * bst.set(0);
151
- * console.log(bst.size); // 18;
152
- *
153
- * // Verify keys are searchable
154
- * console.log(bst.has(11)); // true;
155
- * console.log(bst.has(100)); // false;
156
- * @example
157
129
  * // BST delete and search after deletion
158
130
  * const bst = new BST<number>([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
159
131
  *
@@ -335,11 +307,217 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
335
307
  * @param key - The key to validate.
336
308
  * @returns True if the key is valid, false otherwise.
337
309
  */
338
- isValidKey(key: any): key is K;
310
+ isValidKey(key: unknown): key is K;
311
+ /**
312
+ * Depth-first search traversal
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
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
+
375
+
376
+
377
+ * @example
378
+ * // Depth-first traversal
379
+ * const bst = new BST<number>([5, 3, 7, 1, 4]);
380
+ * const inOrder = bst.dfs(node => node.key, 'IN');
381
+ * console.log(inOrder); // [1, 3, 4, 5, 7];
382
+ */
339
383
  dfs(): (K | undefined)[];
340
384
  dfs<C extends NodeCallback<BSTNode<K, V>>>(callback: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
385
+ /**
386
+ * BinaryTree level-order traversal
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
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
+
443
+ * @example
444
+ * // Breadth-first traversal
445
+ * const bst = new BST<number>([5, 3, 7]);
446
+ * const result = bst.bfs(node => node.key);
447
+ * console.log(result.length); // 3;
448
+ */
341
449
  bfs(): (K | undefined)[];
342
450
  bfs<C extends NodeCallback<BSTNode<K, V>>>(callback: C, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
451
+ /**
452
+ * Level-order grouping
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
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
+
512
+ * @example
513
+ * // Level-order grouping
514
+ * const bst = new BST<number>([5, 3, 7, 1, 4]);
515
+ * const levels = bst.listLevels(node => node.key);
516
+ * console.log(levels.length); // > 0;
517
+ * console.log(levels[0].length); // 1; // root level has 1 node
518
+ * const allKeys = levels.flat().sort((a, b) => a - b);
519
+ * console.log(allKeys); // [1, 3, 4, 5, 7];
520
+ */
343
521
  listLevels(): (K | undefined)[][];
344
522
  listLevels<C extends NodeCallback<BSTNode<K, V>>>(callback: C, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[][];
345
523
  /**
@@ -350,10 +528,178 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
350
528
  * @param [startNode=this._root] - The node to start the search from.
351
529
  * @param [iterationType=this.iterationType] - The traversal method.
352
530
  * @returns The first matching node, or undefined if not found.
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
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
+
592
+ * @example
593
+ * // Get node object by key
594
+ * const bst = new BST<number, string>([[5, 'root'], [3, 'left'], [7, 'right']]);
595
+ * const node = bst.getNode(3);
596
+ * console.log(node?.key); // 3;
597
+ * console.log(node?.value); // 'left';
353
598
  */
354
599
  getNode(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>>, startNode?: BSTNOptKeyOrNode<K, BSTNode<K, V>>, iterationType?: IterationType): OptNode<BSTNode<K, V>>;
600
+ /**
601
+ * Search nodes by predicate
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
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
+
656
+ * @example
657
+ * // Search nodes by predicate
658
+ * const bst = new BST<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd']]);
659
+ * const found = bst.search(node => node.key > 2, true);
660
+ * console.log(found.length); // >= 1;
661
+ */
355
662
  search(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne?: boolean): (K | undefined)[];
356
663
  search<C extends NodeCallback<BSTNode<K, V>>>(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne: boolean, callback: C, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
664
+ /**
665
+ * Find all keys in a range
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+ * @example
699
+ * // Find all keys in a range
700
+ * const bst = new BST<number>([10, 20, 30, 40, 50]);
701
+ * console.log(bst.rangeSearch([15, 35])); // [20, 30];
702
+ */
357
703
  rangeSearch(range: Range<K> | [K, K]): (K | undefined)[];
358
704
  rangeSearch<C extends NodeCallback<BSTNode<K, V>>>(range: Range<K> | [K, K], callback: C, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
359
705
  /**
@@ -363,6 +709,100 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
363
709
  * @param keyNodeOrEntry - The key, node, or entry to set.
364
710
  * @param [value] - The value, if providing just a key.
365
711
  * @returns True if the addition was successful, false otherwise.
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
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
+
795
+
796
+
797
+
798
+
799
+
800
+ * @example
801
+ * // Set a key-value pair
802
+ * const bst = new BST<number, string>();
803
+ * bst.set(1, 'one');
804
+ * bst.set(2, 'two');
805
+ * console.log(bst.get(1)); // 'one';
366
806
  */
367
807
  set(keyNodeOrEntry: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
368
808
  /**
@@ -376,6 +816,65 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
376
816
  * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
377
817
  * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).
378
818
  * @returns An array of booleans indicating the success of each individual `set` operation.
819
+
820
+
821
+
822
+
823
+
824
+
825
+
826
+
827
+
828
+
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
+
872
+ * @example
873
+ * // Set multiple key-value pairs
874
+ * const bst = new BST<number, string>();
875
+ * bst.setMany([[1, 'a'], [2, 'b'], [3, 'c']]);
876
+ * console.log(bst.size); // 3;
877
+ * console.log(bst.get(2)); // 'b';
379
878
  */
380
879
  setMany(keysNodesEntriesOrRaws: Iterable<R | BTNRep<K, V, BSTNode<K, V>>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
381
880
  /**
@@ -383,6 +882,44 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
383
882
  * Equivalent to Java TreeMap.ceiling.
384
883
  * Time Complexity: O(log n) average, O(h) worst case.
385
884
  * Space Complexity: O(h) for recursion, O(1) for iteration.
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+ * @example
918
+ * // Find the least key ≥ target
919
+ * const bst = new BST<number>([10, 20, 30, 40, 50]);
920
+ * console.log(bst.ceiling(25)); // 30;
921
+ * console.log(bst.ceiling(30)); // 30;
922
+ * console.log(bst.ceiling(55)); // undefined;
386
923
  */
387
924
  ceiling(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>>): K | undefined;
388
925
  /**
@@ -396,6 +933,43 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
396
933
  * Equivalent to Java TreeMap.higher.
397
934
  * Time Complexity: O(log n) average, O(h) worst case.
398
935
  * Space Complexity: O(h) for recursion, O(1) for iteration.
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
965
+
966
+
967
+
968
+ * @example
969
+ * // Find the least key strictly > target
970
+ * const bst = new BST<number>([10, 20, 30, 40]);
971
+ * console.log(bst.higher(20)); // 30;
972
+ * console.log(bst.higher(40)); // undefined;
399
973
  */
400
974
  higher(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>>): K | undefined;
401
975
  /**
@@ -409,6 +983,44 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
409
983
  * Equivalent to Java TreeMap.floor.
410
984
  * Time Complexity: O(log n) average, O(h) worst case.
411
985
  * Space Complexity: O(h) for recursion, O(1) for iteration.
986
+
987
+
988
+
989
+
990
+
991
+
992
+
993
+
994
+
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+ * @example
1019
+ * // Find the greatest key ≤ target
1020
+ * const bst = new BST<number>([10, 20, 30, 40, 50]);
1021
+ * console.log(bst.floor(25)); // 20;
1022
+ * console.log(bst.floor(10)); // 10;
1023
+ * console.log(bst.floor(5)); // undefined;
412
1024
  */
413
1025
  floor(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>>): K | undefined;
414
1026
  /**
@@ -422,6 +1034,43 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
422
1034
  * Equivalent to Java TreeMap.lower.
423
1035
  * Time Complexity: O(log n) average, O(h) worst case.
424
1036
  * Space Complexity: O(h) for recursion, O(1) for iteration.
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+ * @example
1070
+ * // Find the greatest key strictly < target
1071
+ * const bst = new BST<number>([10, 20, 30, 40]);
1072
+ * console.log(bst.lower(30)); // 20;
1073
+ * console.log(bst.lower(10)); // undefined;
425
1074
  */
426
1075
  lower(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>>): K | undefined;
427
1076
  /**
@@ -438,6 +1087,44 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
438
1087
  *
439
1088
  * @param [iterationType=this.iterationType] - The traversal method for the initial node export.
440
1089
  * @returns True if successful, false if the tree was empty.
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+ * @example
1121
+ * // Rebalance the tree
1122
+ * const bst = new BST<number>();
1123
+ * // Insert in sorted order (worst case for BST)
1124
+ * for (let i = 1; i <= 7; i++) bst.add(i);
1125
+ * console.log(bst.isAVLBalanced()); // false;
1126
+ * bst.perfectlyBalance();
1127
+ * console.log(bst.isAVLBalanced()); // true;
441
1128
  */
442
1129
  perfectlyBalance(iterationType?: IterationType): boolean;
443
1130
  /**
@@ -446,6 +1133,40 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
446
1133
  *
447
1134
  * @param [iterationType=this.iterationType] - The traversal method.
448
1135
  * @returns True if the tree is AVL balanced, false otherwise.
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+
1148
+
1149
+
1150
+
1151
+
1152
+
1153
+
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+
1164
+
1165
+
1166
+ * @example
1167
+ * // Check if tree is height-balanced
1168
+ * const bst = new BST<number>([3, 1, 5, 2, 4]);
1169
+ * console.log(bst.isAVLBalanced()); // true;
449
1170
  */
450
1171
  isAVLBalanced(iterationType?: IterationType): boolean;
451
1172
  /**
@@ -460,6 +1181,72 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
460
1181
  * @param [options] - Options for the new BST.
461
1182
  * @param [thisArg] - `this` context for the callback.
462
1183
  * @returns A new, mapped BST.
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+
1197
+
1198
+
1199
+
1200
+
1201
+
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
+
1245
+ * @example
1246
+ * // Transform to new tree
1247
+ * const bst = new BST<number, number>([[1, 10], [2, 20], [3, 30]]);
1248
+ * const doubled = bst.map((value, key) => [key, (value ?? 0) * 2] as [number, number]);
1249
+ * console.log([...doubled.values()]); // [20, 40, 60];
463
1250
  */
464
1251
  map<MK = K, MV = V, MR = any>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: Partial<BSTOptions<MK, MV, MR>>, thisArg?: unknown): BST<MK, MV, MR>;
465
1252
  /**