binary-tree-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 (75) hide show
  1. package/dist/cjs/index.cjs +609 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +609 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +609 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +609 -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/binary-tree-typed.js +609 -0
  41. package/dist/umd/binary-tree-typed.js.map +1 -1
  42. package/dist/umd/binary-tree-typed.min.js +5 -5
  43. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/data-structures/base/index.ts +1 -0
  46. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  47. package/src/data-structures/base/linear-base.ts +3 -3
  48. package/src/data-structures/binary-tree/avl-tree.ts +252 -0
  49. package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
  50. package/src/data-structures/binary-tree/binary-tree.ts +527 -2
  51. package/src/data-structures/binary-tree/bst.ts +505 -1
  52. package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
  53. package/src/data-structures/binary-tree/segment-tree.ts +127 -2
  54. package/src/data-structures/binary-tree/tree-map.ts +2958 -459
  55. package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
  56. package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
  57. package/src/data-structures/binary-tree/tree-set.ts +2816 -422
  58. package/src/data-structures/graph/abstract-graph.ts +4 -4
  59. package/src/data-structures/graph/directed-graph.ts +210 -0
  60. package/src/data-structures/graph/undirected-graph.ts +189 -0
  61. package/src/data-structures/hash/hash-map.ts +246 -15
  62. package/src/data-structures/heap/heap.ts +294 -0
  63. package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
  64. package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
  65. package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
  66. package/src/data-structures/matrix/matrix.ts +169 -1
  67. package/src/data-structures/queue/deque.ts +320 -5
  68. package/src/data-structures/queue/queue.ts +252 -0
  69. package/src/data-structures/stack/stack.ts +210 -0
  70. package/src/data-structures/trie/trie.ts +257 -5
  71. package/src/interfaces/graph.ts +1 -1
  72. package/src/types/common.ts +2 -2
  73. package/src/types/data-structures/heap/heap.ts +1 -0
  74. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  75. package/src/types/utils/validate-type.ts +4 -4
@@ -168,6 +168,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
168
168
 
169
169
 
170
170
 
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
171
192
  * @example
172
193
  * // Track queue length
173
194
  * const q = new Queue<number>();
@@ -196,6 +217,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
196
217
 
197
218
 
198
219
 
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
199
241
  * @example
200
242
  * // View the front element
201
243
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -244,6 +286,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
244
286
 
245
287
 
246
288
 
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
247
310
  * @example
248
311
  * // Queue for...of iteration and isEmpty check
249
312
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -284,6 +347,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
284
347
 
285
348
 
286
349
 
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
287
371
  * @example
288
372
  * // basic Queue creation and push operation
289
373
  * // Create a simple Queue with initial values
@@ -333,6 +417,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
333
417
 
334
418
 
335
419
 
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
336
441
  * @example
337
442
  * // Queue shift and peek operations
338
443
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -370,6 +475,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
370
475
 
371
476
 
372
477
 
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
373
499
  * @example
374
500
  * // Remove specific element
375
501
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -400,6 +526,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
400
526
 
401
527
 
402
528
 
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
403
550
  * @example
404
551
  * // Access element by index
405
552
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -479,6 +626,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
479
626
 
480
627
 
481
628
 
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
482
650
  * @example
483
651
  * // Remove all elements
484
652
  * const q = new Queue<number>([1, 2, 3]);
@@ -503,6 +671,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
503
671
 
504
672
 
505
673
 
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
506
695
  * @example
507
696
  * // Reclaim unused memory
508
697
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -556,6 +745,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
556
745
 
557
746
 
558
747
 
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
559
769
  * @example
560
770
  * // Create independent copy
561
771
  * const q = new Queue<number>([1, 2, 3]);
@@ -587,6 +797,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
587
797
 
588
798
 
589
799
 
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+
818
+
819
+
820
+
590
821
  * @example
591
822
  * // Filter elements
592
823
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -622,6 +853,27 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
622
853
 
623
854
 
624
855
 
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+
875
+
876
+
625
877
  * @example
626
878
  * // Transform elements
627
879
  * const q = new Queue<number>([1, 2, 3]);
@@ -173,6 +173,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
173
173
 
174
174
 
175
175
 
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
176
197
  * @example
177
198
  * // Get number of elements
178
199
  * const stack = new Stack<number>([1, 2, 3]);
@@ -217,6 +238,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
217
238
 
218
239
 
219
240
 
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
220
262
  * @example
221
263
  * // Check if stack has elements
222
264
  * const stack = new Stack<number>();
@@ -244,6 +286,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
244
286
 
245
287
 
246
288
 
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
247
310
  * @example
248
311
  * // View the top element without removing it
249
312
  * const stack = new Stack<string>(['a', 'b', 'c']);
@@ -271,6 +334,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
271
334
 
272
335
 
273
336
 
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
274
358
  * @example
275
359
  * // basic Stack creation and push operation
276
360
  * // Create a simple Stack with initial values
@@ -307,6 +391,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
307
391
 
308
392
 
309
393
 
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
310
415
  * @example
311
416
  * // Stack pop operation (LIFO - Last In First Out)
312
417
  * const stack = new Stack<number>([10, 20, 30, 40, 50]);
@@ -360,6 +465,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
360
465
 
361
466
 
362
467
 
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
363
489
  * @example
364
490
  * // Remove element
365
491
  * const stack = new Stack<number>([1, 2, 3]);
@@ -415,6 +541,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
415
541
 
416
542
 
417
543
 
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
418
565
  * @example
419
566
  * // Remove all elements
420
567
  * const stack = new Stack<number>([1, 2, 3]);
@@ -439,6 +586,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
439
586
 
440
587
 
441
588
 
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
442
610
  * @example
443
611
  * // Create independent copy
444
612
  * const stack = new Stack<number>([1, 2, 3]);
@@ -469,6 +637,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
469
637
 
470
638
 
471
639
 
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
472
661
  * @example
473
662
  * // Filter elements
474
663
  * const stack = new Stack<number>([1, 2, 3, 4, 5]);
@@ -521,6 +710,27 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
521
710
 
522
711
 
523
712
 
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
524
734
  * @example
525
735
  * // Transform elements
526
736
  * const stack = new Stack<number>([1, 2, 3]);