binary-tree-typed 2.5.3 → 2.6.0

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 (61) hide show
  1. package/dist/cjs/index.cjs +126 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +126 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +126 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +126 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/umd/binary-tree-typed.js +126 -0
  34. package/dist/umd/binary-tree-typed.js.map +1 -1
  35. package/dist/umd/binary-tree-typed.min.js +1 -1
  36. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/data-structures/base/iterable-element-base.ts +32 -0
  39. package/src/data-structures/base/linear-base.ts +11 -0
  40. package/src/data-structures/binary-tree/avl-tree.ts +36 -0
  41. package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
  42. package/src/data-structures/binary-tree/binary-tree.ts +75 -0
  43. package/src/data-structures/binary-tree/bst.ts +72 -0
  44. package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
  45. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  46. package/src/data-structures/binary-tree/tree-map.ts +375 -0
  47. package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
  48. package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
  49. package/src/data-structures/binary-tree/tree-set.ts +492 -0
  50. package/src/data-structures/graph/directed-graph.ts +30 -0
  51. package/src/data-structures/graph/undirected-graph.ts +27 -0
  52. package/src/data-structures/hash/hash-map.ts +33 -0
  53. package/src/data-structures/heap/heap.ts +42 -0
  54. package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
  55. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  56. package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
  57. package/src/data-structures/matrix/matrix.ts +24 -0
  58. package/src/data-structures/queue/deque.ts +103 -1
  59. package/src/data-structures/queue/queue.ts +36 -0
  60. package/src/data-structures/stack/stack.ts +30 -0
  61. package/src/data-structures/trie/trie.ts +36 -0
@@ -206,6 +206,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
206
206
 
207
207
 
208
208
 
209
+
210
+
211
+
209
212
 
210
213
 
211
214
 
@@ -268,6 +271,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
268
271
 
269
272
 
270
273
 
274
+
275
+
276
+
271
277
 
272
278
 
273
279
 
@@ -338,6 +344,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
338
344
 
339
345
 
340
346
 
347
+
348
+
349
+
341
350
 
342
351
 
343
352
 
@@ -402,6 +411,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
402
411
 
403
412
 
404
413
 
414
+
415
+
416
+
405
417
 
406
418
 
407
419
 
@@ -452,6 +464,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
452
464
 
453
465
 
454
466
 
467
+
468
+
469
+
455
470
 
456
471
 
457
472
 
@@ -549,6 +564,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
549
564
 
550
565
 
551
566
 
567
+
568
+
569
+
552
570
 
553
571
 
554
572
 
@@ -614,6 +632,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
614
632
 
615
633
 
616
634
 
635
+
636
+
637
+
617
638
 
618
639
 
619
640
 
@@ -667,6 +688,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
667
688
 
668
689
 
669
690
 
691
+
692
+
693
+
670
694
 
671
695
 
672
696
 
@@ -719,6 +743,9 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
719
743
 
720
744
 
721
745
 
746
+
747
+
748
+
722
749
 
723
750
 
724
751
 
@@ -169,6 +169,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
169
169
 
170
170
 
171
171
 
172
+
173
+
174
+
172
175
 
173
176
 
174
177
 
@@ -216,6 +219,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
216
219
 
217
220
 
218
221
 
222
+
223
+
224
+
219
225
 
220
226
 
221
227
 
@@ -310,6 +316,12 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
310
316
 
311
317
 
312
318
 
319
+
320
+
321
+
322
+
323
+
324
+
313
325
 
314
326
 
315
327
 
@@ -375,6 +387,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
375
387
 
376
388
 
377
389
 
390
+
391
+
392
+
378
393
 
379
394
 
380
395
 
@@ -426,6 +441,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
426
441
 
427
442
 
428
443
 
444
+
445
+
446
+
429
447
 
430
448
 
431
449
 
@@ -493,6 +511,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
493
511
 
494
512
 
495
513
 
514
+
515
+
516
+
496
517
 
497
518
 
498
519
 
@@ -545,6 +566,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
545
566
 
546
567
 
547
568
 
569
+
570
+
571
+
548
572
 
549
573
 
550
574
 
@@ -602,6 +626,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
602
626
 
603
627
 
604
628
 
629
+
630
+
631
+
605
632
 
606
633
 
607
634
 
@@ -656,6 +683,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
656
683
 
657
684
 
658
685
 
686
+
687
+
688
+
659
689
 
660
690
 
661
691
 
@@ -710,6 +740,9 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
710
740
 
711
741
 
712
742
 
743
+
744
+
745
+
713
746
 
714
747
 
715
748
 
@@ -200,6 +200,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
200
200
 
201
201
 
202
202
 
203
+
204
+
205
+
203
206
 
204
207
 
205
208
 
@@ -282,6 +285,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
282
285
 
283
286
 
284
287
 
288
+
289
+
290
+
285
291
 
286
292
 
287
293
 
@@ -340,6 +346,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
340
346
 
341
347
 
342
348
 
349
+
350
+
351
+
343
352
 
344
353
 
345
354
 
@@ -422,6 +431,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
422
431
  */
423
432
  /**
424
433
  * @deprecated Use `pop` instead. Will be removed in a future major version.
434
+
435
+
436
+
425
437
  * @example
426
438
  * // Heap with custom comparator (MaxHeap behavior)
427
439
  * interface Task {
@@ -494,6 +506,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
494
506
 
495
507
 
496
508
 
509
+
510
+
511
+
497
512
 
498
513
 
499
514
 
@@ -596,6 +611,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
596
611
 
597
612
 
598
613
 
614
+
615
+
616
+
599
617
 
600
618
 
601
619
 
@@ -645,6 +663,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
645
663
 
646
664
 
647
665
 
666
+
667
+
668
+
648
669
 
649
670
 
650
671
 
@@ -687,6 +708,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
687
708
 
688
709
 
689
710
 
711
+
712
+
713
+
690
714
 
691
715
 
692
716
 
@@ -735,6 +759,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
735
759
 
736
760
 
737
761
 
762
+
763
+
764
+
738
765
 
739
766
 
740
767
 
@@ -795,6 +822,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
795
822
 
796
823
 
797
824
 
825
+
826
+
827
+
798
828
 
799
829
 
800
830
 
@@ -851,6 +881,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
851
881
 
852
882
 
853
883
 
884
+
885
+
886
+
854
887
 
855
888
 
856
889
 
@@ -899,6 +932,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
899
932
 
900
933
 
901
934
 
935
+
936
+
937
+
902
938
 
903
939
 
904
940
 
@@ -951,6 +987,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
951
987
 
952
988
 
953
989
 
990
+
991
+
992
+
954
993
 
955
994
 
956
995
 
@@ -1003,6 +1042,9 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
1003
1042
 
1004
1043
 
1005
1044
 
1045
+
1046
+
1047
+
1006
1048
 
1007
1049
 
1008
1050
 
@@ -220,6 +220,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
220
220
 
221
221
 
222
222
 
223
+
224
+
225
+
223
226
 
224
227
 
225
228
 
@@ -280,6 +283,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
280
283
 
281
284
 
282
285
 
286
+
287
+
288
+
283
289
 
284
290
 
285
291
 
@@ -340,6 +346,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
340
346
 
341
347
 
342
348
 
349
+
350
+
351
+
343
352
 
344
353
 
345
354
 
@@ -391,6 +400,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
391
400
 
392
401
 
393
402
 
403
+
404
+
405
+
394
406
 
395
407
 
396
408
 
@@ -456,6 +468,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
456
468
 
457
469
 
458
470
 
471
+
472
+
473
+
459
474
 
460
475
 
461
476
 
@@ -504,6 +519,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
504
519
 
505
520
 
506
521
 
522
+
523
+
524
+
507
525
 
508
526
 
509
527
 
@@ -559,6 +577,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
559
577
 
560
578
 
561
579
 
580
+
581
+
582
+
562
583
 
563
584
 
564
585
 
@@ -631,6 +652,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
631
652
 
632
653
 
633
654
 
655
+
656
+
657
+
634
658
 
635
659
 
636
660
 
@@ -679,6 +703,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
679
703
 
680
704
 
681
705
 
706
+
707
+
708
+
682
709
 
683
710
 
684
711
 
@@ -727,6 +754,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
727
754
 
728
755
 
729
756
 
757
+
758
+
759
+
730
760
 
731
761
 
732
762
 
@@ -773,6 +803,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
773
803
 
774
804
 
775
805
 
806
+
807
+
808
+
776
809
 
777
810
 
778
811
 
@@ -821,6 +854,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
821
854
 
822
855
 
823
856
 
857
+
858
+
859
+
824
860
 
825
861
 
826
862
 
@@ -876,11 +912,36 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
876
912
  * @example
877
913
  * // Find value scanning from tail
878
914
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
879
- * // getBackward scans from tail to head, returns first match
880
- * const found = list.getBackward(node => node.value < 4);
915
+ * // findLast scans from tail to head, returns first match
916
+ * const found = list.findLast(node => node.value < 4);
881
917
  * console.log(found); // 3;
882
918
  */
919
+ /**
920
+ * @deprecated Use `findLast` instead. Will be removed in a future major version.
921
+ */
883
922
  getBackward(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
923
+ /**
924
+ * Find the first value matching a predicate scanning backward (tail → head).
925
+ * @remarks Time O(N), Space O(1)
926
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
927
+ * @returns Matching value or undefined.
928
+
929
+
930
+ * @example
931
+ * // Find value scanning from tail
932
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
933
+ * // findLast scans from tail to head, returns first match
934
+ * const found = list.findLast(node => node.value < 4);
935
+ * console.log(found); // 3;
936
+ */
937
+ findLast(elementNodeOrPredicate: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): E | undefined;
938
+ /**
939
+ * Find the index of the last value matching a predicate (scans tail → head).
940
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
941
+ * @param predicate - Function called with (value, index, list).
942
+ * @returns Matching index, or -1 if not found.
943
+ */
944
+ findLastIndex(predicate: (value: E, index: number, list: this) => boolean): number;
884
945
  /**
885
946
  * Reverse the list in place.
886
947
  * @remarks Time O(N), Space O(1)
@@ -920,6 +981,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
920
981
 
921
982
 
922
983
 
984
+
985
+
986
+
923
987
 
924
988
 
925
989
 
@@ -982,6 +1046,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
982
1046
 
983
1047
 
984
1048
 
1049
+
1050
+
1051
+
985
1052
 
986
1053
 
987
1054
 
@@ -1035,6 +1102,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
1035
1102
 
1036
1103
 
1037
1104
 
1105
+
1106
+
1107
+
1038
1108
 
1039
1109
 
1040
1110
 
@@ -1098,6 +1168,9 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
1098
1168
 
1099
1169
 
1100
1170
 
1171
+
1172
+
1173
+
1101
1174
 
1102
1175
 
1103
1176
 
@@ -269,6 +269,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
269
269
 
270
270
 
271
271
 
272
+
273
+
274
+
272
275
 
273
276
 
274
277
 
@@ -329,6 +332,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
329
332
 
330
333
 
331
334
 
335
+
336
+
337
+
332
338
 
333
339
 
334
340
 
@@ -389,6 +395,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
389
395
 
390
396
 
391
397
 
398
+
399
+
400
+
392
401
 
393
402
 
394
403
 
@@ -440,6 +449,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
440
449
 
441
450
 
442
451
 
452
+
453
+
454
+
443
455
 
444
456
 
445
457
 
@@ -527,6 +539,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
527
539
 
528
540
 
529
541
 
542
+
543
+
544
+
530
545
 
531
546
 
532
547
 
@@ -583,6 +598,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
583
598
 
584
599
 
585
600
 
601
+
602
+
603
+
586
604
 
587
605
 
588
606
 
@@ -630,6 +648,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
630
648
 
631
649
 
632
650
 
651
+
652
+
653
+
633
654
 
634
655
 
635
656
 
@@ -678,6 +699,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
678
699
 
679
700
 
680
701
 
702
+
703
+
704
+
681
705
 
682
706
 
683
707
 
@@ -727,6 +751,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
727
751
 
728
752
 
729
753
 
754
+
755
+
756
+
730
757
 
731
758
 
732
759
 
@@ -783,6 +810,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
783
810
 
784
811
 
785
812
 
813
+
814
+
815
+
786
816
 
787
817
 
788
818
 
@@ -829,6 +859,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
829
859
 
830
860
 
831
861
 
862
+
863
+
864
+
832
865
 
833
866
 
834
867
 
@@ -879,6 +912,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
879
912
 
880
913
 
881
914
 
915
+
916
+
917
+
882
918
 
883
919
 
884
920
 
@@ -980,6 +1016,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
980
1016
 
981
1017
 
982
1018
 
1019
+
1020
+
1021
+
983
1022
 
984
1023
 
985
1024
 
@@ -1034,6 +1073,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
1034
1073
 
1035
1074
 
1036
1075
 
1076
+
1077
+
1078
+
1037
1079
 
1038
1080
 
1039
1081
 
@@ -1107,6 +1149,9 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
1107
1149
 
1108
1150
 
1109
1151
 
1152
+
1153
+
1154
+
1110
1155
 
1111
1156
 
1112
1157