binary-tree-typed 2.5.3 → 2.6.0

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 (61) hide show
  1. package/dist/cjs/index.cjs +126 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +126 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +126 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +126 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/umd/binary-tree-typed.js +126 -0
  34. package/dist/umd/binary-tree-typed.js.map +1 -1
  35. package/dist/umd/binary-tree-typed.min.js +1 -1
  36. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/data-structures/base/iterable-element-base.ts +32 -0
  39. package/src/data-structures/base/linear-base.ts +11 -0
  40. package/src/data-structures/binary-tree/avl-tree.ts +36 -0
  41. package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
  42. package/src/data-structures/binary-tree/binary-tree.ts +75 -0
  43. package/src/data-structures/binary-tree/bst.ts +72 -0
  44. package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
  45. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  46. package/src/data-structures/binary-tree/tree-map.ts +375 -0
  47. package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
  48. package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
  49. package/src/data-structures/binary-tree/tree-set.ts +492 -0
  50. package/src/data-structures/graph/directed-graph.ts +30 -0
  51. package/src/data-structures/graph/undirected-graph.ts +27 -0
  52. package/src/data-structures/hash/hash-map.ts +33 -0
  53. package/src/data-structures/heap/heap.ts +42 -0
  54. package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
  55. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  56. package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
  57. package/src/data-structures/matrix/matrix.ts +24 -0
  58. package/src/data-structures/queue/deque.ts +103 -1
  59. package/src/data-structures/queue/queue.ts +36 -0
  60. package/src/data-structures/stack/stack.ts +30 -0
  61. package/src/data-structures/trie/trie.ts +36 -0
@@ -253,6 +253,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
253
253
 
254
254
 
255
255
 
256
+
257
+
258
+
256
259
 
257
260
 
258
261
 
@@ -311,6 +314,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
311
314
 
312
315
 
313
316
 
317
+
318
+
319
+
314
320
 
315
321
 
316
322
 
@@ -364,6 +370,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
364
370
 
365
371
 
366
372
 
373
+
374
+
375
+
367
376
 
368
377
 
369
378
 
@@ -413,6 +422,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
413
422
 
414
423
 
415
424
 
425
+
426
+
427
+
416
428
 
417
429
 
418
430
 
@@ -461,6 +473,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
461
473
 
462
474
 
463
475
 
476
+
477
+
478
+
464
479
 
465
480
 
466
481
 
@@ -512,6 +527,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
512
527
 
513
528
 
514
529
 
530
+
531
+
532
+
515
533
 
516
534
 
517
535
 
@@ -588,6 +606,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
588
606
 
589
607
 
590
608
 
609
+
610
+
611
+
591
612
 
592
613
 
593
614
 
@@ -647,6 +668,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
647
668
 
648
669
 
649
670
 
671
+
672
+
673
+
650
674
 
651
675
 
652
676
 
@@ -700,6 +724,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
700
724
 
701
725
 
702
726
 
727
+
728
+
729
+
703
730
 
704
731
 
705
732
 
@@ -753,6 +780,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
753
780
 
754
781
 
755
782
 
783
+
784
+
785
+
756
786
 
757
787
 
758
788
 
@@ -803,6 +833,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
803
833
 
804
834
 
805
835
 
836
+
837
+
838
+
806
839
 
807
840
 
808
841
 
@@ -848,6 +881,9 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
848
881
 
849
882
 
850
883
 
884
+
885
+
886
+
851
887
 
852
888
 
853
889
 
@@ -282,6 +282,35 @@ var binaryTreeTyped = (() => {
282
282
  for (const ele of this) if (ele === element) return true;
283
283
  return false;
284
284
  }
285
+ /**
286
+ * Check whether a value exists (Array-compatible alias for `has`).
287
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
288
+ * @param element - Element to search for (uses `===`).
289
+ * @returns `true` if found.
290
+ */
291
+ includes(element) {
292
+ return this.has(element);
293
+ }
294
+ /**
295
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
296
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
297
+ */
298
+ *entries() {
299
+ let index = 0;
300
+ for (const value of this) {
301
+ yield [index++, value];
302
+ }
303
+ }
304
+ /**
305
+ * Return an iterator of numeric indices (Array-compatible).
306
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
307
+ */
308
+ *keys() {
309
+ let index = 0;
310
+ for (const _ of this) {
311
+ yield index++;
312
+ }
313
+ }
285
314
  /**
286
315
  * Reduces all elements to a single accumulated value.
287
316
  *
@@ -541,6 +570,16 @@ var binaryTreeTyped = (() => {
541
570
  }
542
571
  return this;
543
572
  }
573
+ /**
574
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
575
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
576
+ * @returns A new reversed instance.
577
+ */
578
+ toReversed() {
579
+ const cloned = this.clone();
580
+ cloned.reverse();
581
+ return cloned;
582
+ }
544
583
  };
545
584
 
546
585
  // src/data-structures/base/iterable-entry-base.ts
@@ -814,6 +853,9 @@ var binaryTreeTyped = (() => {
814
853
 
815
854
 
816
855
 
856
+
857
+
858
+
817
859
 
818
860
 
819
861
 
@@ -868,6 +910,9 @@ var binaryTreeTyped = (() => {
868
910
 
869
911
 
870
912
 
913
+
914
+
915
+
871
916
 
872
917
 
873
918
 
@@ -946,6 +991,9 @@ var binaryTreeTyped = (() => {
946
991
 
947
992
 
948
993
 
994
+
995
+
996
+
949
997
 
950
998
 
951
999
 
@@ -1012,6 +1060,9 @@ var binaryTreeTyped = (() => {
1012
1060
 
1013
1061
 
1014
1062
 
1063
+
1064
+
1065
+
1015
1066
 
1016
1067
 
1017
1068
 
@@ -1085,6 +1136,9 @@ var binaryTreeTyped = (() => {
1085
1136
 
1086
1137
 
1087
1138
 
1139
+
1140
+
1141
+
1088
1142
 
1089
1143
 
1090
1144
 
@@ -1148,6 +1202,9 @@ var binaryTreeTyped = (() => {
1148
1202
 
1149
1203
 
1150
1204
 
1205
+
1206
+
1207
+
1151
1208
 
1152
1209
 
1153
1210
 
@@ -1204,6 +1261,9 @@ var binaryTreeTyped = (() => {
1204
1261
 
1205
1262
 
1206
1263
 
1264
+
1265
+
1266
+
1207
1267
 
1208
1268
 
1209
1269
 
@@ -1316,6 +1376,9 @@ var binaryTreeTyped = (() => {
1316
1376
 
1317
1377
 
1318
1378
 
1379
+
1380
+
1381
+
1319
1382
 
1320
1383
 
1321
1384
 
@@ -1366,6 +1429,9 @@ var binaryTreeTyped = (() => {
1366
1429
 
1367
1430
 
1368
1431
 
1432
+
1433
+
1434
+
1369
1435
 
1370
1436
 
1371
1437
 
@@ -1439,6 +1505,9 @@ var binaryTreeTyped = (() => {
1439
1505
 
1440
1506
 
1441
1507
 
1508
+
1509
+
1510
+
1442
1511
 
1443
1512
 
1444
1513
 
@@ -1496,6 +1565,9 @@ var binaryTreeTyped = (() => {
1496
1565
 
1497
1566
 
1498
1567
 
1568
+
1569
+
1570
+
1499
1571
 
1500
1572
 
1501
1573
 
@@ -1557,6 +1629,9 @@ var binaryTreeTyped = (() => {
1557
1629
 
1558
1630
 
1559
1631
 
1632
+
1633
+
1634
+
1560
1635
 
1561
1636
 
1562
1637
 
@@ -2065,6 +2140,9 @@ var binaryTreeTyped = (() => {
2065
2140
 
2066
2141
 
2067
2142
 
2143
+
2144
+
2145
+
2068
2146
 
2069
2147
 
2070
2148
 
@@ -2123,6 +2201,9 @@ var binaryTreeTyped = (() => {
2123
2201
 
2124
2202
 
2125
2203
 
2204
+
2205
+
2206
+
2126
2207
 
2127
2208
 
2128
2209
 
@@ -2233,6 +2314,9 @@ var binaryTreeTyped = (() => {
2233
2314
 
2234
2315
 
2235
2316
 
2317
+
2318
+
2319
+
2236
2320
 
2237
2321
 
2238
2322
 
@@ -2279,6 +2363,9 @@ var binaryTreeTyped = (() => {
2279
2363
 
2280
2364
 
2281
2365
 
2366
+
2367
+
2368
+
2282
2369
 
2283
2370
 
2284
2371
 
@@ -2346,6 +2433,9 @@ var binaryTreeTyped = (() => {
2346
2433
 
2347
2434
 
2348
2435
 
2436
+
2437
+
2438
+
2349
2439
 
2350
2440
 
2351
2441
 
@@ -2452,6 +2542,9 @@ var binaryTreeTyped = (() => {
2452
2542
 
2453
2543
 
2454
2544
 
2545
+
2546
+
2547
+
2455
2548
 
2456
2549
 
2457
2550
 
@@ -2556,6 +2649,9 @@ var binaryTreeTyped = (() => {
2556
2649
 
2557
2650
 
2558
2651
 
2652
+
2653
+
2654
+
2559
2655
 
2560
2656
 
2561
2657
 
@@ -2618,6 +2714,9 @@ var binaryTreeTyped = (() => {
2618
2714
 
2619
2715
 
2620
2716
 
2717
+
2718
+
2719
+
2621
2720
 
2622
2721
 
2623
2722
 
@@ -2683,6 +2782,9 @@ var binaryTreeTyped = (() => {
2683
2782
 
2684
2783
 
2685
2784
 
2785
+
2786
+
2787
+
2686
2788
 
2687
2789
 
2688
2790
 
@@ -2735,6 +2837,9 @@ var binaryTreeTyped = (() => {
2735
2837
 
2736
2838
 
2737
2839
 
2840
+
2841
+
2842
+
2738
2843
 
2739
2844
 
2740
2845
 
@@ -2796,6 +2901,9 @@ var binaryTreeTyped = (() => {
2796
2901
 
2797
2902
 
2798
2903
 
2904
+
2905
+
2906
+
2799
2907
 
2800
2908
 
2801
2909
 
@@ -2884,6 +2992,9 @@ var binaryTreeTyped = (() => {
2884
2992
 
2885
2993
 
2886
2994
 
2995
+
2996
+
2997
+
2887
2998
 
2888
2999
 
2889
3000
 
@@ -2949,6 +3060,9 @@ var binaryTreeTyped = (() => {
2949
3060
 
2950
3061
 
2951
3062
 
3063
+
3064
+
3065
+
2952
3066
 
2953
3067
 
2954
3068
 
@@ -3430,6 +3544,9 @@ var binaryTreeTyped = (() => {
3430
3544
 
3431
3545
 
3432
3546
 
3547
+
3548
+
3549
+
3433
3550
 
3434
3551
 
3435
3552
 
@@ -3486,6 +3603,9 @@ var binaryTreeTyped = (() => {
3486
3603
 
3487
3604
 
3488
3605
 
3606
+
3607
+
3608
+
3489
3609
 
3490
3610
 
3491
3611
 
@@ -3546,6 +3666,9 @@ var binaryTreeTyped = (() => {
3546
3666
 
3547
3667
 
3548
3668
 
3669
+
3670
+
3671
+
3549
3672
 
3550
3673
 
3551
3674
 
@@ -3631,6 +3754,9 @@ var binaryTreeTyped = (() => {
3631
3754
 
3632
3755
 
3633
3756
 
3757
+
3758
+
3759
+
3634
3760
 
3635
3761
 
3636
3762