binary-tree-typed 2.5.0 → 2.5.2

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 (90) hide show
  1. package/dist/cjs/index.cjs +771 -68
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +771 -68
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +771 -69
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +771 -69
  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/base/index.d.ts +1 -0
  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 +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/binary-tree-typed.js +773 -71
  47. package/dist/umd/binary-tree-typed.js.map +1 -1
  48. package/dist/umd/binary-tree-typed.min.js +5 -5
  49. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -168,6 +168,30 @@ 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
+
192
+
193
+
194
+
171
195
  * @example
172
196
  * // Track queue length
173
197
  * const q = new Queue<number>();
@@ -196,6 +220,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
196
220
 
197
221
 
198
222
 
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
199
247
  * @example
200
248
  * // View the front element
201
249
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -244,6 +292,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
244
292
 
245
293
 
246
294
 
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
247
319
  * @example
248
320
  * // Queue for...of iteration and isEmpty check
249
321
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -284,6 +356,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
284
356
 
285
357
 
286
358
 
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
287
383
  * @example
288
384
  * // basic Queue creation and push operation
289
385
  * // Create a simple Queue with initial values
@@ -333,6 +429,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
333
429
 
334
430
 
335
431
 
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
336
456
  * @example
337
457
  * // Queue shift and peek operations
338
458
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -370,6 +490,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
370
490
 
371
491
 
372
492
 
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
373
517
  * @example
374
518
  * // Remove specific element
375
519
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -400,6 +544,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
400
544
 
401
545
 
402
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
+
403
571
  * @example
404
572
  * // Access element by index
405
573
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -479,6 +647,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
479
647
 
480
648
 
481
649
 
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
482
674
  * @example
483
675
  * // Remove all elements
484
676
  * const q = new Queue<number>([1, 2, 3]);
@@ -503,6 +695,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
503
695
 
504
696
 
505
697
 
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
506
722
  * @example
507
723
  * // Reclaim unused memory
508
724
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -556,6 +772,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
556
772
 
557
773
 
558
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
+
559
799
  * @example
560
800
  * // Create independent copy
561
801
  * const q = new Queue<number>([1, 2, 3]);
@@ -587,6 +827,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
587
827
 
588
828
 
589
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
+
590
854
  * @example
591
855
  * // Filter elements
592
856
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -622,6 +886,30 @@ export class Queue<E = any, R = any> extends LinearBase<E, R> {
622
886
 
623
887
 
624
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
+
625
913
  * @example
626
914
  * // Transform elements
627
915
  * const q = new Queue<number>([1, 2, 3]);
@@ -173,6 +173,30 @@ 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
+
197
+
198
+
199
+
176
200
  * @example
177
201
  * // Get number of elements
178
202
  * const stack = new Stack<number>([1, 2, 3]);
@@ -217,6 +241,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
217
241
 
218
242
 
219
243
 
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
220
268
  * @example
221
269
  * // Check if stack has elements
222
270
  * const stack = new Stack<number>();
@@ -244,6 +292,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
244
292
 
245
293
 
246
294
 
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
247
319
  * @example
248
320
  * // View the top element without removing it
249
321
  * const stack = new Stack<string>(['a', 'b', 'c']);
@@ -271,6 +343,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
271
343
 
272
344
 
273
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
+
274
370
  * @example
275
371
  * // basic Stack creation and push operation
276
372
  * // Create a simple Stack with initial values
@@ -307,6 +403,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
307
403
 
308
404
 
309
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
+
310
430
  * @example
311
431
  * // Stack pop operation (LIFO - Last In First Out)
312
432
  * const stack = new Stack<number>([10, 20, 30, 40, 50]);
@@ -360,6 +480,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
360
480
 
361
481
 
362
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
+
363
507
  * @example
364
508
  * // Remove element
365
509
  * const stack = new Stack<number>([1, 2, 3]);
@@ -415,6 +559,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
415
559
 
416
560
 
417
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
+
418
586
  * @example
419
587
  * // Remove all elements
420
588
  * const stack = new Stack<number>([1, 2, 3]);
@@ -439,6 +607,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
439
607
 
440
608
 
441
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
+
442
634
  * @example
443
635
  * // Create independent copy
444
636
  * const stack = new Stack<number>([1, 2, 3]);
@@ -469,6 +661,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
469
661
 
470
662
 
471
663
 
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
472
688
  * @example
473
689
  * // Filter elements
474
690
  * const stack = new Stack<number>([1, 2, 3, 4, 5]);
@@ -521,6 +737,30 @@ export class Stack<E = any, R = any> extends IterableElementBase<E, R> {
521
737
 
522
738
 
523
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
+
524
764
  * @example
525
765
  * // Transform elements
526
766
  * const stack = new Stack<number>([1, 2, 3]);