red-black-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 +216 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +216 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +216 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +216 -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/red-black-tree-typed.js +216 -0
- package/dist/umd/red-black-tree-typed.js.map +1 -1
- package/dist/umd/red-black-tree-typed.min.js +2 -2
- package/dist/umd/red-black-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
|
|
|
@@ -4447,6 +4573,12 @@ var BST = class extends BinaryTree {
|
|
|
4447
4573
|
|
|
4448
4574
|
|
|
4449
4575
|
|
|
4576
|
+
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4580
|
+
|
|
4581
|
+
|
|
4450
4582
|
|
|
4451
4583
|
|
|
4452
4584
|
|
|
@@ -4792,6 +4924,15 @@ var BST = class extends BinaryTree {
|
|
|
4792
4924
|
|
|
4793
4925
|
|
|
4794
4926
|
|
|
4927
|
+
|
|
4928
|
+
|
|
4929
|
+
|
|
4930
|
+
|
|
4931
|
+
|
|
4932
|
+
|
|
4933
|
+
|
|
4934
|
+
|
|
4935
|
+
|
|
4795
4936
|
|
|
4796
4937
|
|
|
4797
4938
|
|
|
@@ -4918,6 +5059,12 @@ var BST = class extends BinaryTree {
|
|
|
4918
5059
|
|
|
4919
5060
|
|
|
4920
5061
|
|
|
5062
|
+
|
|
5063
|
+
|
|
5064
|
+
|
|
5065
|
+
|
|
5066
|
+
|
|
5067
|
+
|
|
4921
5068
|
|
|
4922
5069
|
|
|
4923
5070
|
|
|
@@ -5212,6 +5359,9 @@ var BST = class extends BinaryTree {
|
|
|
5212
5359
|
|
|
5213
5360
|
|
|
5214
5361
|
|
|
5362
|
+
|
|
5363
|
+
|
|
5364
|
+
|
|
5215
5365
|
|
|
5216
5366
|
|
|
5217
5367
|
|
|
@@ -5285,6 +5435,9 @@ var BST = class extends BinaryTree {
|
|
|
5285
5435
|
|
|
5286
5436
|
|
|
5287
5437
|
|
|
5438
|
+
|
|
5439
|
+
|
|
5440
|
+
|
|
5288
5441
|
|
|
5289
5442
|
|
|
5290
5443
|
|
|
@@ -5412,6 +5565,12 @@ var BST = class extends BinaryTree {
|
|
|
5412
5565
|
|
|
5413
5566
|
|
|
5414
5567
|
|
|
5568
|
+
|
|
5569
|
+
|
|
5570
|
+
|
|
5571
|
+
|
|
5572
|
+
|
|
5573
|
+
|
|
5415
5574
|
|
|
5416
5575
|
|
|
5417
5576
|
|
|
@@ -6342,6 +6501,18 @@ var RedBlackTree = class extends BST {
|
|
|
6342
6501
|
|
|
6343
6502
|
|
|
6344
6503
|
|
|
6504
|
+
|
|
6505
|
+
|
|
6506
|
+
|
|
6507
|
+
|
|
6508
|
+
|
|
6509
|
+
|
|
6510
|
+
|
|
6511
|
+
|
|
6512
|
+
|
|
6513
|
+
|
|
6514
|
+
|
|
6515
|
+
|
|
6345
6516
|
|
|
6346
6517
|
|
|
6347
6518
|
|
|
@@ -6833,6 +7004,18 @@ var RedBlackTree = class extends BST {
|
|
|
6833
7004
|
|
|
6834
7005
|
|
|
6835
7006
|
|
|
7007
|
+
|
|
7008
|
+
|
|
7009
|
+
|
|
7010
|
+
|
|
7011
|
+
|
|
7012
|
+
|
|
7013
|
+
|
|
7014
|
+
|
|
7015
|
+
|
|
7016
|
+
|
|
7017
|
+
|
|
7018
|
+
|
|
6836
7019
|
|
|
6837
7020
|
|
|
6838
7021
|
|
|
@@ -7048,6 +7231,18 @@ var RedBlackTree = class extends BST {
|
|
|
7048
7231
|
|
|
7049
7232
|
|
|
7050
7233
|
|
|
7234
|
+
|
|
7235
|
+
|
|
7236
|
+
|
|
7237
|
+
|
|
7238
|
+
|
|
7239
|
+
|
|
7240
|
+
|
|
7241
|
+
|
|
7242
|
+
|
|
7243
|
+
|
|
7244
|
+
|
|
7245
|
+
|
|
7051
7246
|
|
|
7052
7247
|
|
|
7053
7248
|
|
|
@@ -7246,6 +7441,15 @@ var RedBlackTree = class extends BST {
|
|
|
7246
7441
|
|
|
7247
7442
|
|
|
7248
7443
|
|
|
7444
|
+
|
|
7445
|
+
|
|
7446
|
+
|
|
7447
|
+
|
|
7448
|
+
|
|
7449
|
+
|
|
7450
|
+
|
|
7451
|
+
|
|
7452
|
+
|
|
7249
7453
|
|
|
7250
7454
|
|
|
7251
7455
|
|
|
@@ -7411,6 +7615,18 @@ var RedBlackTree = class extends BST {
|
|
|
7411
7615
|
|
|
7412
7616
|
|
|
7413
7617
|
|
|
7618
|
+
|
|
7619
|
+
|
|
7620
|
+
|
|
7621
|
+
|
|
7622
|
+
|
|
7623
|
+
|
|
7624
|
+
|
|
7625
|
+
|
|
7626
|
+
|
|
7627
|
+
|
|
7628
|
+
|
|
7629
|
+
|
|
7414
7630
|
|
|
7415
7631
|
|
|
7416
7632
|
|