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.
- package/dist/cjs/index.cjs +126 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +126 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +126 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +126 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/binary-tree-typed.js +126 -0
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +1 -1
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +36 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
- package/src/data-structures/binary-tree/binary-tree.ts +75 -0
- package/src/data-structures/binary-tree/bst.ts +72 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +375 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
- package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
- package/src/data-structures/binary-tree/tree-set.ts +492 -0
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +33 -0
- package/src/data-structures/heap/heap.ts +42 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
- package/src/data-structures/matrix/matrix.ts +24 -0
- package/src/data-structures/queue/deque.ts +103 -1
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +36 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -264,6 +264,35 @@ var IterableElementBase = class {
|
|
|
264
264
|
for (const ele of this) if (ele === element) return true;
|
|
265
265
|
return false;
|
|
266
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
269
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
270
|
+
* @param element - Element to search for (uses `===`).
|
|
271
|
+
* @returns `true` if found.
|
|
272
|
+
*/
|
|
273
|
+
includes(element) {
|
|
274
|
+
return this.has(element);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
278
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
279
|
+
*/
|
|
280
|
+
*entries() {
|
|
281
|
+
let index = 0;
|
|
282
|
+
for (const value of this) {
|
|
283
|
+
yield [index++, value];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
288
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
289
|
+
*/
|
|
290
|
+
*keys() {
|
|
291
|
+
let index = 0;
|
|
292
|
+
for (const _ of this) {
|
|
293
|
+
yield index++;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
267
296
|
/**
|
|
268
297
|
* Reduces all elements to a single accumulated value.
|
|
269
298
|
*
|
|
@@ -526,6 +555,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
526
555
|
}
|
|
527
556
|
return this;
|
|
528
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
560
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
561
|
+
* @returns A new reversed instance.
|
|
562
|
+
*/
|
|
563
|
+
toReversed() {
|
|
564
|
+
const cloned = this.clone();
|
|
565
|
+
cloned.reverse();
|
|
566
|
+
return cloned;
|
|
567
|
+
}
|
|
529
568
|
};
|
|
530
569
|
|
|
531
570
|
// src/data-structures/base/iterable-entry-base.ts
|
|
@@ -805,6 +844,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
805
844
|
|
|
806
845
|
|
|
807
846
|
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
808
850
|
|
|
809
851
|
|
|
810
852
|
|
|
@@ -859,6 +901,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
859
901
|
|
|
860
902
|
|
|
861
903
|
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
862
907
|
|
|
863
908
|
|
|
864
909
|
|
|
@@ -937,6 +982,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
937
982
|
|
|
938
983
|
|
|
939
984
|
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
|
|
940
988
|
|
|
941
989
|
|
|
942
990
|
|
|
@@ -1003,6 +1051,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1003
1051
|
|
|
1004
1052
|
|
|
1005
1053
|
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1006
1057
|
|
|
1007
1058
|
|
|
1008
1059
|
|
|
@@ -1076,6 +1127,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1076
1127
|
|
|
1077
1128
|
|
|
1078
1129
|
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1079
1133
|
|
|
1080
1134
|
|
|
1081
1135
|
|
|
@@ -1139,6 +1193,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1139
1193
|
|
|
1140
1194
|
|
|
1141
1195
|
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1142
1199
|
|
|
1143
1200
|
|
|
1144
1201
|
|
|
@@ -1195,6 +1252,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1195
1252
|
|
|
1196
1253
|
|
|
1197
1254
|
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1198
1258
|
|
|
1199
1259
|
|
|
1200
1260
|
|
|
@@ -1307,6 +1367,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1307
1367
|
|
|
1308
1368
|
|
|
1309
1369
|
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1310
1373
|
|
|
1311
1374
|
|
|
1312
1375
|
|
|
@@ -1357,6 +1420,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1357
1420
|
|
|
1358
1421
|
|
|
1359
1422
|
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1360
1426
|
|
|
1361
1427
|
|
|
1362
1428
|
|
|
@@ -1430,6 +1496,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1430
1496
|
|
|
1431
1497
|
|
|
1432
1498
|
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1433
1502
|
|
|
1434
1503
|
|
|
1435
1504
|
|
|
@@ -1487,6 +1556,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1487
1556
|
|
|
1488
1557
|
|
|
1489
1558
|
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1490
1562
|
|
|
1491
1563
|
|
|
1492
1564
|
|
|
@@ -1548,6 +1620,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1548
1620
|
|
|
1549
1621
|
|
|
1550
1622
|
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1551
1626
|
|
|
1552
1627
|
|
|
1553
1628
|
|
|
@@ -2052,6 +2127,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2052
2127
|
|
|
2053
2128
|
|
|
2054
2129
|
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2055
2133
|
|
|
2056
2134
|
|
|
2057
2135
|
|
|
@@ -2110,6 +2188,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2110
2188
|
|
|
2111
2189
|
|
|
2112
2190
|
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
2113
2194
|
|
|
2114
2195
|
|
|
2115
2196
|
|
|
@@ -2220,6 +2301,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2220
2301
|
|
|
2221
2302
|
|
|
2222
2303
|
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2223
2307
|
|
|
2224
2308
|
|
|
2225
2309
|
|
|
@@ -2266,6 +2350,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2266
2350
|
|
|
2267
2351
|
|
|
2268
2352
|
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
|
|
2269
2356
|
|
|
2270
2357
|
|
|
2271
2358
|
|
|
@@ -2333,6 +2420,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2333
2420
|
|
|
2334
2421
|
|
|
2335
2422
|
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2336
2426
|
|
|
2337
2427
|
|
|
2338
2428
|
|
|
@@ -2439,6 +2529,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2439
2529
|
|
|
2440
2530
|
|
|
2441
2531
|
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2442
2535
|
|
|
2443
2536
|
|
|
2444
2537
|
|
|
@@ -2543,6 +2636,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2543
2636
|
|
|
2544
2637
|
|
|
2545
2638
|
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
|
|
2546
2642
|
|
|
2547
2643
|
|
|
2548
2644
|
|
|
@@ -2605,6 +2701,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2605
2701
|
|
|
2606
2702
|
|
|
2607
2703
|
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2608
2707
|
|
|
2609
2708
|
|
|
2610
2709
|
|
|
@@ -2669,6 +2768,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2669
2768
|
|
|
2670
2769
|
|
|
2671
2770
|
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
|
|
2672
2774
|
|
|
2673
2775
|
|
|
2674
2776
|
|
|
@@ -2721,6 +2823,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2721
2823
|
|
|
2722
2824
|
|
|
2723
2825
|
|
|
2826
|
+
|
|
2827
|
+
|
|
2828
|
+
|
|
2724
2829
|
|
|
2725
2830
|
|
|
2726
2831
|
|
|
@@ -2782,6 +2887,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2782
2887
|
|
|
2783
2888
|
|
|
2784
2889
|
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
|
|
2785
2893
|
|
|
2786
2894
|
|
|
2787
2895
|
|
|
@@ -2870,6 +2978,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2870
2978
|
|
|
2871
2979
|
|
|
2872
2980
|
|
|
2981
|
+
|
|
2982
|
+
|
|
2983
|
+
|
|
2873
2984
|
|
|
2874
2985
|
|
|
2875
2986
|
|
|
@@ -2935,6 +3046,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2935
3046
|
|
|
2936
3047
|
|
|
2937
3048
|
|
|
3049
|
+
|
|
3050
|
+
|
|
3051
|
+
|
|
2938
3052
|
|
|
2939
3053
|
|
|
2940
3054
|
|
|
@@ -3416,6 +3530,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3416
3530
|
|
|
3417
3531
|
|
|
3418
3532
|
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3419
3536
|
|
|
3420
3537
|
|
|
3421
3538
|
|
|
@@ -3472,6 +3589,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3472
3589
|
|
|
3473
3590
|
|
|
3474
3591
|
|
|
3592
|
+
|
|
3593
|
+
|
|
3594
|
+
|
|
3475
3595
|
|
|
3476
3596
|
|
|
3477
3597
|
|
|
@@ -3532,6 +3652,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3532
3652
|
|
|
3533
3653
|
|
|
3534
3654
|
|
|
3655
|
+
|
|
3656
|
+
|
|
3657
|
+
|
|
3535
3658
|
|
|
3536
3659
|
|
|
3537
3660
|
|
|
@@ -3617,6 +3740,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3617
3740
|
|
|
3618
3741
|
|
|
3619
3742
|
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3620
3746
|
|
|
3621
3747
|
|
|
3622
3748
|
|