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/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
|
}
|
|
@@ -757,6 +812,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
757
812
|
|
|
758
813
|
|
|
759
814
|
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
760
818
|
|
|
761
819
|
|
|
762
820
|
|
|
@@ -821,6 +879,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
821
879
|
|
|
822
880
|
|
|
823
881
|
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
824
885
|
|
|
825
886
|
|
|
826
887
|
|
|
@@ -890,6 +951,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
890
951
|
|
|
891
952
|
|
|
892
953
|
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
893
957
|
|
|
894
958
|
|
|
895
959
|
|
|
@@ -941,6 +1005,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
941
1005
|
|
|
942
1006
|
|
|
943
1007
|
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
944
1011
|
|
|
945
1012
|
|
|
946
1013
|
|
|
@@ -1053,6 +1120,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1053
1120
|
|
|
1054
1121
|
|
|
1055
1122
|
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1056
1126
|
|
|
1057
1127
|
|
|
1058
1128
|
|
|
@@ -1109,6 +1179,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1109
1179
|
|
|
1110
1180
|
|
|
1111
1181
|
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1112
1185
|
|
|
1113
1186
|
|
|
1114
1187
|
|
|
@@ -1154,6 +1227,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1154
1227
|
|
|
1155
1228
|
|
|
1156
1229
|
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1157
1233
|
|
|
1158
1234
|
|
|
1159
1235
|
|
|
@@ -1205,6 +1281,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1205
1281
|
|
|
1206
1282
|
|
|
1207
1283
|
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1208
1287
|
|
|
1209
1288
|
|
|
1210
1289
|
|
|
@@ -1261,6 +1340,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1261
1340
|
|
|
1262
1341
|
|
|
1263
1342
|
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1264
1346
|
|
|
1265
1347
|
|
|
1266
1348
|
|
|
@@ -1325,6 +1407,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1325
1407
|
|
|
1326
1408
|
|
|
1327
1409
|
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
|
|
1328
1413
|
|
|
1329
1414
|
|
|
1330
1415
|
|
|
@@ -1366,6 +1451,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1366
1451
|
|
|
1367
1452
|
|
|
1368
1453
|
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1369
1457
|
|
|
1370
1458
|
|
|
1371
1459
|
|
|
@@ -1413,6 +1501,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1413
1501
|
|
|
1414
1502
|
|
|
1415
1503
|
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1416
1507
|
|
|
1417
1508
|
|
|
1418
1509
|
|
|
@@ -1626,6 +1717,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1626
1717
|
|
|
1627
1718
|
|
|
1628
1719
|
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
|
|
1629
1723
|
|
|
1630
1724
|
|
|
1631
1725
|
|
|
@@ -1677,6 +1771,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1677
1771
|
|
|
1678
1772
|
|
|
1679
1773
|
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1680
1777
|
|
|
1681
1778
|
|
|
1682
1779
|
|
|
@@ -1756,6 +1853,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
1756
1853
|
|
|
1757
1854
|
|
|
1758
1855
|
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
|
|
1759
1859
|
|
|
1760
1860
|
|
|
1761
1861
|
|
|
@@ -2073,6 +2173,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2073
2173
|
|
|
2074
2174
|
|
|
2075
2175
|
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2076
2179
|
|
|
2077
2180
|
|
|
2078
2181
|
|
|
@@ -2139,6 +2242,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2139
2242
|
|
|
2140
2243
|
|
|
2141
2244
|
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2142
2248
|
|
|
2143
2249
|
|
|
2144
2250
|
|
|
@@ -2204,6 +2310,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2204
2310
|
|
|
2205
2311
|
|
|
2206
2312
|
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
|
|
2207
2316
|
|
|
2208
2317
|
|
|
2209
2318
|
|
|
@@ -2260,6 +2369,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2260
2369
|
|
|
2261
2370
|
|
|
2262
2371
|
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2263
2375
|
|
|
2264
2376
|
|
|
2265
2377
|
|
|
@@ -2345,6 +2457,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2345
2457
|
|
|
2346
2458
|
|
|
2347
2459
|
|
|
2460
|
+
|
|
2461
|
+
|
|
2462
|
+
|
|
2348
2463
|
|
|
2349
2464
|
|
|
2350
2465
|
|
|
@@ -2391,6 +2506,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2391
2506
|
|
|
2392
2507
|
|
|
2393
2508
|
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
|
|
2394
2512
|
|
|
2395
2513
|
|
|
2396
2514
|
|
|
@@ -2468,6 +2586,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2468
2586
|
|
|
2469
2587
|
|
|
2470
2588
|
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2471
2592
|
|
|
2472
2593
|
|
|
2473
2594
|
|
|
@@ -2573,6 +2694,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2573
2694
|
|
|
2574
2695
|
|
|
2575
2696
|
|
|
2697
|
+
|
|
2698
|
+
|
|
2699
|
+
|
|
2576
2700
|
|
|
2577
2701
|
|
|
2578
2702
|
|
|
@@ -2625,6 +2749,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2625
2749
|
|
|
2626
2750
|
|
|
2627
2751
|
|
|
2752
|
+
|
|
2753
|
+
|
|
2754
|
+
|
|
2628
2755
|
|
|
2629
2756
|
|
|
2630
2757
|
|
|
@@ -2679,6 +2806,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2679
2806
|
|
|
2680
2807
|
|
|
2681
2808
|
|
|
2809
|
+
|
|
2810
|
+
|
|
2811
|
+
|
|
2682
2812
|
|
|
2683
2813
|
|
|
2684
2814
|
|
|
@@ -2720,6 +2850,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2720
2850
|
|
|
2721
2851
|
|
|
2722
2852
|
|
|
2853
|
+
|
|
2854
|
+
|
|
2855
|
+
|
|
2723
2856
|
|
|
2724
2857
|
|
|
2725
2858
|
|
|
@@ -2765,6 +2898,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2765
2898
|
|
|
2766
2899
|
|
|
2767
2900
|
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
|
|
2768
2904
|
|
|
2769
2905
|
|
|
2770
2906
|
|
|
@@ -2814,6 +2950,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2814
2950
|
|
|
2815
2951
|
|
|
2816
2952
|
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2817
2956
|
|
|
2818
2957
|
|
|
2819
2958
|
|
|
@@ -2866,6 +3005,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2866
3005
|
|
|
2867
3006
|
|
|
2868
3007
|
|
|
3008
|
+
|
|
3009
|
+
|
|
3010
|
+
|
|
2869
3011
|
|
|
2870
3012
|
|
|
2871
3013
|
|
|
@@ -2926,6 +3068,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2926
3068
|
|
|
2927
3069
|
|
|
2928
3070
|
|
|
3071
|
+
|
|
3072
|
+
|
|
3073
|
+
|
|
2929
3074
|
|
|
2930
3075
|
|
|
2931
3076
|
|
|
@@ -2976,6 +3121,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
2976
3121
|
|
|
2977
3122
|
|
|
2978
3123
|
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
|
|
2979
3127
|
|
|
2980
3128
|
|
|
2981
3129
|
|
|
@@ -3045,6 +3193,9 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3045
3193
|
|
|
3046
3194
|
|
|
3047
3195
|
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3048
3199
|
|
|
3049
3200
|
|
|
3050
3201
|
|
|
@@ -3152,55 +3303,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
3152
3303
|
}
|
|
3153
3304
|
};
|
|
3154
3305
|
|
|
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
3306
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3205
3307
|
var IterableEntryBase = class {
|
|
3206
3308
|
static {
|
|
@@ -3418,7 +3520,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3418
3520
|
[k, v] = toEntryFn(item);
|
|
3419
3521
|
} else {
|
|
3420
3522
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3421
|
-
|
|
3523
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3422
3524
|
}
|
|
3423
3525
|
[k, v] = item;
|
|
3424
3526
|
}
|
|
@@ -3431,7 +3533,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3431
3533
|
static createDefaultComparator() {
|
|
3432
3534
|
return (a, b) => {
|
|
3433
3535
|
if (typeof a === "number" && typeof b === "number") {
|
|
3434
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3536
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3435
3537
|
return a - b;
|
|
3436
3538
|
}
|
|
3437
3539
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3439,13 +3541,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3439
3541
|
}
|
|
3440
3542
|
if (a instanceof Date && b instanceof Date) {
|
|
3441
3543
|
const ta = a.getTime(), tb = b.getTime();
|
|
3442
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3544
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3443
3545
|
return ta - tb;
|
|
3444
3546
|
}
|
|
3445
3547
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3446
3548
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3447
3549
|
}
|
|
3448
|
-
|
|
3550
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3449
3551
|
};
|
|
3450
3552
|
}
|
|
3451
3553
|
// ─── Internal state ──────────────────────────────────────────
|
|
@@ -3494,6 +3596,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3494
3596
|
|
|
3495
3597
|
|
|
3496
3598
|
|
|
3599
|
+
|
|
3600
|
+
|
|
3601
|
+
|
|
3497
3602
|
|
|
3498
3603
|
|
|
3499
3604
|
|
|
@@ -3533,6 +3638,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3533
3638
|
|
|
3534
3639
|
|
|
3535
3640
|
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3536
3644
|
|
|
3537
3645
|
|
|
3538
3646
|
|
|
@@ -3575,6 +3683,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3575
3683
|
|
|
3576
3684
|
|
|
3577
3685
|
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
|
|
3578
3689
|
|
|
3579
3690
|
|
|
3580
3691
|
|
|
@@ -3625,6 +3736,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3625
3736
|
|
|
3626
3737
|
|
|
3627
3738
|
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3628
3742
|
|
|
3629
3743
|
|
|
3630
3744
|
|
|
@@ -3700,6 +3814,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3700
3814
|
|
|
3701
3815
|
|
|
3702
3816
|
|
|
3817
|
+
|
|
3818
|
+
|
|
3819
|
+
|
|
3703
3820
|
|
|
3704
3821
|
|
|
3705
3822
|
|
|
@@ -3760,6 +3877,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3760
3877
|
|
|
3761
3878
|
|
|
3762
3879
|
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3763
3883
|
|
|
3764
3884
|
|
|
3765
3885
|
|
|
@@ -3803,6 +3923,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3803
3923
|
|
|
3804
3924
|
|
|
3805
3925
|
|
|
3926
|
+
|
|
3927
|
+
|
|
3928
|
+
|
|
3806
3929
|
|
|
3807
3930
|
|
|
3808
3931
|
|
|
@@ -3866,6 +3989,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3866
3989
|
|
|
3867
3990
|
|
|
3868
3991
|
|
|
3992
|
+
|
|
3993
|
+
|
|
3994
|
+
|
|
3869
3995
|
|
|
3870
3996
|
|
|
3871
3997
|
|
|
@@ -3909,6 +4035,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3909
4035
|
|
|
3910
4036
|
|
|
3911
4037
|
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
3912
4041
|
|
|
3913
4042
|
|
|
3914
4043
|
|
|
@@ -3954,6 +4083,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3954
4083
|
|
|
3955
4084
|
|
|
3956
4085
|
|
|
4086
|
+
|
|
4087
|
+
|
|
4088
|
+
|
|
3957
4089
|
|
|
3958
4090
|
|
|
3959
4091
|
|
|
@@ -3997,6 +4129,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3997
4129
|
|
|
3998
4130
|
|
|
3999
4131
|
|
|
4132
|
+
|
|
4133
|
+
|
|
4134
|
+
|
|
4000
4135
|
|
|
4001
4136
|
|
|
4002
4137
|
|
|
@@ -4043,6 +4178,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4043
4178
|
|
|
4044
4179
|
|
|
4045
4180
|
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4046
4184
|
|
|
4047
4185
|
|
|
4048
4186
|
|
|
@@ -4094,6 +4232,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4094
4232
|
|
|
4095
4233
|
|
|
4096
4234
|
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4097
4238
|
|
|
4098
4239
|
|
|
4099
4240
|
|
|
@@ -4143,6 +4284,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4143
4284
|
|
|
4144
4285
|
|
|
4145
4286
|
|
|
4287
|
+
|
|
4288
|
+
|
|
4289
|
+
|
|
4146
4290
|
|
|
4147
4291
|
|
|
4148
4292
|
|
|
@@ -4191,6 +4335,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4191
4335
|
|
|
4192
4336
|
|
|
4193
4337
|
|
|
4338
|
+
|
|
4339
|
+
|
|
4340
|
+
|
|
4194
4341
|
|
|
4195
4342
|
|
|
4196
4343
|
|
|
@@ -4245,6 +4392,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4245
4392
|
|
|
4246
4393
|
|
|
4247
4394
|
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
|
|
4248
4398
|
|
|
4249
4399
|
|
|
4250
4400
|
|
|
@@ -4307,6 +4457,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4307
4457
|
|
|
4308
4458
|
|
|
4309
4459
|
|
|
4460
|
+
|
|
4461
|
+
|
|
4462
|
+
|
|
4310
4463
|
|
|
4311
4464
|
|
|
4312
4465
|
|
|
@@ -4353,6 +4506,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4353
4506
|
|
|
4354
4507
|
|
|
4355
4508
|
|
|
4509
|
+
|
|
4510
|
+
|
|
4511
|
+
|
|
4356
4512
|
|
|
4357
4513
|
|
|
4358
4514
|
|
|
@@ -4443,5 +4599,6 @@ exports.SinglyLinkedList = SinglyLinkedList;
|
|
|
4443
4599
|
exports.SinglyLinkedListNode = SinglyLinkedListNode;
|
|
4444
4600
|
exports.SkipList = SkipList;
|
|
4445
4601
|
exports.SkipListNode = SkipListNode;
|
|
4602
|
+
exports.raise = raise;
|
|
4446
4603
|
//# sourceMappingURL=index.cjs.map
|
|
4447
4604
|
//# sourceMappingURL=index.cjs.map
|