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/cjs/index.cjs
CHANGED
|
@@ -266,6 +266,35 @@ var IterableElementBase = class {
|
|
|
266
266
|
for (const ele of this) if (ele === element) return true;
|
|
267
267
|
return false;
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
271
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
272
|
+
* @param element - Element to search for (uses `===`).
|
|
273
|
+
* @returns `true` if found.
|
|
274
|
+
*/
|
|
275
|
+
includes(element) {
|
|
276
|
+
return this.has(element);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
280
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
281
|
+
*/
|
|
282
|
+
*entries() {
|
|
283
|
+
let index = 0;
|
|
284
|
+
for (const value of this) {
|
|
285
|
+
yield [index++, value];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
290
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
291
|
+
*/
|
|
292
|
+
*keys() {
|
|
293
|
+
let index = 0;
|
|
294
|
+
for (const _ of this) {
|
|
295
|
+
yield index++;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
269
298
|
/**
|
|
270
299
|
* Reduces all elements to a single accumulated value.
|
|
271
300
|
*
|
|
@@ -528,6 +557,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
528
557
|
}
|
|
529
558
|
return this;
|
|
530
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
562
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
563
|
+
* @returns A new reversed instance.
|
|
564
|
+
*/
|
|
565
|
+
toReversed() {
|
|
566
|
+
const cloned = this.clone();
|
|
567
|
+
cloned.reverse();
|
|
568
|
+
return cloned;
|
|
569
|
+
}
|
|
531
570
|
};
|
|
532
571
|
|
|
533
572
|
// src/data-structures/base/iterable-entry-base.ts
|
|
@@ -807,6 +846,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
807
846
|
|
|
808
847
|
|
|
809
848
|
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
810
852
|
|
|
811
853
|
|
|
812
854
|
|
|
@@ -861,6 +903,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
861
903
|
|
|
862
904
|
|
|
863
905
|
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
864
909
|
|
|
865
910
|
|
|
866
911
|
|
|
@@ -939,6 +984,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
939
984
|
|
|
940
985
|
|
|
941
986
|
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
|
|
942
990
|
|
|
943
991
|
|
|
944
992
|
|
|
@@ -1005,6 +1053,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1005
1053
|
|
|
1006
1054
|
|
|
1007
1055
|
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1008
1059
|
|
|
1009
1060
|
|
|
1010
1061
|
|
|
@@ -1078,6 +1129,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1078
1129
|
|
|
1079
1130
|
|
|
1080
1131
|
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1081
1135
|
|
|
1082
1136
|
|
|
1083
1137
|
|
|
@@ -1141,6 +1195,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1141
1195
|
|
|
1142
1196
|
|
|
1143
1197
|
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1144
1201
|
|
|
1145
1202
|
|
|
1146
1203
|
|
|
@@ -1197,6 +1254,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1197
1254
|
|
|
1198
1255
|
|
|
1199
1256
|
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1200
1260
|
|
|
1201
1261
|
|
|
1202
1262
|
|
|
@@ -1309,6 +1369,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1309
1369
|
|
|
1310
1370
|
|
|
1311
1371
|
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1312
1375
|
|
|
1313
1376
|
|
|
1314
1377
|
|
|
@@ -1359,6 +1422,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1359
1422
|
|
|
1360
1423
|
|
|
1361
1424
|
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1362
1428
|
|
|
1363
1429
|
|
|
1364
1430
|
|
|
@@ -1432,6 +1498,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1432
1498
|
|
|
1433
1499
|
|
|
1434
1500
|
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1435
1504
|
|
|
1436
1505
|
|
|
1437
1506
|
|
|
@@ -1489,6 +1558,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1489
1558
|
|
|
1490
1559
|
|
|
1491
1560
|
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1492
1564
|
|
|
1493
1565
|
|
|
1494
1566
|
|
|
@@ -1550,6 +1622,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1550
1622
|
|
|
1551
1623
|
|
|
1552
1624
|
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1553
1628
|
|
|
1554
1629
|
|
|
1555
1630
|
|
|
@@ -2054,6 +2129,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2054
2129
|
|
|
2055
2130
|
|
|
2056
2131
|
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
|
|
2057
2135
|
|
|
2058
2136
|
|
|
2059
2137
|
|
|
@@ -2112,6 +2190,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2112
2190
|
|
|
2113
2191
|
|
|
2114
2192
|
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
|
|
2115
2196
|
|
|
2116
2197
|
|
|
2117
2198
|
|
|
@@ -2222,6 +2303,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2222
2303
|
|
|
2223
2304
|
|
|
2224
2305
|
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2225
2309
|
|
|
2226
2310
|
|
|
2227
2311
|
|
|
@@ -2268,6 +2352,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2268
2352
|
|
|
2269
2353
|
|
|
2270
2354
|
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
|
|
2271
2358
|
|
|
2272
2359
|
|
|
2273
2360
|
|
|
@@ -2335,6 +2422,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2335
2422
|
|
|
2336
2423
|
|
|
2337
2424
|
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2338
2428
|
|
|
2339
2429
|
|
|
2340
2430
|
|
|
@@ -2441,6 +2531,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2441
2531
|
|
|
2442
2532
|
|
|
2443
2533
|
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2444
2537
|
|
|
2445
2538
|
|
|
2446
2539
|
|
|
@@ -2545,6 +2638,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2545
2638
|
|
|
2546
2639
|
|
|
2547
2640
|
|
|
2641
|
+
|
|
2642
|
+
|
|
2643
|
+
|
|
2548
2644
|
|
|
2549
2645
|
|
|
2550
2646
|
|
|
@@ -2607,6 +2703,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2607
2703
|
|
|
2608
2704
|
|
|
2609
2705
|
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2610
2709
|
|
|
2611
2710
|
|
|
2612
2711
|
|
|
@@ -2671,6 +2770,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2671
2770
|
|
|
2672
2771
|
|
|
2673
2772
|
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
|
|
2674
2776
|
|
|
2675
2777
|
|
|
2676
2778
|
|
|
@@ -2723,6 +2825,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2723
2825
|
|
|
2724
2826
|
|
|
2725
2827
|
|
|
2828
|
+
|
|
2829
|
+
|
|
2830
|
+
|
|
2726
2831
|
|
|
2727
2832
|
|
|
2728
2833
|
|
|
@@ -2784,6 +2889,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2784
2889
|
|
|
2785
2890
|
|
|
2786
2891
|
|
|
2892
|
+
|
|
2893
|
+
|
|
2894
|
+
|
|
2787
2895
|
|
|
2788
2896
|
|
|
2789
2897
|
|
|
@@ -2872,6 +2980,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2872
2980
|
|
|
2873
2981
|
|
|
2874
2982
|
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
|
|
2875
2986
|
|
|
2876
2987
|
|
|
2877
2988
|
|
|
@@ -2937,6 +3048,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2937
3048
|
|
|
2938
3049
|
|
|
2939
3050
|
|
|
3051
|
+
|
|
3052
|
+
|
|
3053
|
+
|
|
2940
3054
|
|
|
2941
3055
|
|
|
2942
3056
|
|
|
@@ -3418,6 +3532,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3418
3532
|
|
|
3419
3533
|
|
|
3420
3534
|
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
|
|
3421
3538
|
|
|
3422
3539
|
|
|
3423
3540
|
|
|
@@ -3474,6 +3591,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3474
3591
|
|
|
3475
3592
|
|
|
3476
3593
|
|
|
3594
|
+
|
|
3595
|
+
|
|
3596
|
+
|
|
3477
3597
|
|
|
3478
3598
|
|
|
3479
3599
|
|
|
@@ -3534,6 +3654,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3534
3654
|
|
|
3535
3655
|
|
|
3536
3656
|
|
|
3657
|
+
|
|
3658
|
+
|
|
3659
|
+
|
|
3537
3660
|
|
|
3538
3661
|
|
|
3539
3662
|
|
|
@@ -3619,6 +3742,9 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3619
3742
|
|
|
3620
3743
|
|
|
3621
3744
|
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3622
3748
|
|
|
3623
3749
|
|
|
3624
3750
|
|