directed-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 +147 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +147 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +147 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +147 -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/directed-graph-typed.js +147 -0
- package/dist/umd/directed-graph-typed.js.map +1 -1
- package/dist/umd/directed-graph-typed.min.js +1 -1
- package/dist/umd/directed-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
|
@@ -408,6 +408,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
408
408
|
for (const ele of this) if (ele === element) return true;
|
|
409
409
|
return false;
|
|
410
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
413
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
414
|
+
* @param element - Element to search for (uses `===`).
|
|
415
|
+
* @returns `true` if found.
|
|
416
|
+
*/
|
|
417
|
+
includes(element) {
|
|
418
|
+
return this.has(element);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
422
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
423
|
+
*/
|
|
424
|
+
*entries() {
|
|
425
|
+
let index = 0;
|
|
426
|
+
for (const value of this) {
|
|
427
|
+
yield [index++, value];
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
432
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
433
|
+
*/
|
|
434
|
+
*keys() {
|
|
435
|
+
let index = 0;
|
|
436
|
+
for (const _ of this) {
|
|
437
|
+
yield index++;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
411
440
|
/**
|
|
412
441
|
* Reduces all elements to a single accumulated value.
|
|
413
442
|
*
|
|
@@ -669,6 +698,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
669
698
|
}
|
|
670
699
|
return this;
|
|
671
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
703
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
704
|
+
* @returns A new reversed instance.
|
|
705
|
+
*/
|
|
706
|
+
toReversed() {
|
|
707
|
+
const cloned = this.clone();
|
|
708
|
+
cloned.reverse();
|
|
709
|
+
return cloned;
|
|
710
|
+
}
|
|
672
711
|
};
|
|
673
712
|
__name(_LinearBase, "LinearBase");
|
|
674
713
|
var LinearBase = _LinearBase;
|
|
@@ -748,6 +787,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
748
787
|
|
|
749
788
|
|
|
750
789
|
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
751
793
|
|
|
752
794
|
|
|
753
795
|
|
|
@@ -839,6 +881,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
839
881
|
|
|
840
882
|
|
|
841
883
|
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
842
887
|
|
|
843
888
|
|
|
844
889
|
|
|
@@ -900,6 +945,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
900
945
|
|
|
901
946
|
|
|
902
947
|
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
903
951
|
|
|
904
952
|
|
|
905
953
|
|
|
@@ -994,6 +1042,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
994
1042
|
*/
|
|
995
1043
|
/**
|
|
996
1044
|
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
997
1048
|
* @example
|
|
998
1049
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
999
1050
|
* interface Task {
|
|
@@ -1077,6 +1128,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1077
1128
|
|
|
1078
1129
|
|
|
1079
1130
|
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1080
1134
|
|
|
1081
1135
|
|
|
1082
1136
|
|
|
@@ -1181,6 +1235,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1181
1235
|
|
|
1182
1236
|
|
|
1183
1237
|
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1184
1241
|
|
|
1185
1242
|
|
|
1186
1243
|
|
|
@@ -1232,6 +1289,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1232
1289
|
|
|
1233
1290
|
|
|
1234
1291
|
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1235
1295
|
|
|
1236
1296
|
|
|
1237
1297
|
|
|
@@ -1276,6 +1336,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1276
1336
|
|
|
1277
1337
|
|
|
1278
1338
|
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1279
1342
|
|
|
1280
1343
|
|
|
1281
1344
|
|
|
@@ -1327,6 +1390,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1327
1390
|
|
|
1328
1391
|
|
|
1329
1392
|
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
|
|
1330
1396
|
|
|
1331
1397
|
|
|
1332
1398
|
|
|
@@ -1430,6 +1496,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1430
1496
|
|
|
1431
1497
|
|
|
1432
1498
|
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1433
1502
|
|
|
1434
1503
|
|
|
1435
1504
|
|
|
@@ -1514,6 +1583,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1514
1583
|
|
|
1515
1584
|
|
|
1516
1585
|
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1517
1589
|
|
|
1518
1590
|
|
|
1519
1591
|
|
|
@@ -1571,6 +1643,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1571
1643
|
|
|
1572
1644
|
|
|
1573
1645
|
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1574
1649
|
|
|
1575
1650
|
|
|
1576
1651
|
|
|
@@ -1627,6 +1702,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1627
1702
|
|
|
1628
1703
|
|
|
1629
1704
|
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
|
|
1630
1708
|
|
|
1631
1709
|
|
|
1632
1710
|
|
|
@@ -1690,6 +1768,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1690
1768
|
|
|
1691
1769
|
|
|
1692
1770
|
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1693
1774
|
|
|
1694
1775
|
|
|
1695
1776
|
|
|
@@ -1897,6 +1978,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1897
1978
|
|
|
1898
1979
|
|
|
1899
1980
|
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1900
1984
|
|
|
1901
1985
|
|
|
1902
1986
|
|
|
@@ -1951,6 +2035,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1951
2035
|
|
|
1952
2036
|
|
|
1953
2037
|
|
|
2038
|
+
|
|
2039
|
+
|
|
2040
|
+
|
|
1954
2041
|
|
|
1955
2042
|
|
|
1956
2043
|
|
|
@@ -2029,6 +2116,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2029
2116
|
|
|
2030
2117
|
|
|
2031
2118
|
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2032
2122
|
|
|
2033
2123
|
|
|
2034
2124
|
|
|
@@ -2095,6 +2185,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2095
2185
|
|
|
2096
2186
|
|
|
2097
2187
|
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2098
2191
|
|
|
2099
2192
|
|
|
2100
2193
|
|
|
@@ -2168,6 +2261,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2168
2261
|
|
|
2169
2262
|
|
|
2170
2263
|
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
2171
2267
|
|
|
2172
2268
|
|
|
2173
2269
|
|
|
@@ -2231,6 +2327,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2231
2327
|
|
|
2232
2328
|
|
|
2233
2329
|
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2234
2333
|
|
|
2235
2334
|
|
|
2236
2335
|
|
|
@@ -2287,6 +2386,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2287
2386
|
|
|
2288
2387
|
|
|
2289
2388
|
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
|
|
2290
2392
|
|
|
2291
2393
|
|
|
2292
2394
|
|
|
@@ -2399,6 +2501,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2399
2501
|
|
|
2400
2502
|
|
|
2401
2503
|
|
|
2504
|
+
|
|
2505
|
+
|
|
2506
|
+
|
|
2402
2507
|
|
|
2403
2508
|
|
|
2404
2509
|
|
|
@@ -2449,6 +2554,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2449
2554
|
|
|
2450
2555
|
|
|
2451
2556
|
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2452
2560
|
|
|
2453
2561
|
|
|
2454
2562
|
|
|
@@ -2522,6 +2630,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2522
2630
|
|
|
2523
2631
|
|
|
2524
2632
|
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
|
|
2525
2636
|
|
|
2526
2637
|
|
|
2527
2638
|
|
|
@@ -2579,6 +2690,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2579
2690
|
|
|
2580
2691
|
|
|
2581
2692
|
|
|
2693
|
+
|
|
2694
|
+
|
|
2695
|
+
|
|
2582
2696
|
|
|
2583
2697
|
|
|
2584
2698
|
|
|
@@ -2640,6 +2754,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2640
2754
|
|
|
2641
2755
|
|
|
2642
2756
|
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
|
|
2643
2760
|
|
|
2644
2761
|
|
|
2645
2762
|
|
|
@@ -3786,6 +3903,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3786
3903
|
|
|
3787
3904
|
|
|
3788
3905
|
|
|
3906
|
+
|
|
3907
|
+
|
|
3908
|
+
|
|
3789
3909
|
|
|
3790
3910
|
|
|
3791
3911
|
|
|
@@ -3878,6 +3998,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3878
3998
|
|
|
3879
3999
|
|
|
3880
4000
|
|
|
4001
|
+
|
|
4002
|
+
|
|
4003
|
+
|
|
3881
4004
|
|
|
3882
4005
|
|
|
3883
4006
|
|
|
@@ -3968,6 +4091,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3968
4091
|
|
|
3969
4092
|
|
|
3970
4093
|
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
3971
4097
|
|
|
3972
4098
|
|
|
3973
4099
|
|
|
@@ -4049,6 +4175,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4049
4175
|
|
|
4050
4176
|
|
|
4051
4177
|
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4052
4181
|
|
|
4053
4182
|
|
|
4054
4183
|
|
|
@@ -4107,6 +4236,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4107
4236
|
|
|
4108
4237
|
|
|
4109
4238
|
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4110
4242
|
|
|
4111
4243
|
|
|
4112
4244
|
|
|
@@ -4218,6 +4350,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4218
4350
|
|
|
4219
4351
|
|
|
4220
4352
|
|
|
4353
|
+
|
|
4354
|
+
|
|
4355
|
+
|
|
4221
4356
|
|
|
4222
4357
|
|
|
4223
4358
|
|
|
@@ -4310,6 +4445,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4310
4445
|
|
|
4311
4446
|
|
|
4312
4447
|
|
|
4448
|
+
|
|
4449
|
+
|
|
4450
|
+
|
|
4313
4451
|
|
|
4314
4452
|
|
|
4315
4453
|
|
|
@@ -4364,6 +4502,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4364
4502
|
|
|
4365
4503
|
|
|
4366
4504
|
|
|
4505
|
+
|
|
4506
|
+
|
|
4507
|
+
|
|
4367
4508
|
|
|
4368
4509
|
|
|
4369
4510
|
|
|
@@ -4471,6 +4612,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4471
4612
|
|
|
4472
4613
|
|
|
4473
4614
|
|
|
4615
|
+
|
|
4616
|
+
|
|
4617
|
+
|
|
4474
4618
|
|
|
4475
4619
|
|
|
4476
4620
|
|
|
@@ -4581,6 +4725,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4581
4725
|
|
|
4582
4726
|
|
|
4583
4727
|
|
|
4728
|
+
|
|
4729
|
+
|
|
4730
|
+
|
|
4584
4731
|
|
|
4585
4732
|
|
|
4586
4733
|
|