binary-tree-typed 2.5.1 → 2.5.3

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 (75) hide show
  1. package/dist/cjs/index.cjs +340 -107
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +339 -106
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +340 -108
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +339 -107
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/binary-tree-typed.js +337 -105
  39. package/dist/umd/binary-tree-typed.js.map +1 -1
  40. package/dist/umd/binary-tree-typed.min.js +5 -5
  41. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -209,6 +209,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
209
209
 
210
210
 
211
211
 
212
+
213
+
214
+
215
+
216
+
217
+
218
+
212
219
 
213
220
 
214
221
 
@@ -262,6 +269,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
262
269
 
263
270
 
264
271
 
272
+
273
+
274
+
275
+
276
+
277
+
278
+
265
279
 
266
280
 
267
281
 
@@ -315,6 +329,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
315
329
 
316
330
 
317
331
 
332
+
333
+
334
+
335
+
336
+
337
+
338
+
318
339
 
319
340
 
320
341
 
@@ -359,6 +380,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
359
380
 
360
381
 
361
382
 
383
+
384
+
385
+
386
+
387
+
388
+
389
+
362
390
 
363
391
 
364
392
 
@@ -417,6 +445,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
417
445
 
418
446
 
419
447
 
448
+
449
+
450
+
451
+
452
+
453
+
454
+
420
455
 
421
456
 
422
457
 
@@ -458,6 +493,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
458
493
 
459
494
 
460
495
 
496
+
497
+
498
+
499
+
500
+
501
+
502
+
461
503
 
462
504
 
463
505
 
@@ -506,6 +548,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
506
548
 
507
549
 
508
550
 
551
+
552
+
553
+
554
+
555
+
556
+
557
+
509
558
 
510
559
 
511
560
 
@@ -571,6 +620,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
571
620
 
572
621
 
573
622
 
623
+
624
+
625
+
626
+
627
+
628
+
629
+
574
630
 
575
631
 
576
632
 
@@ -612,6 +668,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
612
668
 
613
669
 
614
670
 
671
+
672
+
673
+
674
+
675
+
676
+
677
+
615
678
 
616
679
 
617
680
 
@@ -653,6 +716,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
653
716
 
654
717
 
655
718
 
719
+
720
+
721
+
722
+
723
+
724
+
725
+
656
726
 
657
727
 
658
728
 
@@ -692,6 +762,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
692
762
 
693
763
 
694
764
 
765
+
766
+
767
+
768
+
769
+
770
+
771
+
695
772
 
696
773
 
697
774
 
@@ -733,6 +810,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
733
810
 
734
811
 
735
812
 
813
+
814
+
815
+
816
+
817
+
818
+
819
+
736
820
 
737
821
 
738
822
 
@@ -774,6 +858,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
774
858
 
775
859
 
776
860
 
861
+
862
+
863
+
864
+
865
+
866
+
867
+
777
868
 
778
869
 
779
870
 
@@ -818,6 +909,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
818
909
 
819
910
 
820
911
 
912
+
913
+
914
+
915
+
916
+
917
+
918
+
821
919
 
822
920
 
823
921
 
@@ -833,6 +931,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
833
931
  * console.log([...list]); // [3, 2, 1];
834
932
  */
835
933
  reverse(): this;
934
+ /**
935
+ * Delete the first element that satisfies a predicate.
936
+ * @remarks Time O(N), Space O(1)
937
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
938
+ * @returns True if a match was removed.
939
+ */
940
+ deleteWhere(predicate: (value: E, index: number, list: this) => boolean): boolean;
836
941
  /**
837
942
  * Set the equality comparator used to compare values.
838
943
  * @remarks Time O(1), Space O(1)
@@ -866,6 +971,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
866
971
 
867
972
 
868
973
 
974
+
975
+
976
+
977
+
978
+
979
+
980
+
869
981
 
870
982
 
871
983
 
@@ -912,6 +1024,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
912
1024
 
913
1025
 
914
1026
 
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
915
1034
 
916
1035
 
917
1036
 
@@ -968,6 +1087,13 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
968
1087
 
969
1088
 
970
1089
 
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
971
1097
 
972
1098
 
973
1099
 
@@ -40,7 +40,7 @@ export declare class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
40
40
  * @remarks Time O(1), Space O(1)
41
41
  * @template E
42
42
  * @template R
43
- * 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
43
+ * 1. Node Structure: Each node contains two parts: a data field and a pointer (or reference) to the next node. This structure allows forward-only traversal of the linked list.
44
44
  * 2. Bidirectional Traversal: Unlike doubly linked lists, singly linked lists can be easily traversed forwards but not backwards.
45
45
  * 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
46
46
  * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
@@ -258,6 +258,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
258
258
 
259
259
 
260
260
 
261
+
262
+
263
+
264
+
265
+
266
+
267
+
261
268
 
262
269
 
263
270
 
@@ -311,6 +318,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
311
318
 
312
319
 
313
320
 
321
+
322
+
323
+
324
+
325
+
326
+
327
+
314
328
 
315
329
 
316
330
 
@@ -364,6 +378,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
364
378
 
365
379
 
366
380
 
381
+
382
+
383
+
384
+
385
+
386
+
387
+
367
388
 
368
389
 
369
390
 
@@ -408,6 +429,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
408
429
 
409
430
 
410
431
 
432
+
433
+
434
+
435
+
436
+
437
+
438
+
411
439
 
412
440
 
413
441
 
@@ -488,6 +516,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
488
516
 
489
517
 
490
518
 
519
+
520
+
521
+
522
+
523
+
524
+
525
+
491
526
 
492
527
 
493
528
 
@@ -537,6 +572,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
537
572
 
538
573
 
539
574
 
575
+
576
+
577
+
578
+
579
+
580
+
581
+
540
582
 
541
583
 
542
584
 
@@ -577,6 +619,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
577
619
 
578
620
 
579
621
 
622
+
623
+
624
+
625
+
626
+
627
+
628
+
580
629
 
581
630
 
582
631
 
@@ -618,6 +667,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
618
667
 
619
668
 
620
669
 
670
+
671
+
672
+
673
+
674
+
675
+
676
+
621
677
 
622
678
 
623
679
 
@@ -660,6 +716,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
660
716
 
661
717
 
662
718
 
719
+
720
+
721
+
722
+
723
+
724
+
725
+
663
726
 
664
727
 
665
728
 
@@ -709,6 +772,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
709
772
 
710
773
 
711
774
 
775
+
776
+
777
+
778
+
779
+
780
+
781
+
712
782
 
713
783
 
714
784
 
@@ -748,6 +818,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
748
818
 
749
819
 
750
820
 
821
+
822
+
823
+
824
+
825
+
826
+
827
+
751
828
 
752
829
 
753
830
 
@@ -791,6 +868,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
791
868
 
792
869
 
793
870
 
871
+
872
+
873
+
874
+
875
+
876
+
877
+
794
878
 
795
879
 
796
880
 
@@ -885,6 +969,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
885
969
 
886
970
 
887
971
 
972
+
973
+
974
+
975
+
976
+
977
+
978
+
888
979
 
889
980
 
890
981
 
@@ -932,6 +1023,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
932
1023
 
933
1024
 
934
1025
 
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
935
1033
 
936
1034
 
937
1035
 
@@ -998,6 +1096,13 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
998
1096
 
999
1097
 
1000
1098
 
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1001
1106
 
1002
1107
 
1003
1108
 
@@ -73,6 +73,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
73
73
 
74
74
 
75
75
 
76
+
77
+
78
+
79
+
80
+
81
+
82
+
76
83
 
77
84
 
78
85
 
@@ -110,6 +117,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
110
117
 
111
118
 
112
119
 
120
+
121
+
122
+
123
+
124
+
125
+
126
+
113
127
 
114
128
 
115
129
 
@@ -148,6 +162,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
148
162
 
149
163
 
150
164
 
165
+
166
+
167
+
168
+
169
+
170
+
171
+
151
172
 
152
173
 
153
174
 
@@ -191,6 +212,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
191
212
 
192
213
 
193
214
 
215
+
216
+
217
+
218
+
219
+
220
+
221
+
194
222
 
195
223
 
196
224
 
@@ -244,6 +272,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
244
272
 
245
273
 
246
274
 
275
+
276
+
277
+
278
+
279
+
280
+
281
+
247
282
 
248
283
 
249
284
 
@@ -301,6 +336,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
301
336
 
302
337
 
303
338
 
339
+
340
+
341
+
342
+
343
+
344
+
345
+
304
346
 
305
347
 
306
348
 
@@ -342,6 +384,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
342
384
 
343
385
 
344
386
 
387
+
388
+
389
+
390
+
391
+
392
+
393
+
345
394
 
346
395
 
347
396
 
@@ -390,6 +439,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
390
439
 
391
440
 
392
441
 
442
+
443
+
444
+
445
+
446
+
447
+
448
+
393
449
 
394
450
 
395
451
 
@@ -430,6 +486,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
430
486
 
431
487
 
432
488
 
489
+
490
+
491
+
492
+
493
+
494
+
495
+
433
496
 
434
497
 
435
498
 
@@ -467,6 +530,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
467
530
 
468
531
 
469
532
 
533
+
534
+
535
+
536
+
537
+
538
+
539
+
470
540
 
471
541
 
472
542
 
@@ -505,6 +575,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
505
575
 
506
576
 
507
577
 
578
+
579
+
580
+
581
+
582
+
583
+
584
+
508
585
 
509
586
 
510
587
 
@@ -546,6 +623,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
546
623
 
547
624
 
548
625
 
626
+
627
+
628
+
629
+
630
+
631
+
632
+
549
633
 
550
634
 
551
635
 
@@ -587,6 +671,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
587
671
 
588
672
 
589
673
 
674
+
675
+
676
+
677
+
678
+
679
+
680
+
590
681
 
591
682
 
592
683
 
@@ -625,6 +716,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
625
716
 
626
717
 
627
718
 
719
+
720
+
721
+
722
+
723
+
724
+
725
+
628
726
 
629
727
 
630
728
 
@@ -663,6 +761,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
663
761
 
664
762
 
665
763
 
764
+
765
+
766
+
767
+
768
+
769
+
770
+
666
771
 
667
772
 
668
773
 
@@ -704,6 +809,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
704
809
 
705
810
 
706
811
 
812
+
813
+
814
+
815
+
816
+
817
+
818
+
707
819
 
708
820
 
709
821
 
@@ -742,6 +854,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
742
854
 
743
855
 
744
856
 
857
+
858
+
859
+
860
+
861
+
862
+
863
+
745
864
 
746
865
 
747
866
 
@@ -780,6 +899,13 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
780
899
 
781
900
 
782
901
 
902
+
903
+
904
+
905
+
906
+
907
+
908
+
783
909
 
784
910
 
785
911