graph-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 +174 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +174 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +174 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +174 -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/graph-typed.js +174 -0
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +1 -1
- package/dist/umd/graph-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
|
@@ -410,6 +410,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
410
410
|
for (const ele of this) if (ele === element) return true;
|
|
411
411
|
return false;
|
|
412
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
415
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
416
|
+
* @param element - Element to search for (uses `===`).
|
|
417
|
+
* @returns `true` if found.
|
|
418
|
+
*/
|
|
419
|
+
includes(element) {
|
|
420
|
+
return this.has(element);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
424
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
425
|
+
*/
|
|
426
|
+
*entries() {
|
|
427
|
+
let index = 0;
|
|
428
|
+
for (const value of this) {
|
|
429
|
+
yield [index++, value];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
434
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
435
|
+
*/
|
|
436
|
+
*keys() {
|
|
437
|
+
let index = 0;
|
|
438
|
+
for (const _ of this) {
|
|
439
|
+
yield index++;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
413
442
|
/**
|
|
414
443
|
* Reduces all elements to a single accumulated value.
|
|
415
444
|
*
|
|
@@ -671,6 +700,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
671
700
|
}
|
|
672
701
|
return this;
|
|
673
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
705
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
706
|
+
* @returns A new reversed instance.
|
|
707
|
+
*/
|
|
708
|
+
toReversed() {
|
|
709
|
+
const cloned = this.clone();
|
|
710
|
+
cloned.reverse();
|
|
711
|
+
return cloned;
|
|
712
|
+
}
|
|
674
713
|
};
|
|
675
714
|
__name(_LinearBase, "LinearBase");
|
|
676
715
|
var LinearBase = _LinearBase;
|
|
@@ -750,6 +789,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
750
789
|
|
|
751
790
|
|
|
752
791
|
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
753
795
|
|
|
754
796
|
|
|
755
797
|
|
|
@@ -841,6 +883,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
841
883
|
|
|
842
884
|
|
|
843
885
|
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
844
889
|
|
|
845
890
|
|
|
846
891
|
|
|
@@ -902,6 +947,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
902
947
|
|
|
903
948
|
|
|
904
949
|
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
905
953
|
|
|
906
954
|
|
|
907
955
|
|
|
@@ -996,6 +1044,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
996
1044
|
*/
|
|
997
1045
|
/**
|
|
998
1046
|
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
999
1050
|
* @example
|
|
1000
1051
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
1001
1052
|
* interface Task {
|
|
@@ -1079,6 +1130,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1079
1130
|
|
|
1080
1131
|
|
|
1081
1132
|
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1082
1136
|
|
|
1083
1137
|
|
|
1084
1138
|
|
|
@@ -1183,6 +1237,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1183
1237
|
|
|
1184
1238
|
|
|
1185
1239
|
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1186
1243
|
|
|
1187
1244
|
|
|
1188
1245
|
|
|
@@ -1234,6 +1291,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1234
1291
|
|
|
1235
1292
|
|
|
1236
1293
|
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1237
1297
|
|
|
1238
1298
|
|
|
1239
1299
|
|
|
@@ -1278,6 +1338,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1278
1338
|
|
|
1279
1339
|
|
|
1280
1340
|
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1281
1344
|
|
|
1282
1345
|
|
|
1283
1346
|
|
|
@@ -1329,6 +1392,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1329
1392
|
|
|
1330
1393
|
|
|
1331
1394
|
|
|
1395
|
+
|
|
1396
|
+
|
|
1397
|
+
|
|
1332
1398
|
|
|
1333
1399
|
|
|
1334
1400
|
|
|
@@ -1432,6 +1498,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1432
1498
|
|
|
1433
1499
|
|
|
1434
1500
|
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1435
1504
|
|
|
1436
1505
|
|
|
1437
1506
|
|
|
@@ -1516,6 +1585,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1516
1585
|
|
|
1517
1586
|
|
|
1518
1587
|
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1519
1591
|
|
|
1520
1592
|
|
|
1521
1593
|
|
|
@@ -1573,6 +1645,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1573
1645
|
|
|
1574
1646
|
|
|
1575
1647
|
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1576
1651
|
|
|
1577
1652
|
|
|
1578
1653
|
|
|
@@ -1629,6 +1704,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1629
1704
|
|
|
1630
1705
|
|
|
1631
1706
|
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1632
1710
|
|
|
1633
1711
|
|
|
1634
1712
|
|
|
@@ -1692,6 +1770,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1692
1770
|
|
|
1693
1771
|
|
|
1694
1772
|
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1695
1776
|
|
|
1696
1777
|
|
|
1697
1778
|
|
|
@@ -1899,6 +1980,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1899
1980
|
|
|
1900
1981
|
|
|
1901
1982
|
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1902
1986
|
|
|
1903
1987
|
|
|
1904
1988
|
|
|
@@ -1953,6 +2037,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1953
2037
|
|
|
1954
2038
|
|
|
1955
2039
|
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
1956
2043
|
|
|
1957
2044
|
|
|
1958
2045
|
|
|
@@ -2031,6 +2118,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2031
2118
|
|
|
2032
2119
|
|
|
2033
2120
|
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2034
2124
|
|
|
2035
2125
|
|
|
2036
2126
|
|
|
@@ -2097,6 +2187,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2097
2187
|
|
|
2098
2188
|
|
|
2099
2189
|
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
|
|
2100
2193
|
|
|
2101
2194
|
|
|
2102
2195
|
|
|
@@ -2170,6 +2263,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2170
2263
|
|
|
2171
2264
|
|
|
2172
2265
|
|
|
2266
|
+
|
|
2267
|
+
|
|
2268
|
+
|
|
2173
2269
|
|
|
2174
2270
|
|
|
2175
2271
|
|
|
@@ -2233,6 +2329,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2233
2329
|
|
|
2234
2330
|
|
|
2235
2331
|
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2236
2335
|
|
|
2237
2336
|
|
|
2238
2337
|
|
|
@@ -2289,6 +2388,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2289
2388
|
|
|
2290
2389
|
|
|
2291
2390
|
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
2292
2394
|
|
|
2293
2395
|
|
|
2294
2396
|
|
|
@@ -2401,6 +2503,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2401
2503
|
|
|
2402
2504
|
|
|
2403
2505
|
|
|
2506
|
+
|
|
2507
|
+
|
|
2508
|
+
|
|
2404
2509
|
|
|
2405
2510
|
|
|
2406
2511
|
|
|
@@ -2451,6 +2556,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2451
2556
|
|
|
2452
2557
|
|
|
2453
2558
|
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
|
|
2454
2562
|
|
|
2455
2563
|
|
|
2456
2564
|
|
|
@@ -2524,6 +2632,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2524
2632
|
|
|
2525
2633
|
|
|
2526
2634
|
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2527
2638
|
|
|
2528
2639
|
|
|
2529
2640
|
|
|
@@ -2581,6 +2692,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2581
2692
|
|
|
2582
2693
|
|
|
2583
2694
|
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
|
|
2584
2698
|
|
|
2585
2699
|
|
|
2586
2700
|
|
|
@@ -2642,6 +2756,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2642
2756
|
|
|
2643
2757
|
|
|
2644
2758
|
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
|
|
2645
2762
|
|
|
2646
2763
|
|
|
2647
2764
|
|
|
@@ -3788,6 +3905,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3788
3905
|
|
|
3789
3906
|
|
|
3790
3907
|
|
|
3908
|
+
|
|
3909
|
+
|
|
3910
|
+
|
|
3791
3911
|
|
|
3792
3912
|
|
|
3793
3913
|
|
|
@@ -3880,6 +4000,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3880
4000
|
|
|
3881
4001
|
|
|
3882
4002
|
|
|
4003
|
+
|
|
4004
|
+
|
|
4005
|
+
|
|
3883
4006
|
|
|
3884
4007
|
|
|
3885
4008
|
|
|
@@ -3970,6 +4093,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3970
4093
|
|
|
3971
4094
|
|
|
3972
4095
|
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
3973
4099
|
|
|
3974
4100
|
|
|
3975
4101
|
|
|
@@ -4051,6 +4177,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4051
4177
|
|
|
4052
4178
|
|
|
4053
4179
|
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4054
4183
|
|
|
4055
4184
|
|
|
4056
4185
|
|
|
@@ -4109,6 +4238,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4109
4238
|
|
|
4110
4239
|
|
|
4111
4240
|
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
|
|
4112
4244
|
|
|
4113
4245
|
|
|
4114
4246
|
|
|
@@ -4220,6 +4352,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4220
4352
|
|
|
4221
4353
|
|
|
4222
4354
|
|
|
4355
|
+
|
|
4356
|
+
|
|
4357
|
+
|
|
4223
4358
|
|
|
4224
4359
|
|
|
4225
4360
|
|
|
@@ -4312,6 +4447,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4312
4447
|
|
|
4313
4448
|
|
|
4314
4449
|
|
|
4450
|
+
|
|
4451
|
+
|
|
4452
|
+
|
|
4315
4453
|
|
|
4316
4454
|
|
|
4317
4455
|
|
|
@@ -4366,6 +4504,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4366
4504
|
|
|
4367
4505
|
|
|
4368
4506
|
|
|
4507
|
+
|
|
4508
|
+
|
|
4509
|
+
|
|
4369
4510
|
|
|
4370
4511
|
|
|
4371
4512
|
|
|
@@ -4473,6 +4614,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4473
4614
|
|
|
4474
4615
|
|
|
4475
4616
|
|
|
4617
|
+
|
|
4618
|
+
|
|
4619
|
+
|
|
4476
4620
|
|
|
4477
4621
|
|
|
4478
4622
|
|
|
@@ -4583,6 +4727,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4583
4727
|
|
|
4584
4728
|
|
|
4585
4729
|
|
|
4730
|
+
|
|
4731
|
+
|
|
4732
|
+
|
|
4586
4733
|
|
|
4587
4734
|
|
|
4588
4735
|
|
|
@@ -4757,6 +4904,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4757
4904
|
|
|
4758
4905
|
|
|
4759
4906
|
|
|
4907
|
+
|
|
4908
|
+
|
|
4909
|
+
|
|
4760
4910
|
|
|
4761
4911
|
|
|
4762
4912
|
|
|
@@ -4846,6 +4996,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4846
4996
|
|
|
4847
4997
|
|
|
4848
4998
|
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
|
|
4849
5002
|
|
|
4850
5003
|
|
|
4851
5004
|
|
|
@@ -4934,6 +5087,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4934
5087
|
|
|
4935
5088
|
|
|
4936
5089
|
|
|
5090
|
+
|
|
5091
|
+
|
|
5092
|
+
|
|
4937
5093
|
|
|
4938
5094
|
|
|
4939
5095
|
|
|
@@ -5037,6 +5193,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5037
5193
|
|
|
5038
5194
|
|
|
5039
5195
|
|
|
5196
|
+
|
|
5197
|
+
|
|
5198
|
+
|
|
5040
5199
|
|
|
5041
5200
|
|
|
5042
5201
|
|
|
@@ -5095,6 +5254,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5095
5254
|
|
|
5096
5255
|
|
|
5097
5256
|
|
|
5257
|
+
|
|
5258
|
+
|
|
5259
|
+
|
|
5098
5260
|
|
|
5099
5261
|
|
|
5100
5262
|
|
|
@@ -5223,6 +5385,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5223
5385
|
|
|
5224
5386
|
|
|
5225
5387
|
|
|
5388
|
+
|
|
5389
|
+
|
|
5390
|
+
|
|
5226
5391
|
|
|
5227
5392
|
|
|
5228
5393
|
|
|
@@ -5373,6 +5538,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5373
5538
|
|
|
5374
5539
|
|
|
5375
5540
|
|
|
5541
|
+
|
|
5542
|
+
|
|
5543
|
+
|
|
5376
5544
|
|
|
5377
5545
|
|
|
5378
5546
|
|
|
@@ -5445,6 +5613,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5445
5613
|
|
|
5446
5614
|
|
|
5447
5615
|
|
|
5616
|
+
|
|
5617
|
+
|
|
5618
|
+
|
|
5448
5619
|
|
|
5449
5620
|
|
|
5450
5621
|
|
|
@@ -5499,6 +5670,9 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5499
5670
|
|
|
5500
5671
|
|
|
5501
5672
|
|
|
5673
|
+
|
|
5674
|
+
|
|
5675
|
+
|
|
5502
5676
|
|
|
5503
5677
|
|
|
5504
5678
|
|