linked-list-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 +212 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +211 -54
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +212 -56
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +211 -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 +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/linked-list-typed.js +209 -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 +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/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
|
}
|
|
@@ -755,6 +810,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
755
810
|
|
|
756
811
|
|
|
757
812
|
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
758
816
|
|
|
759
817
|
|
|
760
818
|
|
|
@@ -819,6 +877,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
819
877
|
|
|
820
878
|
|
|
821
879
|
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
822
883
|
|
|
823
884
|
|
|
824
885
|
|
|
@@ -888,6 +949,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
888
949
|
|
|
889
950
|
|
|
890
951
|
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
891
955
|
|
|
892
956
|
|
|
893
957
|
|
|
@@ -939,6 +1003,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
939
1003
|
|
|
940
1004
|
|
|
941
1005
|
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
942
1009
|
|
|
943
1010
|
|
|
944
1011
|
|
|
@@ -1051,6 +1118,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1051
1118
|
|
|
1052
1119
|
|
|
1053
1120
|
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1054
1124
|
|
|
1055
1125
|
|
|
1056
1126
|
|
|
@@ -1107,6 +1177,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1107
1177
|
|
|
1108
1178
|
|
|
1109
1179
|
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1110
1183
|
|
|
1111
1184
|
|
|
1112
1185
|
|
|
@@ -1152,6 +1225,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1152
1225
|
|
|
1153
1226
|
|
|
1154
1227
|
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1155
1231
|
|
|
1156
1232
|
|
|
1157
1233
|
|
|
@@ -1203,6 +1279,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1203
1279
|
|
|
1204
1280
|
|
|
1205
1281
|
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
|
|
1206
1285
|
|
|
1207
1286
|
|
|
1208
1287
|
|
|
@@ -1259,6 +1338,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1259
1338
|
|
|
1260
1339
|
|
|
1261
1340
|
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1262
1344
|
|
|
1263
1345
|
|
|
1264
1346
|
|
|
@@ -1323,6 +1405,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1323
1405
|
|
|
1324
1406
|
|
|
1325
1407
|
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
|
|
1326
1411
|
|
|
1327
1412
|
|
|
1328
1413
|
|
|
@@ -1364,6 +1449,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1364
1449
|
|
|
1365
1450
|
|
|
1366
1451
|
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1367
1455
|
|
|
1368
1456
|
|
|
1369
1457
|
|
|
@@ -1411,6 +1499,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1411
1499
|
|
|
1412
1500
|
|
|
1413
1501
|
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1414
1505
|
|
|
1415
1506
|
|
|
1416
1507
|
|
|
@@ -1624,6 +1715,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1624
1715
|
|
|
1625
1716
|
|
|
1626
1717
|
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1627
1721
|
|
|
1628
1722
|
|
|
1629
1723
|
|
|
@@ -1675,6 +1769,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1675
1769
|
|
|
1676
1770
|
|
|
1677
1771
|
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1678
1775
|
|
|
1679
1776
|
|
|
1680
1777
|
|
|
@@ -1754,6 +1851,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1754
1851
|
|
|
1755
1852
|
|
|
1756
1853
|
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
|
|
1757
1857
|
|
|
1758
1858
|
|
|
1759
1859
|
|
|
@@ -2071,6 +2171,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2071
2171
|
|
|
2072
2172
|
|
|
2073
2173
|
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2074
2177
|
|
|
2075
2178
|
|
|
2076
2179
|
|
|
@@ -2137,6 +2240,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2137
2240
|
|
|
2138
2241
|
|
|
2139
2242
|
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2140
2246
|
|
|
2141
2247
|
|
|
2142
2248
|
|
|
@@ -2202,6 +2308,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2202
2308
|
|
|
2203
2309
|
|
|
2204
2310
|
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2205
2314
|
|
|
2206
2315
|
|
|
2207
2316
|
|
|
@@ -2258,6 +2367,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2258
2367
|
|
|
2259
2368
|
|
|
2260
2369
|
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2261
2373
|
|
|
2262
2374
|
|
|
2263
2375
|
|
|
@@ -2343,6 +2455,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2343
2455
|
|
|
2344
2456
|
|
|
2345
2457
|
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2346
2461
|
|
|
2347
2462
|
|
|
2348
2463
|
|
|
@@ -2389,6 +2504,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2389
2504
|
|
|
2390
2505
|
|
|
2391
2506
|
|
|
2507
|
+
|
|
2508
|
+
|
|
2509
|
+
|
|
2392
2510
|
|
|
2393
2511
|
|
|
2394
2512
|
|
|
@@ -2466,6 +2584,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2466
2584
|
|
|
2467
2585
|
|
|
2468
2586
|
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2469
2590
|
|
|
2470
2591
|
|
|
2471
2592
|
|
|
@@ -2571,6 +2692,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2571
2692
|
|
|
2572
2693
|
|
|
2573
2694
|
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
|
|
2574
2698
|
|
|
2575
2699
|
|
|
2576
2700
|
|
|
@@ -2623,6 +2747,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2623
2747
|
|
|
2624
2748
|
|
|
2625
2749
|
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
|
|
2626
2753
|
|
|
2627
2754
|
|
|
2628
2755
|
|
|
@@ -2677,6 +2804,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2677
2804
|
|
|
2678
2805
|
|
|
2679
2806
|
|
|
2807
|
+
|
|
2808
|
+
|
|
2809
|
+
|
|
2680
2810
|
|
|
2681
2811
|
|
|
2682
2812
|
|
|
@@ -2718,6 +2848,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2718
2848
|
|
|
2719
2849
|
|
|
2720
2850
|
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
|
|
2721
2854
|
|
|
2722
2855
|
|
|
2723
2856
|
|
|
@@ -2763,6 +2896,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2763
2896
|
|
|
2764
2897
|
|
|
2765
2898
|
|
|
2899
|
+
|
|
2900
|
+
|
|
2901
|
+
|
|
2766
2902
|
|
|
2767
2903
|
|
|
2768
2904
|
|
|
@@ -2812,6 +2948,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2812
2948
|
|
|
2813
2949
|
|
|
2814
2950
|
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2815
2954
|
|
|
2816
2955
|
|
|
2817
2956
|
|
|
@@ -2864,6 +3003,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2864
3003
|
|
|
2865
3004
|
|
|
2866
3005
|
|
|
3006
|
+
|
|
3007
|
+
|
|
3008
|
+
|
|
2867
3009
|
|
|
2868
3010
|
|
|
2869
3011
|
|
|
@@ -2924,6 +3066,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2924
3066
|
|
|
2925
3067
|
|
|
2926
3068
|
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
|
|
2927
3072
|
|
|
2928
3073
|
|
|
2929
3074
|
|
|
@@ -2974,6 +3119,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2974
3119
|
|
|
2975
3120
|
|
|
2976
3121
|
|
|
3122
|
+
|
|
3123
|
+
|
|
3124
|
+
|
|
2977
3125
|
|
|
2978
3126
|
|
|
2979
3127
|
|
|
@@ -3043,6 +3191,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3043
3191
|
|
|
3044
3192
|
|
|
3045
3193
|
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3046
3197
|
|
|
3047
3198
|
|
|
3048
3199
|
|
|
@@ -3150,55 +3301,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3150
3301
|
}
|
|
3151
3302
|
};
|
|
3152
3303
|
|
|
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
3304
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3203
3305
|
var IterableEntryBase = class {
|
|
3204
3306
|
static {
|
|
@@ -3416,7 +3518,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3416
3518
|
[k, v] = toEntryFn(item);
|
|
3417
3519
|
} else {
|
|
3418
3520
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3419
|
-
|
|
3521
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3420
3522
|
}
|
|
3421
3523
|
[k, v] = item;
|
|
3422
3524
|
}
|
|
@@ -3429,7 +3531,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3429
3531
|
static createDefaultComparator() {
|
|
3430
3532
|
return (a, b) => {
|
|
3431
3533
|
if (typeof a === "number" && typeof b === "number") {
|
|
3432
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3534
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3433
3535
|
return a - b;
|
|
3434
3536
|
}
|
|
3435
3537
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3437,13 +3539,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3437
3539
|
}
|
|
3438
3540
|
if (a instanceof Date && b instanceof Date) {
|
|
3439
3541
|
const ta = a.getTime(), tb = b.getTime();
|
|
3440
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3542
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3441
3543
|
return ta - tb;
|
|
3442
3544
|
}
|
|
3443
3545
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3444
3546
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3445
3547
|
}
|
|
3446
|
-
|
|
3548
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3447
3549
|
};
|
|
3448
3550
|
}
|
|
3449
3551
|
// ─── Internal state ──────────────────────────────────────────
|
|
@@ -3492,6 +3594,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3492
3594
|
|
|
3493
3595
|
|
|
3494
3596
|
|
|
3597
|
+
|
|
3598
|
+
|
|
3599
|
+
|
|
3495
3600
|
|
|
3496
3601
|
|
|
3497
3602
|
|
|
@@ -3531,6 +3636,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3531
3636
|
|
|
3532
3637
|
|
|
3533
3638
|
|
|
3639
|
+
|
|
3640
|
+
|
|
3641
|
+
|
|
3534
3642
|
|
|
3535
3643
|
|
|
3536
3644
|
|
|
@@ -3573,6 +3681,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3573
3681
|
|
|
3574
3682
|
|
|
3575
3683
|
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
|
|
3576
3687
|
|
|
3577
3688
|
|
|
3578
3689
|
|
|
@@ -3623,6 +3734,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3623
3734
|
|
|
3624
3735
|
|
|
3625
3736
|
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
|
|
3626
3740
|
|
|
3627
3741
|
|
|
3628
3742
|
|
|
@@ -3698,6 +3812,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3698
3812
|
|
|
3699
3813
|
|
|
3700
3814
|
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
|
|
3701
3818
|
|
|
3702
3819
|
|
|
3703
3820
|
|
|
@@ -3758,6 +3875,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3758
3875
|
|
|
3759
3876
|
|
|
3760
3877
|
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3761
3881
|
|
|
3762
3882
|
|
|
3763
3883
|
|
|
@@ -3801,6 +3921,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3801
3921
|
|
|
3802
3922
|
|
|
3803
3923
|
|
|
3924
|
+
|
|
3925
|
+
|
|
3926
|
+
|
|
3804
3927
|
|
|
3805
3928
|
|
|
3806
3929
|
|
|
@@ -3864,6 +3987,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3864
3987
|
|
|
3865
3988
|
|
|
3866
3989
|
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
|
|
3867
3993
|
|
|
3868
3994
|
|
|
3869
3995
|
|
|
@@ -3907,6 +4033,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3907
4033
|
|
|
3908
4034
|
|
|
3909
4035
|
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
3910
4039
|
|
|
3911
4040
|
|
|
3912
4041
|
|
|
@@ -3952,6 +4081,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3952
4081
|
|
|
3953
4082
|
|
|
3954
4083
|
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
3955
4087
|
|
|
3956
4088
|
|
|
3957
4089
|
|
|
@@ -3995,6 +4127,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3995
4127
|
|
|
3996
4128
|
|
|
3997
4129
|
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
|
|
3998
4133
|
|
|
3999
4134
|
|
|
4000
4135
|
|
|
@@ -4041,6 +4176,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4041
4176
|
|
|
4042
4177
|
|
|
4043
4178
|
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4044
4182
|
|
|
4045
4183
|
|
|
4046
4184
|
|
|
@@ -4092,6 +4230,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4092
4230
|
|
|
4093
4231
|
|
|
4094
4232
|
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4095
4236
|
|
|
4096
4237
|
|
|
4097
4238
|
|
|
@@ -4141,6 +4282,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4141
4282
|
|
|
4142
4283
|
|
|
4143
4284
|
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
4144
4288
|
|
|
4145
4289
|
|
|
4146
4290
|
|
|
@@ -4189,6 +4333,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4189
4333
|
|
|
4190
4334
|
|
|
4191
4335
|
|
|
4336
|
+
|
|
4337
|
+
|
|
4338
|
+
|
|
4192
4339
|
|
|
4193
4340
|
|
|
4194
4341
|
|
|
@@ -4243,6 +4390,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4243
4390
|
|
|
4244
4391
|
|
|
4245
4392
|
|
|
4393
|
+
|
|
4394
|
+
|
|
4395
|
+
|
|
4246
4396
|
|
|
4247
4397
|
|
|
4248
4398
|
|
|
@@ -4305,6 +4455,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4305
4455
|
|
|
4306
4456
|
|
|
4307
4457
|
|
|
4458
|
+
|
|
4459
|
+
|
|
4460
|
+
|
|
4308
4461
|
|
|
4309
4462
|
|
|
4310
4463
|
|
|
@@ -4351,6 +4504,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4351
4504
|
|
|
4352
4505
|
|
|
4353
4506
|
|
|
4507
|
+
|
|
4508
|
+
|
|
4509
|
+
|
|
4354
4510
|
|
|
4355
4511
|
|
|
4356
4512
|
|
|
@@ -4432,6 +4588,6 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4432
4588
|
* @license MIT License
|
|
4433
4589
|
*/
|
|
4434
4590
|
|
|
4435
|
-
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode };
|
|
4591
|
+
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, raise };
|
|
4436
4592
|
//# sourceMappingURL=index.mjs.map
|
|
4437
4593
|
//# sourceMappingURL=index.mjs.map
|