directed-graph-typed 2.5.1 → 2.5.2
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 +121 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +121 -6
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +121 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +121 -7
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- 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 +77 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -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 +409 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -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 +51 -0
- 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 +45 -0
- 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/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/directed-graph-typed.js +121 -7
- package/dist/umd/directed-graph-typed.js.map +1 -1
- package/dist/umd/directed-graph-typed.min.js +2 -2
- package/dist/umd/directed-graph-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- 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 +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- 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 +38 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -25,6 +25,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
|
|
|
25
25
|
}, "arrayRemove");
|
|
26
26
|
|
|
27
27
|
// src/common/error.ts
|
|
28
|
+
function raise(ErrorClass, message) {
|
|
29
|
+
throw new ErrorClass(message);
|
|
30
|
+
}
|
|
31
|
+
__name(raise, "raise");
|
|
28
32
|
var ERR = {
|
|
29
33
|
// Range / index
|
|
30
34
|
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
@@ -46,7 +50,9 @@ var ERR = {
|
|
|
46
50
|
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
47
51
|
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
48
52
|
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
49
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
53
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
54
|
+
// Order statistic
|
|
55
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
// src/common/index.ts
|
|
@@ -273,7 +279,7 @@ var IterableElementBase = class {
|
|
|
273
279
|
if (options) {
|
|
274
280
|
const { toElementFn } = options;
|
|
275
281
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
276
|
-
else if (toElementFn)
|
|
282
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
277
283
|
}
|
|
278
284
|
}
|
|
279
285
|
/**
|
|
@@ -436,7 +442,7 @@ var IterableElementBase = class {
|
|
|
436
442
|
acc = initialValue;
|
|
437
443
|
} else {
|
|
438
444
|
const first = iter.next();
|
|
439
|
-
if (first.done)
|
|
445
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
440
446
|
acc = first.value;
|
|
441
447
|
index = 1;
|
|
442
448
|
}
|
|
@@ -733,6 +739,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
733
739
|
|
|
734
740
|
|
|
735
741
|
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
736
745
|
|
|
737
746
|
|
|
738
747
|
|
|
@@ -816,6 +825,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
816
825
|
|
|
817
826
|
|
|
818
827
|
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
819
831
|
|
|
820
832
|
|
|
821
833
|
|
|
@@ -870,6 +882,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
870
882
|
|
|
871
883
|
|
|
872
884
|
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
873
888
|
|
|
874
889
|
|
|
875
890
|
|
|
@@ -926,6 +941,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
926
941
|
|
|
927
942
|
|
|
928
943
|
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
929
947
|
|
|
930
948
|
|
|
931
949
|
|
|
@@ -998,6 +1016,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
998
1016
|
|
|
999
1017
|
|
|
1000
1018
|
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1001
1022
|
|
|
1002
1023
|
|
|
1003
1024
|
|
|
@@ -1095,6 +1116,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1095
1116
|
|
|
1096
1117
|
|
|
1097
1118
|
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1098
1122
|
|
|
1099
1123
|
|
|
1100
1124
|
|
|
@@ -1139,6 +1163,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1139
1163
|
|
|
1140
1164
|
|
|
1141
1165
|
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1142
1169
|
|
|
1143
1170
|
|
|
1144
1171
|
|
|
@@ -1186,6 +1213,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1186
1213
|
|
|
1187
1214
|
|
|
1188
1215
|
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1189
1219
|
|
|
1190
1220
|
|
|
1191
1221
|
|
|
@@ -1230,6 +1260,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1230
1260
|
|
|
1231
1261
|
|
|
1232
1262
|
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1233
1266
|
|
|
1234
1267
|
|
|
1235
1268
|
|
|
@@ -1320,6 +1353,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1320
1353
|
|
|
1321
1354
|
|
|
1322
1355
|
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1323
1359
|
|
|
1324
1360
|
|
|
1325
1361
|
|
|
@@ -1397,6 +1433,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1397
1433
|
|
|
1398
1434
|
|
|
1399
1435
|
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1400
1439
|
|
|
1401
1440
|
|
|
1402
1441
|
|
|
@@ -1447,6 +1486,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1447
1486
|
|
|
1448
1487
|
|
|
1449
1488
|
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1450
1492
|
|
|
1451
1493
|
|
|
1452
1494
|
|
|
@@ -1496,6 +1538,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1496
1538
|
|
|
1497
1539
|
|
|
1498
1540
|
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1499
1544
|
|
|
1500
1545
|
|
|
1501
1546
|
|
|
@@ -1552,6 +1597,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1552
1597
|
|
|
1553
1598
|
|
|
1554
1599
|
|
|
1600
|
+
|
|
1601
|
+
|
|
1602
|
+
|
|
1555
1603
|
|
|
1556
1604
|
|
|
1557
1605
|
|
|
@@ -1564,7 +1612,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1564
1612
|
*/
|
|
1565
1613
|
map(callback, options, thisArg) {
|
|
1566
1614
|
const { comparator, toElementFn, ...rest } = options ?? {};
|
|
1567
|
-
if (!comparator)
|
|
1615
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1568
1616
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1569
1617
|
let i = 0;
|
|
1570
1618
|
for (const x of this) {
|
|
@@ -1591,7 +1639,7 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1591
1639
|
}
|
|
1592
1640
|
_DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
|
|
1593
1641
|
if (typeof a === "object" || typeof b === "object") {
|
|
1594
|
-
|
|
1642
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
1595
1643
|
}
|
|
1596
1644
|
if (a > b) return 1;
|
|
1597
1645
|
if (a < b) return -1;
|
|
@@ -1762,6 +1810,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1762
1810
|
|
|
1763
1811
|
|
|
1764
1812
|
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
|
|
1765
1816
|
|
|
1766
1817
|
|
|
1767
1818
|
|
|
@@ -1809,6 +1860,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1809
1860
|
|
|
1810
1861
|
|
|
1811
1862
|
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1812
1866
|
|
|
1813
1867
|
|
|
1814
1868
|
|
|
@@ -1872,6 +1926,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1872
1926
|
|
|
1873
1927
|
|
|
1874
1928
|
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1875
1932
|
|
|
1876
1933
|
|
|
1877
1934
|
|
|
@@ -1931,6 +1988,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1931
1988
|
|
|
1932
1989
|
|
|
1933
1990
|
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
|
|
1934
1994
|
|
|
1935
1995
|
|
|
1936
1996
|
|
|
@@ -1997,6 +2057,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1997
2057
|
|
|
1998
2058
|
|
|
1999
2059
|
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
|
|
2000
2063
|
|
|
2001
2064
|
|
|
2002
2065
|
|
|
@@ -2053,6 +2116,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2053
2116
|
|
|
2054
2117
|
|
|
2055
2118
|
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2056
2122
|
|
|
2057
2123
|
|
|
2058
2124
|
|
|
@@ -2102,6 +2168,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2102
2168
|
|
|
2103
2169
|
|
|
2104
2170
|
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
2105
2174
|
|
|
2106
2175
|
|
|
2107
2176
|
|
|
@@ -2192,6 +2261,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2192
2261
|
|
|
2193
2262
|
|
|
2194
2263
|
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
2195
2267
|
|
|
2196
2268
|
|
|
2197
2269
|
|
|
@@ -2235,6 +2307,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2235
2307
|
|
|
2236
2308
|
|
|
2237
2309
|
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
|
|
2238
2313
|
|
|
2239
2314
|
|
|
2240
2315
|
|
|
@@ -2301,6 +2376,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2301
2376
|
|
|
2302
2377
|
|
|
2303
2378
|
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2304
2382
|
|
|
2305
2383
|
|
|
2306
2384
|
|
|
@@ -2351,6 +2429,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2351
2429
|
|
|
2352
2430
|
|
|
2353
2431
|
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2354
2435
|
|
|
2355
2436
|
|
|
2356
2437
|
|
|
@@ -2405,6 +2486,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2405
2486
|
|
|
2406
2487
|
|
|
2407
2488
|
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
|
|
2408
2492
|
|
|
2409
2493
|
|
|
2410
2494
|
|
|
@@ -2644,7 +2728,7 @@ var AbstractGraph = class extends IterableEntryBase {
|
|
|
2644
2728
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2645
2729
|
return this._addEdge(newEdge);
|
|
2646
2730
|
} else {
|
|
2647
|
-
|
|
2731
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2648
2732
|
}
|
|
2649
2733
|
}
|
|
2650
2734
|
}
|
|
@@ -3541,6 +3625,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3541
3625
|
|
|
3542
3626
|
|
|
3543
3627
|
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3544
3631
|
|
|
3545
3632
|
|
|
3546
3633
|
|
|
@@ -3626,6 +3713,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3626
3713
|
|
|
3627
3714
|
|
|
3628
3715
|
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
|
|
3629
3719
|
|
|
3630
3720
|
|
|
3631
3721
|
|
|
@@ -3709,6 +3799,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3709
3799
|
|
|
3710
3800
|
|
|
3711
3801
|
|
|
3802
|
+
|
|
3803
|
+
|
|
3804
|
+
|
|
3712
3805
|
|
|
3713
3806
|
|
|
3714
3807
|
|
|
@@ -3783,6 +3876,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3783
3876
|
|
|
3784
3877
|
|
|
3785
3878
|
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3786
3882
|
|
|
3787
3883
|
|
|
3788
3884
|
|
|
@@ -3834,6 +3930,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3834
3930
|
|
|
3835
3931
|
|
|
3836
3932
|
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
|
|
3837
3936
|
|
|
3838
3937
|
|
|
3839
3938
|
|
|
@@ -3938,6 +4037,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3938
4037
|
|
|
3939
4038
|
|
|
3940
4039
|
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
3941
4043
|
|
|
3942
4044
|
|
|
3943
4045
|
|
|
@@ -4023,6 +4125,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4023
4125
|
|
|
4024
4126
|
|
|
4025
4127
|
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
|
|
4026
4131
|
|
|
4027
4132
|
|
|
4028
4133
|
|
|
@@ -4070,6 +4175,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4070
4175
|
|
|
4071
4176
|
|
|
4072
4177
|
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4073
4181
|
|
|
4074
4182
|
|
|
4075
4183
|
|
|
@@ -4170,6 +4278,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4170
4278
|
|
|
4171
4279
|
|
|
4172
4280
|
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4173
4284
|
|
|
4174
4285
|
|
|
4175
4286
|
|
|
@@ -4273,6 +4384,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4273
4384
|
|
|
4274
4385
|
|
|
4275
4386
|
|
|
4387
|
+
|
|
4388
|
+
|
|
4389
|
+
|
|
4276
4390
|
|
|
4277
4391
|
|
|
4278
4392
|
|
|
@@ -4340,5 +4454,6 @@ exports.DirectedGraph = DirectedGraph;
|
|
|
4340
4454
|
exports.DirectedVertex = DirectedVertex;
|
|
4341
4455
|
exports.ERR = ERR;
|
|
4342
4456
|
exports.Range = Range;
|
|
4457
|
+
exports.raise = raise;
|
|
4343
4458
|
//# sourceMappingURL=index.cjs.map
|
|
4344
4459
|
//# sourceMappingURL=index.cjs.map
|