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
@@ -138,6 +138,27 @@ 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
+
141
162
  * @example
142
163
  * // Track queue length
143
164
  * const q = new Queue<number>();
@@ -162,6 +183,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
162
183
 
163
184
 
164
185
 
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
165
207
  * @example
166
208
  * // View the front element
167
209
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -198,6 +240,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
198
240
 
199
241
 
200
242
 
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
201
264
  * @example
202
265
  * // Queue for...of iteration and isEmpty check
203
266
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -234,6 +297,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
234
297
 
235
298
 
236
299
 
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
237
321
  * @example
238
322
  * // basic Queue creation and push operation
239
323
  * // Create a simple Queue with initial values
@@ -268,6 +352,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
268
352
 
269
353
 
270
354
 
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
271
376
  * @example
272
377
  * // Queue shift and peek operations
273
378
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -297,6 +402,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
297
402
 
298
403
 
299
404
 
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
300
426
  * @example
301
427
  * // Remove specific element
302
428
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -317,6 +443,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
317
443
 
318
444
 
319
445
 
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
320
467
  * @example
321
468
  * // Access element by index
322
469
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -366,6 +513,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
366
513
 
367
514
 
368
515
 
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
369
537
  * @example
370
538
  * // Remove all elements
371
539
  * const q = new Queue<number>([1, 2, 3]);
@@ -385,6 +553,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
385
553
 
386
554
 
387
555
 
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
388
577
  * @example
389
578
  * // Reclaim unused memory
390
579
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -416,6 +605,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
416
605
 
417
606
 
418
607
 
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
419
629
  * @example
420
630
  * // Create independent copy
421
631
  * const q = new Queue<number>([1, 2, 3]);
@@ -440,6 +650,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
440
650
 
441
651
 
442
652
 
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
443
674
  * @example
444
675
  * // Filter elements
445
676
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -464,6 +695,27 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
464
695
 
465
696
 
466
697
 
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
467
719
  * @example
468
720
  * // Transform elements
469
721
  * const q = new Queue<number>([1, 2, 3]);
@@ -160,6 +160,27 @@ 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
+
163
184
  * @example
164
185
  * // Get number of elements
165
186
  * const stack = new Stack<number>([1, 2, 3]);
@@ -192,6 +213,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
192
213
 
193
214
 
194
215
 
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
195
237
  * @example
196
238
  * // Check if stack has elements
197
239
  * const stack = new Stack<number>();
@@ -215,6 +257,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
215
257
 
216
258
 
217
259
 
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
218
281
  * @example
219
282
  * // View the top element without removing it
220
283
  * const stack = new Stack<string>(['a', 'b', 'c']);
@@ -238,6 +301,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
238
301
 
239
302
 
240
303
 
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
241
325
  * @example
242
326
  * // basic Stack creation and push operation
243
327
  * // Create a simple Stack with initial values
@@ -269,6 +353,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
269
353
 
270
354
 
271
355
 
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
272
377
  * @example
273
378
  * // Stack pop operation (LIFO - Last In First Out)
274
379
  * const stack = new Stack<number>([10, 20, 30, 40, 50]);
@@ -309,6 +414,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
309
414
 
310
415
 
311
416
 
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
312
438
  * @example
313
439
  * // Remove element
314
440
  * const stack = new Stack<number>([1, 2, 3]);
@@ -343,6 +469,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
343
469
 
344
470
 
345
471
 
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
346
493
  * @example
347
494
  * // Remove all elements
348
495
  * const stack = new Stack<number>([1, 2, 3]);
@@ -363,6 +510,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
363
510
 
364
511
 
365
512
 
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
366
534
  * @example
367
535
  * // Create independent copy
368
536
  * const stack = new Stack<number>([1, 2, 3]);
@@ -387,6 +555,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
387
555
 
388
556
 
389
557
 
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
390
579
  * @example
391
580
  * // Filter elements
392
581
  * const stack = new Stack<number>([1, 2, 3, 4, 5]);
@@ -419,6 +608,27 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
419
608
 
420
609
 
421
610
 
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
422
632
  * @example
423
633
  * // Transform elements
424
634
  * const stack = new Stack<number>([1, 2, 3]);