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
|
@@ -264,6 +264,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
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
|
*
|
|
@@ -525,6 +554,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
525
554
|
}
|
|
526
555
|
return this;
|
|
527
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
559
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
560
|
+
* @returns A new reversed instance.
|
|
561
|
+
*/
|
|
562
|
+
toReversed() {
|
|
563
|
+
const cloned = this.clone();
|
|
564
|
+
cloned.reverse();
|
|
565
|
+
return cloned;
|
|
566
|
+
}
|
|
528
567
|
};
|
|
529
568
|
__name(_LinearBase, "LinearBase");
|
|
530
569
|
var LinearBase = _LinearBase;
|
|
@@ -802,6 +841,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
802
841
|
|
|
803
842
|
|
|
804
843
|
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
805
847
|
|
|
806
848
|
|
|
807
849
|
|
|
@@ -856,6 +898,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
856
898
|
|
|
857
899
|
|
|
858
900
|
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
859
904
|
|
|
860
905
|
|
|
861
906
|
|
|
@@ -934,6 +979,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
934
979
|
|
|
935
980
|
|
|
936
981
|
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
937
985
|
|
|
938
986
|
|
|
939
987
|
|
|
@@ -1000,6 +1048,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1000
1048
|
|
|
1001
1049
|
|
|
1002
1050
|
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
1003
1054
|
|
|
1004
1055
|
|
|
1005
1056
|
|
|
@@ -1073,6 +1124,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1073
1124
|
|
|
1074
1125
|
|
|
1075
1126
|
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1076
1130
|
|
|
1077
1131
|
|
|
1078
1132
|
|
|
@@ -1136,6 +1190,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1136
1190
|
|
|
1137
1191
|
|
|
1138
1192
|
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1139
1196
|
|
|
1140
1197
|
|
|
1141
1198
|
|
|
@@ -1192,6 +1249,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1192
1249
|
|
|
1193
1250
|
|
|
1194
1251
|
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1195
1255
|
|
|
1196
1256
|
|
|
1197
1257
|
|
|
@@ -1304,6 +1364,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1304
1364
|
|
|
1305
1365
|
|
|
1306
1366
|
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1307
1370
|
|
|
1308
1371
|
|
|
1309
1372
|
|
|
@@ -1354,6 +1417,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1354
1417
|
|
|
1355
1418
|
|
|
1356
1419
|
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1357
1423
|
|
|
1358
1424
|
|
|
1359
1425
|
|
|
@@ -1427,6 +1493,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1427
1493
|
|
|
1428
1494
|
|
|
1429
1495
|
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1430
1499
|
|
|
1431
1500
|
|
|
1432
1501
|
|
|
@@ -1484,6 +1553,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1484
1553
|
|
|
1485
1554
|
|
|
1486
1555
|
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1487
1559
|
|
|
1488
1560
|
|
|
1489
1561
|
|
|
@@ -1545,6 +1617,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1545
1617
|
|
|
1546
1618
|
|
|
1547
1619
|
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1548
1623
|
|
|
1549
1624
|
|
|
1550
1625
|
|
|
@@ -2057,6 +2132,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2057
2132
|
|
|
2058
2133
|
|
|
2059
2134
|
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
|
|
2060
2138
|
|
|
2061
2139
|
|
|
2062
2140
|
|
|
@@ -2115,6 +2193,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2115
2193
|
|
|
2116
2194
|
|
|
2117
2195
|
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
|
|
2118
2199
|
|
|
2119
2200
|
|
|
2120
2201
|
|
|
@@ -2225,6 +2306,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2225
2306
|
|
|
2226
2307
|
|
|
2227
2308
|
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2228
2312
|
|
|
2229
2313
|
|
|
2230
2314
|
|
|
@@ -2271,6 +2355,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2271
2355
|
|
|
2272
2356
|
|
|
2273
2357
|
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
|
|
2274
2361
|
|
|
2275
2362
|
|
|
2276
2363
|
|
|
@@ -2338,6 +2425,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2338
2425
|
|
|
2339
2426
|
|
|
2340
2427
|
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2341
2431
|
|
|
2342
2432
|
|
|
2343
2433
|
|
|
@@ -2444,6 +2534,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2444
2534
|
|
|
2445
2535
|
|
|
2446
2536
|
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2447
2540
|
|
|
2448
2541
|
|
|
2449
2542
|
|
|
@@ -2548,6 +2641,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2548
2641
|
|
|
2549
2642
|
|
|
2550
2643
|
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
|
|
2551
2647
|
|
|
2552
2648
|
|
|
2553
2649
|
|
|
@@ -2610,6 +2706,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2610
2706
|
|
|
2611
2707
|
|
|
2612
2708
|
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2613
2712
|
|
|
2614
2713
|
|
|
2615
2714
|
|
|
@@ -2675,6 +2774,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2675
2774
|
|
|
2676
2775
|
|
|
2677
2776
|
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2678
2780
|
|
|
2679
2781
|
|
|
2680
2782
|
|
|
@@ -2727,6 +2829,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2727
2829
|
|
|
2728
2830
|
|
|
2729
2831
|
|
|
2832
|
+
|
|
2833
|
+
|
|
2834
|
+
|
|
2730
2835
|
|
|
2731
2836
|
|
|
2732
2837
|
|
|
@@ -2788,6 +2893,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2788
2893
|
|
|
2789
2894
|
|
|
2790
2895
|
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
|
|
2791
2899
|
|
|
2792
2900
|
|
|
2793
2901
|
|
|
@@ -2876,6 +2984,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2876
2984
|
|
|
2877
2985
|
|
|
2878
2986
|
|
|
2987
|
+
|
|
2988
|
+
|
|
2989
|
+
|
|
2879
2990
|
|
|
2880
2991
|
|
|
2881
2992
|
|
|
@@ -2941,6 +3052,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2941
3052
|
|
|
2942
3053
|
|
|
2943
3054
|
|
|
3055
|
+
|
|
3056
|
+
|
|
3057
|
+
|
|
2944
3058
|
|
|
2945
3059
|
|
|
2946
3060
|
|
|
@@ -3422,6 +3536,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3422
3536
|
|
|
3423
3537
|
|
|
3424
3538
|
|
|
3539
|
+
|
|
3540
|
+
|
|
3541
|
+
|
|
3425
3542
|
|
|
3426
3543
|
|
|
3427
3544
|
|
|
@@ -3478,6 +3595,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3478
3595
|
|
|
3479
3596
|
|
|
3480
3597
|
|
|
3598
|
+
|
|
3599
|
+
|
|
3600
|
+
|
|
3481
3601
|
|
|
3482
3602
|
|
|
3483
3603
|
|
|
@@ -3538,6 +3658,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3538
3658
|
|
|
3539
3659
|
|
|
3540
3660
|
|
|
3661
|
+
|
|
3662
|
+
|
|
3663
|
+
|
|
3541
3664
|
|
|
3542
3665
|
|
|
3543
3666
|
|
|
@@ -3623,6 +3746,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3623
3746
|
|
|
3624
3747
|
|
|
3625
3748
|
|
|
3749
|
+
|
|
3750
|
+
|
|
3751
|
+
|
|
3626
3752
|
|
|
3627
3753
|
|
|
3628
3754
|
|