linked-list-typed 2.5.1 → 2.5.3
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 +431 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +430 -54
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +431 -56
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +430 -55
- 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 +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- 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/linked-list-typed.js +428 -53
- package/dist/umd/linked-list-typed.js.map +1 -1
- package/dist/umd/linked-list-typed.min.js +1 -1
- package/dist/umd/linked-list-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 +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- 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/esm/index.mjs
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/common/error.ts
|
|
5
|
+
function raise(ErrorClass, message) {
|
|
6
|
+
throw new ErrorClass(message);
|
|
7
|
+
}
|
|
8
|
+
__name(raise, "raise");
|
|
9
|
+
var ERR = {
|
|
10
|
+
// Range / index
|
|
11
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
12
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
13
|
+
// Type / argument
|
|
14
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
15
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
16
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
17
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
18
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
19
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
20
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
21
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
22
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
23
|
+
// State / operation
|
|
24
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
25
|
+
// Matrix
|
|
26
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
27
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
28
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
29
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
30
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
31
|
+
// Order statistic
|
|
32
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/common/index.ts
|
|
36
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
37
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
38
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
39
|
+
return DFSOperation2;
|
|
40
|
+
})(DFSOperation || {});
|
|
41
|
+
var Range = class {
|
|
42
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
43
|
+
this.low = low;
|
|
44
|
+
this.high = high;
|
|
45
|
+
this.includeLow = includeLow;
|
|
46
|
+
this.includeHigh = includeHigh;
|
|
47
|
+
}
|
|
48
|
+
static {
|
|
49
|
+
__name(this, "Range");
|
|
50
|
+
}
|
|
51
|
+
// Determine whether a key is within the range
|
|
52
|
+
isInRange(key, comparator) {
|
|
53
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
54
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
55
|
+
return lowCheck && highCheck;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
4
59
|
// src/data-structures/base/iterable-element-base.ts
|
|
5
60
|
var IterableElementBase = class {
|
|
6
61
|
static {
|
|
@@ -19,7 +74,7 @@ var IterableElementBase = class {
|
|
|
19
74
|
if (options) {
|
|
20
75
|
const { toElementFn } = options;
|
|
21
76
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
22
|
-
else if (toElementFn)
|
|
77
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
23
78
|
}
|
|
24
79
|
}
|
|
25
80
|
/**
|
|
@@ -182,7 +237,7 @@ var IterableElementBase = class {
|
|
|
182
237
|
acc = initialValue;
|
|
183
238
|
} else {
|
|
184
239
|
const first = iter.next();
|
|
185
|
-
if (first.done)
|
|
240
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
186
241
|
acc = first.value;
|
|
187
242
|
index = 1;
|
|
188
243
|
}
|
|
@@ -751,6 +806,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
751
806
|
|
|
752
807
|
|
|
753
808
|
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
754
816
|
|
|
755
817
|
|
|
756
818
|
|
|
@@ -815,6 +877,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
815
877
|
|
|
816
878
|
|
|
817
879
|
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
818
887
|
|
|
819
888
|
|
|
820
889
|
|
|
@@ -884,6 +953,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
884
953
|
|
|
885
954
|
|
|
886
955
|
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
887
963
|
|
|
888
964
|
|
|
889
965
|
|
|
@@ -935,6 +1011,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
935
1011
|
|
|
936
1012
|
|
|
937
1013
|
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
938
1021
|
|
|
939
1022
|
|
|
940
1023
|
|
|
@@ -1047,6 +1130,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1047
1130
|
|
|
1048
1131
|
|
|
1049
1132
|
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1050
1140
|
|
|
1051
1141
|
|
|
1052
1142
|
|
|
@@ -1103,6 +1193,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1103
1193
|
|
|
1104
1194
|
|
|
1105
1195
|
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1106
1203
|
|
|
1107
1204
|
|
|
1108
1205
|
|
|
@@ -1148,6 +1245,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1148
1245
|
|
|
1149
1246
|
|
|
1150
1247
|
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1151
1255
|
|
|
1152
1256
|
|
|
1153
1257
|
|
|
@@ -1199,6 +1303,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1199
1303
|
|
|
1200
1304
|
|
|
1201
1305
|
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
|
|
1202
1313
|
|
|
1203
1314
|
|
|
1204
1315
|
|
|
@@ -1255,6 +1366,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1255
1366
|
|
|
1256
1367
|
|
|
1257
1368
|
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1258
1376
|
|
|
1259
1377
|
|
|
1260
1378
|
|
|
@@ -1319,6 +1437,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1319
1437
|
|
|
1320
1438
|
|
|
1321
1439
|
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1322
1447
|
|
|
1323
1448
|
|
|
1324
1449
|
|
|
@@ -1360,6 +1485,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1360
1485
|
|
|
1361
1486
|
|
|
1362
1487
|
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
|
|
1363
1495
|
|
|
1364
1496
|
|
|
1365
1497
|
|
|
@@ -1407,6 +1539,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1407
1539
|
|
|
1408
1540
|
|
|
1409
1541
|
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1410
1549
|
|
|
1411
1550
|
|
|
1412
1551
|
|
|
@@ -1620,6 +1759,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1620
1759
|
|
|
1621
1760
|
|
|
1622
1761
|
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
|
|
1623
1769
|
|
|
1624
1770
|
|
|
1625
1771
|
|
|
@@ -1671,6 +1817,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1671
1817
|
|
|
1672
1818
|
|
|
1673
1819
|
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
|
|
1674
1827
|
|
|
1675
1828
|
|
|
1676
1829
|
|
|
@@ -1750,6 +1903,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1750
1903
|
|
|
1751
1904
|
|
|
1752
1905
|
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1753
1913
|
|
|
1754
1914
|
|
|
1755
1915
|
|
|
@@ -2067,6 +2227,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2067
2227
|
|
|
2068
2228
|
|
|
2069
2229
|
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2070
2237
|
|
|
2071
2238
|
|
|
2072
2239
|
|
|
@@ -2133,6 +2300,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2133
2300
|
|
|
2134
2301
|
|
|
2135
2302
|
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2136
2310
|
|
|
2137
2311
|
|
|
2138
2312
|
|
|
@@ -2198,6 +2372,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2198
2372
|
|
|
2199
2373
|
|
|
2200
2374
|
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2201
2382
|
|
|
2202
2383
|
|
|
2203
2384
|
|
|
@@ -2254,6 +2435,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2254
2435
|
|
|
2255
2436
|
|
|
2256
2437
|
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2257
2445
|
|
|
2258
2446
|
|
|
2259
2447
|
|
|
@@ -2339,6 +2527,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2339
2527
|
|
|
2340
2528
|
|
|
2341
2529
|
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2342
2537
|
|
|
2343
2538
|
|
|
2344
2539
|
|
|
@@ -2385,6 +2580,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2385
2580
|
|
|
2386
2581
|
|
|
2387
2582
|
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2388
2590
|
|
|
2389
2591
|
|
|
2390
2592
|
|
|
@@ -2462,6 +2664,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2462
2664
|
|
|
2463
2665
|
|
|
2464
2666
|
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2673
|
+
|
|
2465
2674
|
|
|
2466
2675
|
|
|
2467
2676
|
|
|
@@ -2567,6 +2776,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2567
2776
|
|
|
2568
2777
|
|
|
2569
2778
|
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2570
2786
|
|
|
2571
2787
|
|
|
2572
2788
|
|
|
@@ -2619,6 +2835,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2619
2835
|
|
|
2620
2836
|
|
|
2621
2837
|
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
|
|
2843
|
+
|
|
2844
|
+
|
|
2622
2845
|
|
|
2623
2846
|
|
|
2624
2847
|
|
|
@@ -2673,6 +2896,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2673
2896
|
|
|
2674
2897
|
|
|
2675
2898
|
|
|
2899
|
+
|
|
2900
|
+
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
|
|
2905
|
+
|
|
2676
2906
|
|
|
2677
2907
|
|
|
2678
2908
|
|
|
@@ -2714,6 +2944,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2714
2944
|
|
|
2715
2945
|
|
|
2716
2946
|
|
|
2947
|
+
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2717
2954
|
|
|
2718
2955
|
|
|
2719
2956
|
|
|
@@ -2759,6 +2996,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2759
2996
|
|
|
2760
2997
|
|
|
2761
2998
|
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
|
|
3005
|
+
|
|
2762
3006
|
|
|
2763
3007
|
|
|
2764
3008
|
|
|
@@ -2808,6 +3052,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2808
3052
|
|
|
2809
3053
|
|
|
2810
3054
|
|
|
3055
|
+
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
|
|
2811
3062
|
|
|
2812
3063
|
|
|
2813
3064
|
|
|
@@ -2860,6 +3111,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2860
3111
|
|
|
2861
3112
|
|
|
2862
3113
|
|
|
3114
|
+
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
|
|
3118
|
+
|
|
3119
|
+
|
|
3120
|
+
|
|
2863
3121
|
|
|
2864
3122
|
|
|
2865
3123
|
|
|
@@ -2884,6 +3142,25 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2884
3142
|
}
|
|
2885
3143
|
return this;
|
|
2886
3144
|
}
|
|
3145
|
+
/**
|
|
3146
|
+
* Delete the first element that satisfies a predicate.
|
|
3147
|
+
* @remarks Time O(N), Space O(1)
|
|
3148
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3149
|
+
* @returns True if a match was removed.
|
|
3150
|
+
*/
|
|
3151
|
+
deleteWhere(predicate) {
|
|
3152
|
+
let current = this.head;
|
|
3153
|
+
let index = 0;
|
|
3154
|
+
while (current) {
|
|
3155
|
+
if (predicate(current.value, index, this)) {
|
|
3156
|
+
this.delete(current);
|
|
3157
|
+
return true;
|
|
3158
|
+
}
|
|
3159
|
+
current = current.next;
|
|
3160
|
+
index++;
|
|
3161
|
+
}
|
|
3162
|
+
return false;
|
|
3163
|
+
}
|
|
2887
3164
|
/**
|
|
2888
3165
|
* Set the equality comparator used to compare values.
|
|
2889
3166
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2920,6 +3197,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2920
3197
|
|
|
2921
3198
|
|
|
2922
3199
|
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
2923
3207
|
|
|
2924
3208
|
|
|
2925
3209
|
|
|
@@ -2970,6 +3254,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2970
3254
|
|
|
2971
3255
|
|
|
2972
3256
|
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
2973
3264
|
|
|
2974
3265
|
|
|
2975
3266
|
|
|
@@ -3039,6 +3330,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3039
3330
|
|
|
3040
3331
|
|
|
3041
3332
|
|
|
3333
|
+
|
|
3334
|
+
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
|
|
3338
|
+
|
|
3339
|
+
|
|
3042
3340
|
|
|
3043
3341
|
|
|
3044
3342
|
|
|
@@ -3150,55 +3448,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3150
3448
|
}
|
|
3151
3449
|
};
|
|
3152
3450
|
|
|
3153
|
-
// src/common/error.ts
|
|
3154
|
-
var ERR = {
|
|
3155
|
-
// Range / index
|
|
3156
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
3157
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
3158
|
-
// Type / argument
|
|
3159
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
3160
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
3161
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
3162
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
3163
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
3164
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
3165
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
3166
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
3167
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
3168
|
-
// State / operation
|
|
3169
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
3170
|
-
// Matrix
|
|
3171
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
3172
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
3173
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
3174
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
3175
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
3176
|
-
};
|
|
3177
|
-
|
|
3178
|
-
// src/common/index.ts
|
|
3179
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
3180
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
3181
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
3182
|
-
return DFSOperation2;
|
|
3183
|
-
})(DFSOperation || {});
|
|
3184
|
-
var Range = class {
|
|
3185
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
3186
|
-
this.low = low;
|
|
3187
|
-
this.high = high;
|
|
3188
|
-
this.includeLow = includeLow;
|
|
3189
|
-
this.includeHigh = includeHigh;
|
|
3190
|
-
}
|
|
3191
|
-
static {
|
|
3192
|
-
__name(this, "Range");
|
|
3193
|
-
}
|
|
3194
|
-
// Determine whether a key is within the range
|
|
3195
|
-
isInRange(key, comparator) {
|
|
3196
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
3197
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
3198
|
-
return lowCheck && highCheck;
|
|
3199
|
-
}
|
|
3200
|
-
};
|
|
3201
|
-
|
|
3202
3451
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3203
3452
|
var IterableEntryBase = class {
|
|
3204
3453
|
static {
|
|
@@ -3416,7 +3665,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3416
3665
|
[k, v] = toEntryFn(item);
|
|
3417
3666
|
} else {
|
|
3418
3667
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3419
|
-
|
|
3668
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3420
3669
|
}
|
|
3421
3670
|
[k, v] = item;
|
|
3422
3671
|
}
|
|
@@ -3429,7 +3678,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3429
3678
|
static createDefaultComparator() {
|
|
3430
3679
|
return (a, b) => {
|
|
3431
3680
|
if (typeof a === "number" && typeof b === "number") {
|
|
3432
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3681
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3433
3682
|
return a - b;
|
|
3434
3683
|
}
|
|
3435
3684
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3437,13 +3686,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3437
3686
|
}
|
|
3438
3687
|
if (a instanceof Date && b instanceof Date) {
|
|
3439
3688
|
const ta = a.getTime(), tb = b.getTime();
|
|
3440
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3689
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3441
3690
|
return ta - tb;
|
|
3442
3691
|
}
|
|
3443
3692
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3444
3693
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3445
3694
|
}
|
|
3446
|
-
|
|
3695
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3447
3696
|
};
|
|
3448
3697
|
}
|
|
3449
3698
|
// ─── Internal state ──────────────────────────────────────────
|
|
@@ -3488,6 +3737,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3488
3737
|
|
|
3489
3738
|
|
|
3490
3739
|
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3491
3747
|
|
|
3492
3748
|
|
|
3493
3749
|
|
|
@@ -3527,6 +3783,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3527
3783
|
|
|
3528
3784
|
|
|
3529
3785
|
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3530
3793
|
|
|
3531
3794
|
|
|
3532
3795
|
|
|
@@ -3569,6 +3832,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3569
3832
|
|
|
3570
3833
|
|
|
3571
3834
|
|
|
3835
|
+
|
|
3836
|
+
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3572
3842
|
|
|
3573
3843
|
|
|
3574
3844
|
|
|
@@ -3619,6 +3889,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3619
3889
|
|
|
3620
3890
|
|
|
3621
3891
|
|
|
3892
|
+
|
|
3893
|
+
|
|
3894
|
+
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
|
|
3622
3899
|
|
|
3623
3900
|
|
|
3624
3901
|
|
|
@@ -3694,6 +3971,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3694
3971
|
|
|
3695
3972
|
|
|
3696
3973
|
|
|
3974
|
+
|
|
3975
|
+
|
|
3976
|
+
|
|
3977
|
+
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3697
3981
|
|
|
3698
3982
|
|
|
3699
3983
|
|
|
@@ -3754,6 +4038,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3754
4038
|
|
|
3755
4039
|
|
|
3756
4040
|
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
3757
4048
|
|
|
3758
4049
|
|
|
3759
4050
|
|
|
@@ -3797,6 +4088,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3797
4088
|
|
|
3798
4089
|
|
|
3799
4090
|
|
|
4091
|
+
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
3800
4098
|
|
|
3801
4099
|
|
|
3802
4100
|
|
|
@@ -3860,6 +4158,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3860
4158
|
|
|
3861
4159
|
|
|
3862
4160
|
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
3863
4168
|
|
|
3864
4169
|
|
|
3865
4170
|
|
|
@@ -3903,6 +4208,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3903
4208
|
|
|
3904
4209
|
|
|
3905
4210
|
|
|
4211
|
+
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
3906
4218
|
|
|
3907
4219
|
|
|
3908
4220
|
|
|
@@ -3948,6 +4260,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3948
4260
|
|
|
3949
4261
|
|
|
3950
4262
|
|
|
4263
|
+
|
|
4264
|
+
|
|
4265
|
+
|
|
4266
|
+
|
|
4267
|
+
|
|
4268
|
+
|
|
4269
|
+
|
|
3951
4270
|
|
|
3952
4271
|
|
|
3953
4272
|
|
|
@@ -3991,6 +4310,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3991
4310
|
|
|
3992
4311
|
|
|
3993
4312
|
|
|
4313
|
+
|
|
4314
|
+
|
|
4315
|
+
|
|
4316
|
+
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
|
|
3994
4320
|
|
|
3995
4321
|
|
|
3996
4322
|
|
|
@@ -4037,6 +4363,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4037
4363
|
|
|
4038
4364
|
|
|
4039
4365
|
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4040
4373
|
|
|
4041
4374
|
|
|
4042
4375
|
|
|
@@ -4088,6 +4421,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4088
4421
|
|
|
4089
4422
|
|
|
4090
4423
|
|
|
4424
|
+
|
|
4425
|
+
|
|
4426
|
+
|
|
4427
|
+
|
|
4428
|
+
|
|
4429
|
+
|
|
4430
|
+
|
|
4091
4431
|
|
|
4092
4432
|
|
|
4093
4433
|
|
|
@@ -4137,6 +4477,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4137
4477
|
|
|
4138
4478
|
|
|
4139
4479
|
|
|
4480
|
+
|
|
4481
|
+
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
|
|
4486
|
+
|
|
4140
4487
|
|
|
4141
4488
|
|
|
4142
4489
|
|
|
@@ -4185,6 +4532,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4185
4532
|
|
|
4186
4533
|
|
|
4187
4534
|
|
|
4535
|
+
|
|
4536
|
+
|
|
4537
|
+
|
|
4538
|
+
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
|
|
4188
4542
|
|
|
4189
4543
|
|
|
4190
4544
|
|
|
@@ -4239,6 +4593,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4239
4593
|
|
|
4240
4594
|
|
|
4241
4595
|
|
|
4596
|
+
|
|
4597
|
+
|
|
4598
|
+
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
|
|
4602
|
+
|
|
4242
4603
|
|
|
4243
4604
|
|
|
4244
4605
|
|
|
@@ -4301,6 +4662,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4301
4662
|
|
|
4302
4663
|
|
|
4303
4664
|
|
|
4665
|
+
|
|
4666
|
+
|
|
4667
|
+
|
|
4668
|
+
|
|
4669
|
+
|
|
4670
|
+
|
|
4671
|
+
|
|
4304
4672
|
|
|
4305
4673
|
|
|
4306
4674
|
|
|
@@ -4347,6 +4715,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4347
4715
|
|
|
4348
4716
|
|
|
4349
4717
|
|
|
4718
|
+
|
|
4719
|
+
|
|
4720
|
+
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
|
|
4724
|
+
|
|
4350
4725
|
|
|
4351
4726
|
|
|
4352
4727
|
|
|
@@ -4432,6 +4807,6 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4432
4807
|
* @license MIT License
|
|
4433
4808
|
*/
|
|
4434
4809
|
|
|
4435
|
-
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode };
|
|
4810
|
+
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, raise };
|
|
4436
4811
|
//# sourceMappingURL=index.mjs.map
|
|
4437
4812
|
//# sourceMappingURL=index.mjs.map
|