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
|
@@ -262,6 +262,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
262
262
|
for (const ele of this) if (ele === element) return true;
|
|
263
263
|
return false;
|
|
264
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
267
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
268
|
+
* @param element - Element to search for (uses `===`).
|
|
269
|
+
* @returns `true` if found.
|
|
270
|
+
*/
|
|
271
|
+
includes(element) {
|
|
272
|
+
return this.has(element);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
276
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
277
|
+
*/
|
|
278
|
+
*entries() {
|
|
279
|
+
let index = 0;
|
|
280
|
+
for (const value of this) {
|
|
281
|
+
yield [index++, value];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
286
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
287
|
+
*/
|
|
288
|
+
*keys() {
|
|
289
|
+
let index = 0;
|
|
290
|
+
for (const _ of this) {
|
|
291
|
+
yield index++;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
265
294
|
/**
|
|
266
295
|
* Reduces all elements to a single accumulated value.
|
|
267
296
|
*
|
|
@@ -523,6 +552,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
523
552
|
}
|
|
524
553
|
return this;
|
|
525
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
557
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
558
|
+
* @returns A new reversed instance.
|
|
559
|
+
*/
|
|
560
|
+
toReversed() {
|
|
561
|
+
const cloned = this.clone();
|
|
562
|
+
cloned.reverse();
|
|
563
|
+
return cloned;
|
|
564
|
+
}
|
|
526
565
|
};
|
|
527
566
|
__name(_LinearBase, "LinearBase");
|
|
528
567
|
var LinearBase = _LinearBase;
|
|
@@ -800,6 +839,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
800
839
|
|
|
801
840
|
|
|
802
841
|
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
803
845
|
|
|
804
846
|
|
|
805
847
|
|
|
@@ -854,6 +896,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
854
896
|
|
|
855
897
|
|
|
856
898
|
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
857
902
|
|
|
858
903
|
|
|
859
904
|
|
|
@@ -932,6 +977,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
932
977
|
|
|
933
978
|
|
|
934
979
|
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
935
983
|
|
|
936
984
|
|
|
937
985
|
|
|
@@ -998,6 +1046,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
998
1046
|
|
|
999
1047
|
|
|
1000
1048
|
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1001
1052
|
|
|
1002
1053
|
|
|
1003
1054
|
|
|
@@ -1071,6 +1122,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1071
1122
|
|
|
1072
1123
|
|
|
1073
1124
|
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1074
1128
|
|
|
1075
1129
|
|
|
1076
1130
|
|
|
@@ -1134,6 +1188,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1134
1188
|
|
|
1135
1189
|
|
|
1136
1190
|
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1137
1194
|
|
|
1138
1195
|
|
|
1139
1196
|
|
|
@@ -1190,6 +1247,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1190
1247
|
|
|
1191
1248
|
|
|
1192
1249
|
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1193
1253
|
|
|
1194
1254
|
|
|
1195
1255
|
|
|
@@ -1302,6 +1362,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1302
1362
|
|
|
1303
1363
|
|
|
1304
1364
|
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
1305
1368
|
|
|
1306
1369
|
|
|
1307
1370
|
|
|
@@ -1352,6 +1415,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1352
1415
|
|
|
1353
1416
|
|
|
1354
1417
|
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1355
1421
|
|
|
1356
1422
|
|
|
1357
1423
|
|
|
@@ -1425,6 +1491,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1425
1491
|
|
|
1426
1492
|
|
|
1427
1493
|
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1428
1497
|
|
|
1429
1498
|
|
|
1430
1499
|
|
|
@@ -1482,6 +1551,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1482
1551
|
|
|
1483
1552
|
|
|
1484
1553
|
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1485
1557
|
|
|
1486
1558
|
|
|
1487
1559
|
|
|
@@ -1543,6 +1615,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1543
1615
|
|
|
1544
1616
|
|
|
1545
1617
|
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1546
1621
|
|
|
1547
1622
|
|
|
1548
1623
|
|
|
@@ -2055,6 +2130,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2055
2130
|
|
|
2056
2131
|
|
|
2057
2132
|
|
|
2133
|
+
|
|
2134
|
+
|
|
2135
|
+
|
|
2058
2136
|
|
|
2059
2137
|
|
|
2060
2138
|
|
|
@@ -2113,6 +2191,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2113
2191
|
|
|
2114
2192
|
|
|
2115
2193
|
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
|
|
2116
2197
|
|
|
2117
2198
|
|
|
2118
2199
|
|
|
@@ -2223,6 +2304,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2223
2304
|
|
|
2224
2305
|
|
|
2225
2306
|
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2226
2310
|
|
|
2227
2311
|
|
|
2228
2312
|
|
|
@@ -2269,6 +2353,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2269
2353
|
|
|
2270
2354
|
|
|
2271
2355
|
|
|
2356
|
+
|
|
2357
|
+
|
|
2358
|
+
|
|
2272
2359
|
|
|
2273
2360
|
|
|
2274
2361
|
|
|
@@ -2336,6 +2423,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2336
2423
|
|
|
2337
2424
|
|
|
2338
2425
|
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2339
2429
|
|
|
2340
2430
|
|
|
2341
2431
|
|
|
@@ -2442,6 +2532,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2442
2532
|
|
|
2443
2533
|
|
|
2444
2534
|
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2445
2538
|
|
|
2446
2539
|
|
|
2447
2540
|
|
|
@@ -2546,6 +2639,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2546
2639
|
|
|
2547
2640
|
|
|
2548
2641
|
|
|
2642
|
+
|
|
2643
|
+
|
|
2644
|
+
|
|
2549
2645
|
|
|
2550
2646
|
|
|
2551
2647
|
|
|
@@ -2608,6 +2704,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2608
2704
|
|
|
2609
2705
|
|
|
2610
2706
|
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2611
2710
|
|
|
2612
2711
|
|
|
2613
2712
|
|
|
@@ -2673,6 +2772,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2673
2772
|
|
|
2674
2773
|
|
|
2675
2774
|
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
|
|
2676
2778
|
|
|
2677
2779
|
|
|
2678
2780
|
|
|
@@ -2725,6 +2827,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2725
2827
|
|
|
2726
2828
|
|
|
2727
2829
|
|
|
2830
|
+
|
|
2831
|
+
|
|
2832
|
+
|
|
2728
2833
|
|
|
2729
2834
|
|
|
2730
2835
|
|
|
@@ -2786,6 +2891,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2786
2891
|
|
|
2787
2892
|
|
|
2788
2893
|
|
|
2894
|
+
|
|
2895
|
+
|
|
2896
|
+
|
|
2789
2897
|
|
|
2790
2898
|
|
|
2791
2899
|
|
|
@@ -2874,6 +2982,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2874
2982
|
|
|
2875
2983
|
|
|
2876
2984
|
|
|
2985
|
+
|
|
2986
|
+
|
|
2987
|
+
|
|
2877
2988
|
|
|
2878
2989
|
|
|
2879
2990
|
|
|
@@ -2939,6 +3050,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2939
3050
|
|
|
2940
3051
|
|
|
2941
3052
|
|
|
3053
|
+
|
|
3054
|
+
|
|
3055
|
+
|
|
2942
3056
|
|
|
2943
3057
|
|
|
2944
3058
|
|
|
@@ -3420,6 +3534,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3420
3534
|
|
|
3421
3535
|
|
|
3422
3536
|
|
|
3537
|
+
|
|
3538
|
+
|
|
3539
|
+
|
|
3423
3540
|
|
|
3424
3541
|
|
|
3425
3542
|
|
|
@@ -3476,6 +3593,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3476
3593
|
|
|
3477
3594
|
|
|
3478
3595
|
|
|
3596
|
+
|
|
3597
|
+
|
|
3598
|
+
|
|
3479
3599
|
|
|
3480
3600
|
|
|
3481
3601
|
|
|
@@ -3536,6 +3656,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3536
3656
|
|
|
3537
3657
|
|
|
3538
3658
|
|
|
3659
|
+
|
|
3660
|
+
|
|
3661
|
+
|
|
3539
3662
|
|
|
3540
3663
|
|
|
3541
3664
|
|
|
@@ -3621,6 +3744,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3621
3744
|
|
|
3622
3745
|
|
|
3623
3746
|
|
|
3747
|
+
|
|
3748
|
+
|
|
3749
|
+
|
|
3624
3750
|
|
|
3625
3751
|
|
|
3626
3752
|
|