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
|
@@ -27,6 +27,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
|
|
|
27
27
|
}, "arrayRemove");
|
|
28
28
|
|
|
29
29
|
// src/common/error.ts
|
|
30
|
+
function raise(ErrorClass, message) {
|
|
31
|
+
throw new ErrorClass(message);
|
|
32
|
+
}
|
|
33
|
+
__name(raise, "raise");
|
|
30
34
|
var ERR = {
|
|
31
35
|
// Range / index
|
|
32
36
|
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
@@ -48,7 +52,9 @@ var ERR = {
|
|
|
48
52
|
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
49
53
|
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
50
54
|
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
51
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
55
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
56
|
+
// Order statistic
|
|
57
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
// src/common/index.ts
|
|
@@ -277,7 +283,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
277
283
|
if (options) {
|
|
278
284
|
const { toElementFn } = options;
|
|
279
285
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
280
|
-
else if (toElementFn)
|
|
286
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
281
287
|
}
|
|
282
288
|
}
|
|
283
289
|
/**
|
|
@@ -433,7 +439,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
433
439
|
acc = initialValue;
|
|
434
440
|
} else {
|
|
435
441
|
const first = iter.next();
|
|
436
|
-
if (first.done)
|
|
442
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
437
443
|
acc = first.value;
|
|
438
444
|
index = 1;
|
|
439
445
|
}
|
|
@@ -684,7 +690,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
684
690
|
__publicField(this, "_elements", []);
|
|
685
691
|
__publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
|
|
686
692
|
if (typeof a === "object" || typeof b === "object") {
|
|
687
|
-
|
|
693
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
688
694
|
}
|
|
689
695
|
if (a > b) return 1;
|
|
690
696
|
if (a < b) return -1;
|
|
@@ -737,6 +743,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
737
743
|
|
|
738
744
|
|
|
739
745
|
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
740
749
|
|
|
741
750
|
|
|
742
751
|
|
|
@@ -821,6 +830,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
821
830
|
|
|
822
831
|
|
|
823
832
|
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
824
836
|
|
|
825
837
|
|
|
826
838
|
|
|
@@ -875,6 +887,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
875
887
|
|
|
876
888
|
|
|
877
889
|
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
878
893
|
|
|
879
894
|
|
|
880
895
|
|
|
@@ -931,6 +946,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
931
946
|
|
|
932
947
|
|
|
933
948
|
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
934
952
|
|
|
935
953
|
|
|
936
954
|
|
|
@@ -1003,6 +1021,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1003
1021
|
|
|
1004
1022
|
|
|
1005
1023
|
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1006
1027
|
|
|
1007
1028
|
|
|
1008
1029
|
|
|
@@ -1100,6 +1121,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1100
1121
|
|
|
1101
1122
|
|
|
1102
1123
|
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1103
1127
|
|
|
1104
1128
|
|
|
1105
1129
|
|
|
@@ -1144,6 +1168,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1144
1168
|
|
|
1145
1169
|
|
|
1146
1170
|
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1147
1174
|
|
|
1148
1175
|
|
|
1149
1176
|
|
|
@@ -1191,6 +1218,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1191
1218
|
|
|
1192
1219
|
|
|
1193
1220
|
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1194
1224
|
|
|
1195
1225
|
|
|
1196
1226
|
|
|
@@ -1235,6 +1265,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1235
1265
|
|
|
1236
1266
|
|
|
1237
1267
|
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1238
1271
|
|
|
1239
1272
|
|
|
1240
1273
|
|
|
@@ -1325,6 +1358,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1325
1358
|
|
|
1326
1359
|
|
|
1327
1360
|
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1328
1364
|
|
|
1329
1365
|
|
|
1330
1366
|
|
|
@@ -1402,6 +1438,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1402
1438
|
|
|
1403
1439
|
|
|
1404
1440
|
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1405
1444
|
|
|
1406
1445
|
|
|
1407
1446
|
|
|
@@ -1452,6 +1491,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1452
1491
|
|
|
1453
1492
|
|
|
1454
1493
|
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1455
1497
|
|
|
1456
1498
|
|
|
1457
1499
|
|
|
@@ -1501,6 +1543,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1501
1543
|
|
|
1502
1544
|
|
|
1503
1545
|
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1504
1549
|
|
|
1505
1550
|
|
|
1506
1551
|
|
|
@@ -1557,6 +1602,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1557
1602
|
|
|
1558
1603
|
|
|
1559
1604
|
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1560
1608
|
|
|
1561
1609
|
|
|
1562
1610
|
|
|
@@ -1569,7 +1617,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1569
1617
|
*/
|
|
1570
1618
|
map(callback, options, thisArg) {
|
|
1571
1619
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1572
|
-
if (!comparator)
|
|
1620
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1573
1621
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1574
1622
|
let i = 0;
|
|
1575
1623
|
for (const x of this) {
|
|
@@ -1757,6 +1805,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1757
1805
|
|
|
1758
1806
|
|
|
1759
1807
|
|
|
1808
|
+
|
|
1809
|
+
|
|
1810
|
+
|
|
1760
1811
|
|
|
1761
1812
|
|
|
1762
1813
|
|
|
@@ -1804,6 +1855,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1804
1855
|
|
|
1805
1856
|
|
|
1806
1857
|
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1807
1861
|
|
|
1808
1862
|
|
|
1809
1863
|
|
|
@@ -1867,6 +1921,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1867
1921
|
|
|
1868
1922
|
|
|
1869
1923
|
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1870
1927
|
|
|
1871
1928
|
|
|
1872
1929
|
|
|
@@ -1926,6 +1983,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1926
1983
|
|
|
1927
1984
|
|
|
1928
1985
|
|
|
1986
|
+
|
|
1987
|
+
|
|
1988
|
+
|
|
1929
1989
|
|
|
1930
1990
|
|
|
1931
1991
|
|
|
@@ -1992,6 +2052,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1992
2052
|
|
|
1993
2053
|
|
|
1994
2054
|
|
|
2055
|
+
|
|
2056
|
+
|
|
2057
|
+
|
|
1995
2058
|
|
|
1996
2059
|
|
|
1997
2060
|
|
|
@@ -2048,6 +2111,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2048
2111
|
|
|
2049
2112
|
|
|
2050
2113
|
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2051
2117
|
|
|
2052
2118
|
|
|
2053
2119
|
|
|
@@ -2097,6 +2163,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2097
2163
|
|
|
2098
2164
|
|
|
2099
2165
|
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2100
2169
|
|
|
2101
2170
|
|
|
2102
2171
|
|
|
@@ -2187,6 +2256,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2187
2256
|
|
|
2188
2257
|
|
|
2189
2258
|
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2190
2262
|
|
|
2191
2263
|
|
|
2192
2264
|
|
|
@@ -2230,6 +2302,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2230
2302
|
|
|
2231
2303
|
|
|
2232
2304
|
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2233
2308
|
|
|
2234
2309
|
|
|
2235
2310
|
|
|
@@ -2296,6 +2371,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2296
2371
|
|
|
2297
2372
|
|
|
2298
2373
|
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2299
2377
|
|
|
2300
2378
|
|
|
2301
2379
|
|
|
@@ -2346,6 +2424,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2346
2424
|
|
|
2347
2425
|
|
|
2348
2426
|
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2349
2430
|
|
|
2350
2431
|
|
|
2351
2432
|
|
|
@@ -2400,6 +2481,9 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
2400
2481
|
|
|
2401
2482
|
|
|
2402
2483
|
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2403
2487
|
|
|
2404
2488
|
|
|
2405
2489
|
|
|
@@ -2638,7 +2722,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2638
2722
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2639
2723
|
return this._addEdge(newEdge);
|
|
2640
2724
|
} else {
|
|
2641
|
-
|
|
2725
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2642
2726
|
}
|
|
2643
2727
|
}
|
|
2644
2728
|
}
|
|
@@ -3539,6 +3623,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3539
3623
|
|
|
3540
3624
|
|
|
3541
3625
|
|
|
3626
|
+
|
|
3627
|
+
|
|
3628
|
+
|
|
3542
3629
|
|
|
3543
3630
|
|
|
3544
3631
|
|
|
@@ -3624,6 +3711,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3624
3711
|
|
|
3625
3712
|
|
|
3626
3713
|
|
|
3714
|
+
|
|
3715
|
+
|
|
3716
|
+
|
|
3627
3717
|
|
|
3628
3718
|
|
|
3629
3719
|
|
|
@@ -3707,6 +3797,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3707
3797
|
|
|
3708
3798
|
|
|
3709
3799
|
|
|
3800
|
+
|
|
3801
|
+
|
|
3802
|
+
|
|
3710
3803
|
|
|
3711
3804
|
|
|
3712
3805
|
|
|
@@ -3781,6 +3874,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3781
3874
|
|
|
3782
3875
|
|
|
3783
3876
|
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3784
3880
|
|
|
3785
3881
|
|
|
3786
3882
|
|
|
@@ -3832,6 +3928,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3832
3928
|
|
|
3833
3929
|
|
|
3834
3930
|
|
|
3931
|
+
|
|
3932
|
+
|
|
3933
|
+
|
|
3835
3934
|
|
|
3836
3935
|
|
|
3837
3936
|
|
|
@@ -3936,6 +4035,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3936
4035
|
|
|
3937
4036
|
|
|
3938
4037
|
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
3939
4041
|
|
|
3940
4042
|
|
|
3941
4043
|
|
|
@@ -4021,6 +4123,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4021
4123
|
|
|
4022
4124
|
|
|
4023
4125
|
|
|
4126
|
+
|
|
4127
|
+
|
|
4128
|
+
|
|
4024
4129
|
|
|
4025
4130
|
|
|
4026
4131
|
|
|
@@ -4068,6 +4173,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4068
4173
|
|
|
4069
4174
|
|
|
4070
4175
|
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4071
4179
|
|
|
4072
4180
|
|
|
4073
4181
|
|
|
@@ -4168,6 +4276,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4168
4276
|
|
|
4169
4277
|
|
|
4170
4278
|
|
|
4279
|
+
|
|
4280
|
+
|
|
4281
|
+
|
|
4171
4282
|
|
|
4172
4283
|
|
|
4173
4284
|
|
|
@@ -4271,6 +4382,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4271
4382
|
|
|
4272
4383
|
|
|
4273
4384
|
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4274
4388
|
|
|
4275
4389
|
|
|
4276
4390
|
|
|
@@ -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
|