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
@@ -138,6 +138,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
138
138
 
139
139
 
140
140
 
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
141
165
  * @example
142
166
  * // Track queue length
143
167
  * const q = new Queue<number>();
@@ -162,6 +186,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
162
186
 
163
187
 
164
188
 
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
165
213
  * @example
166
214
  * // View the front element
167
215
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -198,6 +246,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
198
246
 
199
247
 
200
248
 
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
201
273
  * @example
202
274
  * // Queue for...of iteration and isEmpty check
203
275
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -234,6 +306,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
234
306
 
235
307
 
236
308
 
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
237
333
  * @example
238
334
  * // basic Queue creation and push operation
239
335
  * // Create a simple Queue with initial values
@@ -268,6 +364,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
268
364
 
269
365
 
270
366
 
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
271
391
  * @example
272
392
  * // Queue shift and peek operations
273
393
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -297,6 +417,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
297
417
 
298
418
 
299
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
+
300
444
  * @example
301
445
  * // Remove specific element
302
446
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -317,6 +461,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
317
461
 
318
462
 
319
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
+
320
488
  * @example
321
489
  * // Access element by index
322
490
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -366,6 +534,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
366
534
 
367
535
 
368
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
+
369
561
  * @example
370
562
  * // Remove all elements
371
563
  * const q = new Queue<number>([1, 2, 3]);
@@ -385,6 +577,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
385
577
 
386
578
 
387
579
 
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
388
604
  * @example
389
605
  * // Reclaim unused memory
390
606
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -416,6 +632,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
416
632
 
417
633
 
418
634
 
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
419
659
  * @example
420
660
  * // Create independent copy
421
661
  * const q = new Queue<number>([1, 2, 3]);
@@ -440,6 +680,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
440
680
 
441
681
 
442
682
 
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
443
707
  * @example
444
708
  * // Filter elements
445
709
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -464,6 +728,30 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
464
728
 
465
729
 
466
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
+
467
755
  * @example
468
756
  * // Transform elements
469
757
  * const q = new Queue<number>([1, 2, 3]);
@@ -160,6 +160,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
160
160
 
161
161
 
162
162
 
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
163
187
  * @example
164
188
  * // Get number of elements
165
189
  * const stack = new Stack<number>([1, 2, 3]);
@@ -192,6 +216,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
192
216
 
193
217
 
194
218
 
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
195
243
  * @example
196
244
  * // Check if stack has elements
197
245
  * const stack = new Stack<number>();
@@ -215,6 +263,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
215
263
 
216
264
 
217
265
 
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
218
290
  * @example
219
291
  * // View the top element without removing it
220
292
  * const stack = new Stack<string>(['a', 'b', 'c']);
@@ -238,6 +310,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
238
310
 
239
311
 
240
312
 
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
241
337
  * @example
242
338
  * // basic Stack creation and push operation
243
339
  * // Create a simple Stack with initial values
@@ -269,6 +365,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
269
365
 
270
366
 
271
367
 
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
272
392
  * @example
273
393
  * // Stack pop operation (LIFO - Last In First Out)
274
394
  * const stack = new Stack<number>([10, 20, 30, 40, 50]);
@@ -309,6 +429,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
309
429
 
310
430
 
311
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
+
312
456
  * @example
313
457
  * // Remove element
314
458
  * const stack = new Stack<number>([1, 2, 3]);
@@ -343,6 +487,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
343
487
 
344
488
 
345
489
 
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
346
514
  * @example
347
515
  * // Remove all elements
348
516
  * const stack = new Stack<number>([1, 2, 3]);
@@ -363,6 +531,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
363
531
 
364
532
 
365
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
+
366
558
  * @example
367
559
  * // Create independent copy
368
560
  * const stack = new Stack<number>([1, 2, 3]);
@@ -387,6 +579,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
387
579
 
388
580
 
389
581
 
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
390
606
  * @example
391
607
  * // Filter elements
392
608
  * const stack = new Stack<number>([1, 2, 3, 4, 5]);
@@ -419,6 +635,30 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
419
635
 
420
636
 
421
637
 
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
422
662
  * @example
423
663
  * // Transform elements
424
664
  * const stack = new Stack<number>([1, 2, 3]);