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
|
@@ -10,6 +10,60 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
10
10
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
11
11
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
12
12
|
|
|
13
|
+
// src/common/error.ts
|
|
14
|
+
function raise(ErrorClass, message) {
|
|
15
|
+
throw new ErrorClass(message);
|
|
16
|
+
}
|
|
17
|
+
__name(raise, "raise");
|
|
18
|
+
var ERR = {
|
|
19
|
+
// Range / index
|
|
20
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
21
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
22
|
+
// Type / argument
|
|
23
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
24
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
25
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
26
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
27
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
28
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
29
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
30
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
31
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
32
|
+
// State / operation
|
|
33
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
34
|
+
// Matrix
|
|
35
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
36
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
37
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
38
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
39
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
40
|
+
// Order statistic
|
|
41
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/common/index.ts
|
|
45
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
46
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
47
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
48
|
+
return DFSOperation2;
|
|
49
|
+
})(DFSOperation || {});
|
|
50
|
+
var _Range = class _Range {
|
|
51
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
52
|
+
this.low = low;
|
|
53
|
+
this.high = high;
|
|
54
|
+
this.includeLow = includeLow;
|
|
55
|
+
this.includeHigh = includeHigh;
|
|
56
|
+
}
|
|
57
|
+
// Determine whether a key is within the range
|
|
58
|
+
isInRange(key, comparator) {
|
|
59
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
60
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
61
|
+
return lowCheck && highCheck;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
__name(_Range, "Range");
|
|
65
|
+
var Range = _Range;
|
|
66
|
+
|
|
13
67
|
// src/data-structures/base/iterable-element-base.ts
|
|
14
68
|
var _IterableElementBase = class _IterableElementBase {
|
|
15
69
|
/**
|
|
@@ -32,7 +86,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
32
86
|
if (options) {
|
|
33
87
|
const { toElementFn } = options;
|
|
34
88
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
35
|
-
else if (toElementFn)
|
|
89
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
36
90
|
}
|
|
37
91
|
}
|
|
38
92
|
/**
|
|
@@ -188,7 +242,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
188
242
|
acc = initialValue;
|
|
189
243
|
} else {
|
|
190
244
|
const first = iter.next();
|
|
191
|
-
if (first.done)
|
|
245
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
192
246
|
acc = first.value;
|
|
193
247
|
index = 1;
|
|
194
248
|
}
|
|
@@ -758,6 +812,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
758
812
|
|
|
759
813
|
|
|
760
814
|
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
761
818
|
|
|
762
819
|
|
|
763
820
|
|
|
@@ -822,6 +879,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
822
879
|
|
|
823
880
|
|
|
824
881
|
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
825
885
|
|
|
826
886
|
|
|
827
887
|
|
|
@@ -892,6 +952,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
892
952
|
|
|
893
953
|
|
|
894
954
|
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
895
958
|
|
|
896
959
|
|
|
897
960
|
|
|
@@ -943,6 +1006,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
943
1006
|
|
|
944
1007
|
|
|
945
1008
|
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
946
1012
|
|
|
947
1013
|
|
|
948
1014
|
|
|
@@ -1055,6 +1121,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1055
1121
|
|
|
1056
1122
|
|
|
1057
1123
|
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1058
1127
|
|
|
1059
1128
|
|
|
1060
1129
|
|
|
@@ -1111,6 +1180,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1111
1180
|
|
|
1112
1181
|
|
|
1113
1182
|
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1114
1186
|
|
|
1115
1187
|
|
|
1116
1188
|
|
|
@@ -1156,6 +1228,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1156
1228
|
|
|
1157
1229
|
|
|
1158
1230
|
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
|
|
1159
1234
|
|
|
1160
1235
|
|
|
1161
1236
|
|
|
@@ -1207,6 +1282,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1207
1282
|
|
|
1208
1283
|
|
|
1209
1284
|
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
|
|
1210
1288
|
|
|
1211
1289
|
|
|
1212
1290
|
|
|
@@ -1263,6 +1341,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1263
1341
|
|
|
1264
1342
|
|
|
1265
1343
|
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1266
1347
|
|
|
1267
1348
|
|
|
1268
1349
|
|
|
@@ -1327,6 +1408,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1327
1408
|
|
|
1328
1409
|
|
|
1329
1410
|
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1330
1414
|
|
|
1331
1415
|
|
|
1332
1416
|
|
|
@@ -1368,6 +1452,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1368
1452
|
|
|
1369
1453
|
|
|
1370
1454
|
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1371
1458
|
|
|
1372
1459
|
|
|
1373
1460
|
|
|
@@ -1415,6 +1502,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1415
1502
|
|
|
1416
1503
|
|
|
1417
1504
|
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1418
1508
|
|
|
1419
1509
|
|
|
1420
1510
|
|
|
@@ -1628,6 +1718,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1628
1718
|
|
|
1629
1719
|
|
|
1630
1720
|
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
|
|
1631
1724
|
|
|
1632
1725
|
|
|
1633
1726
|
|
|
@@ -1679,6 +1772,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1679
1772
|
|
|
1680
1773
|
|
|
1681
1774
|
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1682
1778
|
|
|
1683
1779
|
|
|
1684
1780
|
|
|
@@ -1758,6 +1854,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1758
1854
|
|
|
1759
1855
|
|
|
1760
1856
|
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
|
|
1761
1860
|
|
|
1762
1861
|
|
|
1763
1862
|
|
|
@@ -2075,6 +2174,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2075
2174
|
|
|
2076
2175
|
|
|
2077
2176
|
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2078
2180
|
|
|
2079
2181
|
|
|
2080
2182
|
|
|
@@ -2141,6 +2243,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2141
2243
|
|
|
2142
2244
|
|
|
2143
2245
|
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2144
2249
|
|
|
2145
2250
|
|
|
2146
2251
|
|
|
@@ -2206,6 +2311,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2206
2311
|
|
|
2207
2312
|
|
|
2208
2313
|
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2209
2317
|
|
|
2210
2318
|
|
|
2211
2319
|
|
|
@@ -2262,6 +2370,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2262
2370
|
|
|
2263
2371
|
|
|
2264
2372
|
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2265
2376
|
|
|
2266
2377
|
|
|
2267
2378
|
|
|
@@ -2347,6 +2458,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2347
2458
|
|
|
2348
2459
|
|
|
2349
2460
|
|
|
2461
|
+
|
|
2462
|
+
|
|
2463
|
+
|
|
2350
2464
|
|
|
2351
2465
|
|
|
2352
2466
|
|
|
@@ -2393,6 +2507,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2393
2507
|
|
|
2394
2508
|
|
|
2395
2509
|
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
|
|
2396
2513
|
|
|
2397
2514
|
|
|
2398
2515
|
|
|
@@ -2470,6 +2587,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2470
2587
|
|
|
2471
2588
|
|
|
2472
2589
|
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2473
2593
|
|
|
2474
2594
|
|
|
2475
2595
|
|
|
@@ -2575,6 +2695,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2575
2695
|
|
|
2576
2696
|
|
|
2577
2697
|
|
|
2698
|
+
|
|
2699
|
+
|
|
2700
|
+
|
|
2578
2701
|
|
|
2579
2702
|
|
|
2580
2703
|
|
|
@@ -2627,6 +2750,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2627
2750
|
|
|
2628
2751
|
|
|
2629
2752
|
|
|
2753
|
+
|
|
2754
|
+
|
|
2755
|
+
|
|
2630
2756
|
|
|
2631
2757
|
|
|
2632
2758
|
|
|
@@ -2681,6 +2807,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2681
2807
|
|
|
2682
2808
|
|
|
2683
2809
|
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
|
|
2684
2813
|
|
|
2685
2814
|
|
|
2686
2815
|
|
|
@@ -2722,6 +2851,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2722
2851
|
|
|
2723
2852
|
|
|
2724
2853
|
|
|
2854
|
+
|
|
2855
|
+
|
|
2856
|
+
|
|
2725
2857
|
|
|
2726
2858
|
|
|
2727
2859
|
|
|
@@ -2767,6 +2899,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2767
2899
|
|
|
2768
2900
|
|
|
2769
2901
|
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
|
|
2770
2905
|
|
|
2771
2906
|
|
|
2772
2907
|
|
|
@@ -2816,6 +2951,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2816
2951
|
|
|
2817
2952
|
|
|
2818
2953
|
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2819
2957
|
|
|
2820
2958
|
|
|
2821
2959
|
|
|
@@ -2868,6 +3006,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2868
3006
|
|
|
2869
3007
|
|
|
2870
3008
|
|
|
3009
|
+
|
|
3010
|
+
|
|
3011
|
+
|
|
2871
3012
|
|
|
2872
3013
|
|
|
2873
3014
|
|
|
@@ -2928,6 +3069,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2928
3069
|
|
|
2929
3070
|
|
|
2930
3071
|
|
|
3072
|
+
|
|
3073
|
+
|
|
3074
|
+
|
|
2931
3075
|
|
|
2932
3076
|
|
|
2933
3077
|
|
|
@@ -2978,6 +3122,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2978
3122
|
|
|
2979
3123
|
|
|
2980
3124
|
|
|
3125
|
+
|
|
3126
|
+
|
|
3127
|
+
|
|
2981
3128
|
|
|
2982
3129
|
|
|
2983
3130
|
|
|
@@ -3047,6 +3194,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3047
3194
|
|
|
3048
3195
|
|
|
3049
3196
|
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3050
3200
|
|
|
3051
3201
|
|
|
3052
3202
|
|
|
@@ -3156,54 +3306,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3156
3306
|
__name(_DoublyLinkedList, "DoublyLinkedList");
|
|
3157
3307
|
var DoublyLinkedList = _DoublyLinkedList;
|
|
3158
3308
|
|
|
3159
|
-
// src/common/error.ts
|
|
3160
|
-
var ERR = {
|
|
3161
|
-
// Range / index
|
|
3162
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
3163
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
3164
|
-
// Type / argument
|
|
3165
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
3166
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
3167
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
3168
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
3169
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
3170
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
3171
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
3172
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
3173
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
3174
|
-
// State / operation
|
|
3175
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
3176
|
-
// Matrix
|
|
3177
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
3178
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
3179
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
3180
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
3181
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
3182
|
-
};
|
|
3183
|
-
|
|
3184
|
-
// src/common/index.ts
|
|
3185
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
3186
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
3187
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
3188
|
-
return DFSOperation2;
|
|
3189
|
-
})(DFSOperation || {});
|
|
3190
|
-
var _Range = class _Range {
|
|
3191
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
3192
|
-
this.low = low;
|
|
3193
|
-
this.high = high;
|
|
3194
|
-
this.includeLow = includeLow;
|
|
3195
|
-
this.includeHigh = includeHigh;
|
|
3196
|
-
}
|
|
3197
|
-
// Determine whether a key is within the range
|
|
3198
|
-
isInRange(key, comparator) {
|
|
3199
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
3200
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
3201
|
-
return lowCheck && highCheck;
|
|
3202
|
-
}
|
|
3203
|
-
};
|
|
3204
|
-
__name(_Range, "Range");
|
|
3205
|
-
var Range = _Range;
|
|
3206
|
-
|
|
3207
3309
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3208
3310
|
var _IterableEntryBase = class _IterableEntryBase {
|
|
3209
3311
|
/**
|
|
@@ -3423,7 +3525,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3423
3525
|
[k, v] = toEntryFn(item);
|
|
3424
3526
|
} else {
|
|
3425
3527
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3426
|
-
|
|
3528
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3427
3529
|
}
|
|
3428
3530
|
[k, v] = item;
|
|
3429
3531
|
}
|
|
@@ -3436,7 +3538,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3436
3538
|
static createDefaultComparator() {
|
|
3437
3539
|
return (a, b) => {
|
|
3438
3540
|
if (typeof a === "number" && typeof b === "number") {
|
|
3439
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3541
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3440
3542
|
return a - b;
|
|
3441
3543
|
}
|
|
3442
3544
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3444,13 +3546,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3444
3546
|
}
|
|
3445
3547
|
if (a instanceof Date && b instanceof Date) {
|
|
3446
3548
|
const ta = a.getTime(), tb = b.getTime();
|
|
3447
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3549
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3448
3550
|
return ta - tb;
|
|
3449
3551
|
}
|
|
3450
3552
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3451
3553
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3452
3554
|
}
|
|
3453
|
-
|
|
3555
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3454
3556
|
};
|
|
3455
3557
|
}
|
|
3456
3558
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -3493,6 +3595,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3493
3595
|
|
|
3494
3596
|
|
|
3495
3597
|
|
|
3598
|
+
|
|
3599
|
+
|
|
3600
|
+
|
|
3496
3601
|
|
|
3497
3602
|
|
|
3498
3603
|
|
|
@@ -3532,6 +3637,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3532
3637
|
|
|
3533
3638
|
|
|
3534
3639
|
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
|
|
3535
3643
|
|
|
3536
3644
|
|
|
3537
3645
|
|
|
@@ -3574,6 +3682,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3574
3682
|
|
|
3575
3683
|
|
|
3576
3684
|
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
|
|
3577
3688
|
|
|
3578
3689
|
|
|
3579
3690
|
|
|
@@ -3624,6 +3735,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3624
3735
|
|
|
3625
3736
|
|
|
3626
3737
|
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3627
3741
|
|
|
3628
3742
|
|
|
3629
3743
|
|
|
@@ -3699,6 +3813,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3699
3813
|
|
|
3700
3814
|
|
|
3701
3815
|
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
|
|
3702
3819
|
|
|
3703
3820
|
|
|
3704
3821
|
|
|
@@ -3759,6 +3876,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3759
3876
|
|
|
3760
3877
|
|
|
3761
3878
|
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3762
3882
|
|
|
3763
3883
|
|
|
3764
3884
|
|
|
@@ -3802,6 +3922,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3802
3922
|
|
|
3803
3923
|
|
|
3804
3924
|
|
|
3925
|
+
|
|
3926
|
+
|
|
3927
|
+
|
|
3805
3928
|
|
|
3806
3929
|
|
|
3807
3930
|
|
|
@@ -3865,6 +3988,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3865
3988
|
|
|
3866
3989
|
|
|
3867
3990
|
|
|
3991
|
+
|
|
3992
|
+
|
|
3993
|
+
|
|
3868
3994
|
|
|
3869
3995
|
|
|
3870
3996
|
|
|
@@ -3908,6 +4034,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3908
4034
|
|
|
3909
4035
|
|
|
3910
4036
|
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
3911
4040
|
|
|
3912
4041
|
|
|
3913
4042
|
|
|
@@ -3953,6 +4082,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3953
4082
|
|
|
3954
4083
|
|
|
3955
4084
|
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
3956
4088
|
|
|
3957
4089
|
|
|
3958
4090
|
|
|
@@ -3996,6 +4128,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3996
4128
|
|
|
3997
4129
|
|
|
3998
4130
|
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
|
|
3999
4134
|
|
|
4000
4135
|
|
|
4001
4136
|
|
|
@@ -4042,6 +4177,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4042
4177
|
|
|
4043
4178
|
|
|
4044
4179
|
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4045
4183
|
|
|
4046
4184
|
|
|
4047
4185
|
|
|
@@ -4093,6 +4231,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4093
4231
|
|
|
4094
4232
|
|
|
4095
4233
|
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4096
4237
|
|
|
4097
4238
|
|
|
4098
4239
|
|
|
@@ -4142,6 +4283,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4142
4283
|
|
|
4143
4284
|
|
|
4144
4285
|
|
|
4286
|
+
|
|
4287
|
+
|
|
4288
|
+
|
|
4145
4289
|
|
|
4146
4290
|
|
|
4147
4291
|
|
|
@@ -4190,6 +4334,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4190
4334
|
|
|
4191
4335
|
|
|
4192
4336
|
|
|
4337
|
+
|
|
4338
|
+
|
|
4339
|
+
|
|
4193
4340
|
|
|
4194
4341
|
|
|
4195
4342
|
|
|
@@ -4244,6 +4391,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4244
4391
|
|
|
4245
4392
|
|
|
4246
4393
|
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
|
|
4247
4397
|
|
|
4248
4398
|
|
|
4249
4399
|
|
|
@@ -4306,6 +4456,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4306
4456
|
|
|
4307
4457
|
|
|
4308
4458
|
|
|
4459
|
+
|
|
4460
|
+
|
|
4461
|
+
|
|
4309
4462
|
|
|
4310
4463
|
|
|
4311
4464
|
|
|
@@ -4352,6 +4505,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4352
4505
|
|
|
4353
4506
|
|
|
4354
4507
|
|
|
4508
|
+
|
|
4509
|
+
|
|
4510
|
+
|
|
4355
4511
|
|
|
4356
4512
|
|
|
4357
4513
|
|
|
@@ -4437,6 +4593,6 @@ var SkipList = _SkipList;
|
|
|
4437
4593
|
* @license MIT License
|
|
4438
4594
|
*/
|
|
4439
4595
|
|
|
4440
|
-
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode };
|
|
4596
|
+
export { DFSOperation, DoublyLinkedList, DoublyLinkedListNode, ERR, Range, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, raise };
|
|
4441
4597
|
//# sourceMappingURL=index.mjs.map
|
|
4442
4598
|
//# sourceMappingURL=index.mjs.map
|