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/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,61 @@
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
5
|
|
|
6
|
+
// src/common/error.ts
|
|
7
|
+
function raise(ErrorClass, message) {
|
|
8
|
+
throw new ErrorClass(message);
|
|
9
|
+
}
|
|
10
|
+
__name(raise, "raise");
|
|
11
|
+
var ERR = {
|
|
12
|
+
// Range / index
|
|
13
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
14
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
15
|
+
// Type / argument
|
|
16
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
17
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
18
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
19
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
20
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
21
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
22
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
23
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
24
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
25
|
+
// State / operation
|
|
26
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
27
|
+
// Matrix
|
|
28
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
29
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
30
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
31
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
32
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
33
|
+
// Order statistic
|
|
34
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/common/index.ts
|
|
38
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
39
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
40
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
41
|
+
return DFSOperation2;
|
|
42
|
+
})(DFSOperation || {});
|
|
43
|
+
var Range = class {
|
|
44
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
45
|
+
this.low = low;
|
|
46
|
+
this.high = high;
|
|
47
|
+
this.includeLow = includeLow;
|
|
48
|
+
this.includeHigh = includeHigh;
|
|
49
|
+
}
|
|
50
|
+
static {
|
|
51
|
+
__name(this, "Range");
|
|
52
|
+
}
|
|
53
|
+
// Determine whether a key is within the range
|
|
54
|
+
isInRange(key, comparator) {
|
|
55
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
56
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
57
|
+
return lowCheck && highCheck;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
6
61
|
// src/data-structures/base/iterable-element-base.ts
|
|
7
62
|
var IterableElementBase = class {
|
|
8
63
|
static {
|
|
@@ -21,7 +76,7 @@ var IterableElementBase = class {
|
|
|
21
76
|
if (options) {
|
|
22
77
|
const { toElementFn } = options;
|
|
23
78
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
24
|
-
else if (toElementFn)
|
|
79
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
25
80
|
}
|
|
26
81
|
}
|
|
27
82
|
/**
|
|
@@ -184,7 +239,7 @@ var IterableElementBase = class {
|
|
|
184
239
|
acc = initialValue;
|
|
185
240
|
} else {
|
|
186
241
|
const first = iter.next();
|
|
187
|
-
if (first.done)
|
|
242
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
188
243
|
acc = first.value;
|
|
189
244
|
index = 1;
|
|
190
245
|
}
|
|
@@ -753,6 +808,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
753
808
|
|
|
754
809
|
|
|
755
810
|
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
756
818
|
|
|
757
819
|
|
|
758
820
|
|
|
@@ -817,6 +879,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
817
879
|
|
|
818
880
|
|
|
819
881
|
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
820
889
|
|
|
821
890
|
|
|
822
891
|
|
|
@@ -886,6 +955,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
886
955
|
|
|
887
956
|
|
|
888
957
|
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
889
965
|
|
|
890
966
|
|
|
891
967
|
|
|
@@ -937,6 +1013,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
937
1013
|
|
|
938
1014
|
|
|
939
1015
|
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
940
1023
|
|
|
941
1024
|
|
|
942
1025
|
|
|
@@ -1049,6 +1132,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1049
1132
|
|
|
1050
1133
|
|
|
1051
1134
|
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
|
|
1052
1142
|
|
|
1053
1143
|
|
|
1054
1144
|
|
|
@@ -1105,6 +1195,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1105
1195
|
|
|
1106
1196
|
|
|
1107
1197
|
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1108
1205
|
|
|
1109
1206
|
|
|
1110
1207
|
|
|
@@ -1150,6 +1247,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1150
1247
|
|
|
1151
1248
|
|
|
1152
1249
|
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1153
1257
|
|
|
1154
1258
|
|
|
1155
1259
|
|
|
@@ -1201,6 +1305,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1201
1305
|
|
|
1202
1306
|
|
|
1203
1307
|
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1204
1315
|
|
|
1205
1316
|
|
|
1206
1317
|
|
|
@@ -1257,6 +1368,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1257
1368
|
|
|
1258
1369
|
|
|
1259
1370
|
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1260
1378
|
|
|
1261
1379
|
|
|
1262
1380
|
|
|
@@ -1321,6 +1439,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1321
1439
|
|
|
1322
1440
|
|
|
1323
1441
|
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1324
1449
|
|
|
1325
1450
|
|
|
1326
1451
|
|
|
@@ -1362,6 +1487,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1362
1487
|
|
|
1363
1488
|
|
|
1364
1489
|
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1365
1497
|
|
|
1366
1498
|
|
|
1367
1499
|
|
|
@@ -1409,6 +1541,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1409
1541
|
|
|
1410
1542
|
|
|
1411
1543
|
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1412
1551
|
|
|
1413
1552
|
|
|
1414
1553
|
|
|
@@ -1622,6 +1761,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1622
1761
|
|
|
1623
1762
|
|
|
1624
1763
|
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1625
1771
|
|
|
1626
1772
|
|
|
1627
1773
|
|
|
@@ -1673,6 +1819,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1673
1819
|
|
|
1674
1820
|
|
|
1675
1821
|
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
|
|
1676
1829
|
|
|
1677
1830
|
|
|
1678
1831
|
|
|
@@ -1752,6 +1905,13 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1752
1905
|
|
|
1753
1906
|
|
|
1754
1907
|
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1755
1915
|
|
|
1756
1916
|
|
|
1757
1917
|
|
|
@@ -2069,6 +2229,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2069
2229
|
|
|
2070
2230
|
|
|
2071
2231
|
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2072
2239
|
|
|
2073
2240
|
|
|
2074
2241
|
|
|
@@ -2135,6 +2302,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2135
2302
|
|
|
2136
2303
|
|
|
2137
2304
|
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2138
2312
|
|
|
2139
2313
|
|
|
2140
2314
|
|
|
@@ -2200,6 +2374,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2200
2374
|
|
|
2201
2375
|
|
|
2202
2376
|
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2203
2384
|
|
|
2204
2385
|
|
|
2205
2386
|
|
|
@@ -2256,6 +2437,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2256
2437
|
|
|
2257
2438
|
|
|
2258
2439
|
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2259
2447
|
|
|
2260
2448
|
|
|
2261
2449
|
|
|
@@ -2341,6 +2529,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2341
2529
|
|
|
2342
2530
|
|
|
2343
2531
|
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2344
2539
|
|
|
2345
2540
|
|
|
2346
2541
|
|
|
@@ -2387,6 +2582,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2387
2582
|
|
|
2388
2583
|
|
|
2389
2584
|
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2390
2592
|
|
|
2391
2593
|
|
|
2392
2594
|
|
|
@@ -2464,6 +2666,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2464
2666
|
|
|
2465
2667
|
|
|
2466
2668
|
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
|
|
2467
2676
|
|
|
2468
2677
|
|
|
2469
2678
|
|
|
@@ -2569,6 +2778,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2569
2778
|
|
|
2570
2779
|
|
|
2571
2780
|
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
|
|
2787
|
+
|
|
2572
2788
|
|
|
2573
2789
|
|
|
2574
2790
|
|
|
@@ -2621,6 +2837,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2621
2837
|
|
|
2622
2838
|
|
|
2623
2839
|
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
|
|
2843
|
+
|
|
2844
|
+
|
|
2845
|
+
|
|
2846
|
+
|
|
2624
2847
|
|
|
2625
2848
|
|
|
2626
2849
|
|
|
@@ -2675,6 +2898,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2675
2898
|
|
|
2676
2899
|
|
|
2677
2900
|
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
|
|
2907
|
+
|
|
2678
2908
|
|
|
2679
2909
|
|
|
2680
2910
|
|
|
@@ -2716,6 +2946,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2716
2946
|
|
|
2717
2947
|
|
|
2718
2948
|
|
|
2949
|
+
|
|
2950
|
+
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2719
2956
|
|
|
2720
2957
|
|
|
2721
2958
|
|
|
@@ -2761,6 +2998,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2761
2998
|
|
|
2762
2999
|
|
|
2763
3000
|
|
|
3001
|
+
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
|
|
3005
|
+
|
|
3006
|
+
|
|
3007
|
+
|
|
2764
3008
|
|
|
2765
3009
|
|
|
2766
3010
|
|
|
@@ -2810,6 +3054,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2810
3054
|
|
|
2811
3055
|
|
|
2812
3056
|
|
|
3057
|
+
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
|
|
2813
3064
|
|
|
2814
3065
|
|
|
2815
3066
|
|
|
@@ -2862,6 +3113,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2862
3113
|
|
|
2863
3114
|
|
|
2864
3115
|
|
|
3116
|
+
|
|
3117
|
+
|
|
3118
|
+
|
|
3119
|
+
|
|
3120
|
+
|
|
3121
|
+
|
|
3122
|
+
|
|
2865
3123
|
|
|
2866
3124
|
|
|
2867
3125
|
|
|
@@ -2886,6 +3144,25 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2886
3144
|
}
|
|
2887
3145
|
return this;
|
|
2888
3146
|
}
|
|
3147
|
+
/**
|
|
3148
|
+
* Delete the first element that satisfies a predicate.
|
|
3149
|
+
* @remarks Time O(N), Space O(1)
|
|
3150
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3151
|
+
* @returns True if a match was removed.
|
|
3152
|
+
*/
|
|
3153
|
+
deleteWhere(predicate) {
|
|
3154
|
+
let current = this.head;
|
|
3155
|
+
let index = 0;
|
|
3156
|
+
while (current) {
|
|
3157
|
+
if (predicate(current.value, index, this)) {
|
|
3158
|
+
this.delete(current);
|
|
3159
|
+
return true;
|
|
3160
|
+
}
|
|
3161
|
+
current = current.next;
|
|
3162
|
+
index++;
|
|
3163
|
+
}
|
|
3164
|
+
return false;
|
|
3165
|
+
}
|
|
2889
3166
|
/**
|
|
2890
3167
|
* Set the equality comparator used to compare values.
|
|
2891
3168
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2922,6 +3199,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2922
3199
|
|
|
2923
3200
|
|
|
2924
3201
|
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
2925
3209
|
|
|
2926
3210
|
|
|
2927
3211
|
|
|
@@ -2972,6 +3256,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2972
3256
|
|
|
2973
3257
|
|
|
2974
3258
|
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
2975
3266
|
|
|
2976
3267
|
|
|
2977
3268
|
|
|
@@ -3041,6 +3332,13 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3041
3332
|
|
|
3042
3333
|
|
|
3043
3334
|
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
|
|
3338
|
+
|
|
3339
|
+
|
|
3340
|
+
|
|
3341
|
+
|
|
3044
3342
|
|
|
3045
3343
|
|
|
3046
3344
|
|
|
@@ -3152,55 +3450,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3152
3450
|
}
|
|
3153
3451
|
};
|
|
3154
3452
|
|
|
3155
|
-
// src/common/error.ts
|
|
3156
|
-
var ERR = {
|
|
3157
|
-
// Range / index
|
|
3158
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
3159
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
3160
|
-
// Type / argument
|
|
3161
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
3162
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
3163
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
3164
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
3165
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
3166
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
3167
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
3168
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
3169
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
3170
|
-
// State / operation
|
|
3171
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
3172
|
-
// Matrix
|
|
3173
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
3174
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
3175
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
3176
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
3177
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
3178
|
-
};
|
|
3179
|
-
|
|
3180
|
-
// src/common/index.ts
|
|
3181
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
3182
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
3183
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
3184
|
-
return DFSOperation2;
|
|
3185
|
-
})(DFSOperation || {});
|
|
3186
|
-
var Range = class {
|
|
3187
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
3188
|
-
this.low = low;
|
|
3189
|
-
this.high = high;
|
|
3190
|
-
this.includeLow = includeLow;
|
|
3191
|
-
this.includeHigh = includeHigh;
|
|
3192
|
-
}
|
|
3193
|
-
static {
|
|
3194
|
-
__name(this, "Range");
|
|
3195
|
-
}
|
|
3196
|
-
// Determine whether a key is within the range
|
|
3197
|
-
isInRange(key, comparator) {
|
|
3198
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
3199
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
3200
|
-
return lowCheck && highCheck;
|
|
3201
|
-
}
|
|
3202
|
-
};
|
|
3203
|
-
|
|
3204
3453
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3205
3454
|
var IterableEntryBase = class {
|
|
3206
3455
|
static {
|
|
@@ -3418,7 +3667,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3418
3667
|
[k, v] = toEntryFn(item);
|
|
3419
3668
|
} else {
|
|
3420
3669
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3421
|
-
|
|
3670
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3422
3671
|
}
|
|
3423
3672
|
[k, v] = item;
|
|
3424
3673
|
}
|
|
@@ -3431,7 +3680,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3431
3680
|
static createDefaultComparator() {
|
|
3432
3681
|
return (a, b) => {
|
|
3433
3682
|
if (typeof a === "number" && typeof b === "number") {
|
|
3434
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3683
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3435
3684
|
return a - b;
|
|
3436
3685
|
}
|
|
3437
3686
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3439,13 +3688,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3439
3688
|
}
|
|
3440
3689
|
if (a instanceof Date && b instanceof Date) {
|
|
3441
3690
|
const ta = a.getTime(), tb = b.getTime();
|
|
3442
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3691
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3443
3692
|
return ta - tb;
|
|
3444
3693
|
}
|
|
3445
3694
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3446
3695
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3447
3696
|
}
|
|
3448
|
-
|
|
3697
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3449
3698
|
};
|
|
3450
3699
|
}
|
|
3451
3700
|
// ─── Internal state ──────────────────────────────────────────
|
|
@@ -3490,6 +3739,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3490
3739
|
|
|
3491
3740
|
|
|
3492
3741
|
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3493
3749
|
|
|
3494
3750
|
|
|
3495
3751
|
|
|
@@ -3529,6 +3785,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3529
3785
|
|
|
3530
3786
|
|
|
3531
3787
|
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3794
|
+
|
|
3532
3795
|
|
|
3533
3796
|
|
|
3534
3797
|
|
|
@@ -3571,6 +3834,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3571
3834
|
|
|
3572
3835
|
|
|
3573
3836
|
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3574
3844
|
|
|
3575
3845
|
|
|
3576
3846
|
|
|
@@ -3621,6 +3891,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3621
3891
|
|
|
3622
3892
|
|
|
3623
3893
|
|
|
3894
|
+
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
|
|
3899
|
+
|
|
3900
|
+
|
|
3624
3901
|
|
|
3625
3902
|
|
|
3626
3903
|
|
|
@@ -3696,6 +3973,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3696
3973
|
|
|
3697
3974
|
|
|
3698
3975
|
|
|
3976
|
+
|
|
3977
|
+
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3699
3983
|
|
|
3700
3984
|
|
|
3701
3985
|
|
|
@@ -3756,6 +4040,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3756
4040
|
|
|
3757
4041
|
|
|
3758
4042
|
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
3759
4050
|
|
|
3760
4051
|
|
|
3761
4052
|
|
|
@@ -3799,6 +4090,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3799
4090
|
|
|
3800
4091
|
|
|
3801
4092
|
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
3802
4100
|
|
|
3803
4101
|
|
|
3804
4102
|
|
|
@@ -3862,6 +4160,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3862
4160
|
|
|
3863
4161
|
|
|
3864
4162
|
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
3865
4170
|
|
|
3866
4171
|
|
|
3867
4172
|
|
|
@@ -3905,6 +4210,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3905
4210
|
|
|
3906
4211
|
|
|
3907
4212
|
|
|
4213
|
+
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
4219
|
+
|
|
3908
4220
|
|
|
3909
4221
|
|
|
3910
4222
|
|
|
@@ -3950,6 +4262,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3950
4262
|
|
|
3951
4263
|
|
|
3952
4264
|
|
|
4265
|
+
|
|
4266
|
+
|
|
4267
|
+
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
|
|
4271
|
+
|
|
3953
4272
|
|
|
3954
4273
|
|
|
3955
4274
|
|
|
@@ -3993,6 +4312,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3993
4312
|
|
|
3994
4313
|
|
|
3995
4314
|
|
|
4315
|
+
|
|
4316
|
+
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
|
|
4320
|
+
|
|
4321
|
+
|
|
3996
4322
|
|
|
3997
4323
|
|
|
3998
4324
|
|
|
@@ -4039,6 +4365,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4039
4365
|
|
|
4040
4366
|
|
|
4041
4367
|
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
|
|
4374
|
+
|
|
4042
4375
|
|
|
4043
4376
|
|
|
4044
4377
|
|
|
@@ -4090,6 +4423,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4090
4423
|
|
|
4091
4424
|
|
|
4092
4425
|
|
|
4426
|
+
|
|
4427
|
+
|
|
4428
|
+
|
|
4429
|
+
|
|
4430
|
+
|
|
4431
|
+
|
|
4432
|
+
|
|
4093
4433
|
|
|
4094
4434
|
|
|
4095
4435
|
|
|
@@ -4139,6 +4479,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4139
4479
|
|
|
4140
4480
|
|
|
4141
4481
|
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
|
|
4486
|
+
|
|
4487
|
+
|
|
4488
|
+
|
|
4142
4489
|
|
|
4143
4490
|
|
|
4144
4491
|
|
|
@@ -4187,6 +4534,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4187
4534
|
|
|
4188
4535
|
|
|
4189
4536
|
|
|
4537
|
+
|
|
4538
|
+
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
|
|
4542
|
+
|
|
4543
|
+
|
|
4190
4544
|
|
|
4191
4545
|
|
|
4192
4546
|
|
|
@@ -4241,6 +4595,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4241
4595
|
|
|
4242
4596
|
|
|
4243
4597
|
|
|
4598
|
+
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
|
|
4602
|
+
|
|
4603
|
+
|
|
4604
|
+
|
|
4244
4605
|
|
|
4245
4606
|
|
|
4246
4607
|
|
|
@@ -4303,6 +4664,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4303
4664
|
|
|
4304
4665
|
|
|
4305
4666
|
|
|
4667
|
+
|
|
4668
|
+
|
|
4669
|
+
|
|
4670
|
+
|
|
4671
|
+
|
|
4672
|
+
|
|
4673
|
+
|
|
4306
4674
|
|
|
4307
4675
|
|
|
4308
4676
|
|
|
@@ -4349,6 +4717,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4349
4717
|
|
|
4350
4718
|
|
|
4351
4719
|
|
|
4720
|
+
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
|
|
4724
|
+
|
|
4725
|
+
|
|
4726
|
+
|
|
4352
4727
|
|
|
4353
4728
|
|
|
4354
4729
|
|
|
@@ -4443,5 +4818,6 @@ exports.SinglyLinkedList = SinglyLinkedList;
|
|
|
4443
4818
|
exports.SinglyLinkedListNode = SinglyLinkedListNode;
|
|
4444
4819
|
exports.SkipList = SkipList;
|
|
4445
4820
|
exports.SkipListNode = SkipListNode;
|
|
4821
|
+
exports.raise = raise;
|
|
4446
4822
|
//# sourceMappingURL=index.cjs.map
|
|
4447
4823
|
//# sourceMappingURL=index.cjs.map
|