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
|
@@ -12,6 +12,60 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
12
12
|
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);
|
|
13
13
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
14
14
|
|
|
15
|
+
// src/common/error.ts
|
|
16
|
+
function raise(ErrorClass, message) {
|
|
17
|
+
throw new ErrorClass(message);
|
|
18
|
+
}
|
|
19
|
+
__name(raise, "raise");
|
|
20
|
+
var ERR = {
|
|
21
|
+
// Range / index
|
|
22
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
23
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
24
|
+
// Type / argument
|
|
25
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
26
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
27
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
28
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
29
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
30
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
31
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
32
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
33
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
34
|
+
// State / operation
|
|
35
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
36
|
+
// Matrix
|
|
37
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
38
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
39
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
40
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
41
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
42
|
+
// Order statistic
|
|
43
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/common/index.ts
|
|
47
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
48
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
49
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
50
|
+
return DFSOperation2;
|
|
51
|
+
})(DFSOperation || {});
|
|
52
|
+
var _Range = class _Range {
|
|
53
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
54
|
+
this.low = low;
|
|
55
|
+
this.high = high;
|
|
56
|
+
this.includeLow = includeLow;
|
|
57
|
+
this.includeHigh = includeHigh;
|
|
58
|
+
}
|
|
59
|
+
// Determine whether a key is within the range
|
|
60
|
+
isInRange(key, comparator) {
|
|
61
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
62
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
63
|
+
return lowCheck && highCheck;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__name(_Range, "Range");
|
|
67
|
+
var Range = _Range;
|
|
68
|
+
|
|
15
69
|
// src/data-structures/base/iterable-element-base.ts
|
|
16
70
|
var _IterableElementBase = class _IterableElementBase {
|
|
17
71
|
/**
|
|
@@ -34,7 +88,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
34
88
|
if (options) {
|
|
35
89
|
const { toElementFn } = options;
|
|
36
90
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
37
|
-
else if (toElementFn)
|
|
91
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
38
92
|
}
|
|
39
93
|
}
|
|
40
94
|
/**
|
|
@@ -190,7 +244,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
190
244
|
acc = initialValue;
|
|
191
245
|
} else {
|
|
192
246
|
const first = iter.next();
|
|
193
|
-
if (first.done)
|
|
247
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
194
248
|
acc = first.value;
|
|
195
249
|
index = 1;
|
|
196
250
|
}
|
|
@@ -760,6 +814,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
760
814
|
|
|
761
815
|
|
|
762
816
|
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
763
820
|
|
|
764
821
|
|
|
765
822
|
|
|
@@ -824,6 +881,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
824
881
|
|
|
825
882
|
|
|
826
883
|
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
827
887
|
|
|
828
888
|
|
|
829
889
|
|
|
@@ -894,6 +954,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
894
954
|
|
|
895
955
|
|
|
896
956
|
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
897
960
|
|
|
898
961
|
|
|
899
962
|
|
|
@@ -945,6 +1008,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
945
1008
|
|
|
946
1009
|
|
|
947
1010
|
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
948
1014
|
|
|
949
1015
|
|
|
950
1016
|
|
|
@@ -1057,6 +1123,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1057
1123
|
|
|
1058
1124
|
|
|
1059
1125
|
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1060
1129
|
|
|
1061
1130
|
|
|
1062
1131
|
|
|
@@ -1113,6 +1182,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1113
1182
|
|
|
1114
1183
|
|
|
1115
1184
|
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1116
1188
|
|
|
1117
1189
|
|
|
1118
1190
|
|
|
@@ -1158,6 +1230,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1158
1230
|
|
|
1159
1231
|
|
|
1160
1232
|
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1161
1236
|
|
|
1162
1237
|
|
|
1163
1238
|
|
|
@@ -1209,6 +1284,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1209
1284
|
|
|
1210
1285
|
|
|
1211
1286
|
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1212
1290
|
|
|
1213
1291
|
|
|
1214
1292
|
|
|
@@ -1265,6 +1343,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1265
1343
|
|
|
1266
1344
|
|
|
1267
1345
|
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1268
1349
|
|
|
1269
1350
|
|
|
1270
1351
|
|
|
@@ -1329,6 +1410,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1329
1410
|
|
|
1330
1411
|
|
|
1331
1412
|
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1332
1416
|
|
|
1333
1417
|
|
|
1334
1418
|
|
|
@@ -1370,6 +1454,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1370
1454
|
|
|
1371
1455
|
|
|
1372
1456
|
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1373
1460
|
|
|
1374
1461
|
|
|
1375
1462
|
|
|
@@ -1417,6 +1504,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1417
1504
|
|
|
1418
1505
|
|
|
1419
1506
|
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1420
1510
|
|
|
1421
1511
|
|
|
1422
1512
|
|
|
@@ -1630,6 +1720,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1630
1720
|
|
|
1631
1721
|
|
|
1632
1722
|
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
|
|
1633
1726
|
|
|
1634
1727
|
|
|
1635
1728
|
|
|
@@ -1681,6 +1774,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1681
1774
|
|
|
1682
1775
|
|
|
1683
1776
|
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1684
1780
|
|
|
1685
1781
|
|
|
1686
1782
|
|
|
@@ -1760,6 +1856,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1760
1856
|
|
|
1761
1857
|
|
|
1762
1858
|
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1763
1862
|
|
|
1764
1863
|
|
|
1765
1864
|
|
|
@@ -2077,6 +2176,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2077
2176
|
|
|
2078
2177
|
|
|
2079
2178
|
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2080
2182
|
|
|
2081
2183
|
|
|
2082
2184
|
|
|
@@ -2143,6 +2245,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2143
2245
|
|
|
2144
2246
|
|
|
2145
2247
|
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2146
2251
|
|
|
2147
2252
|
|
|
2148
2253
|
|
|
@@ -2208,6 +2313,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2208
2313
|
|
|
2209
2314
|
|
|
2210
2315
|
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2211
2319
|
|
|
2212
2320
|
|
|
2213
2321
|
|
|
@@ -2264,6 +2372,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2264
2372
|
|
|
2265
2373
|
|
|
2266
2374
|
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2267
2378
|
|
|
2268
2379
|
|
|
2269
2380
|
|
|
@@ -2349,6 +2460,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2349
2460
|
|
|
2350
2461
|
|
|
2351
2462
|
|
|
2463
|
+
|
|
2464
|
+
|
|
2465
|
+
|
|
2352
2466
|
|
|
2353
2467
|
|
|
2354
2468
|
|
|
@@ -2395,6 +2509,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2395
2509
|
|
|
2396
2510
|
|
|
2397
2511
|
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
|
|
2398
2515
|
|
|
2399
2516
|
|
|
2400
2517
|
|
|
@@ -2472,6 +2589,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2472
2589
|
|
|
2473
2590
|
|
|
2474
2591
|
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2475
2595
|
|
|
2476
2596
|
|
|
2477
2597
|
|
|
@@ -2577,6 +2697,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2577
2697
|
|
|
2578
2698
|
|
|
2579
2699
|
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2580
2703
|
|
|
2581
2704
|
|
|
2582
2705
|
|
|
@@ -2629,6 +2752,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2629
2752
|
|
|
2630
2753
|
|
|
2631
2754
|
|
|
2755
|
+
|
|
2756
|
+
|
|
2757
|
+
|
|
2632
2758
|
|
|
2633
2759
|
|
|
2634
2760
|
|
|
@@ -2683,6 +2809,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2683
2809
|
|
|
2684
2810
|
|
|
2685
2811
|
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
|
|
2686
2815
|
|
|
2687
2816
|
|
|
2688
2817
|
|
|
@@ -2724,6 +2853,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2724
2853
|
|
|
2725
2854
|
|
|
2726
2855
|
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
|
|
2727
2859
|
|
|
2728
2860
|
|
|
2729
2861
|
|
|
@@ -2769,6 +2901,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2769
2901
|
|
|
2770
2902
|
|
|
2771
2903
|
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
|
|
2772
2907
|
|
|
2773
2908
|
|
|
2774
2909
|
|
|
@@ -2818,6 +2953,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2818
2953
|
|
|
2819
2954
|
|
|
2820
2955
|
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2821
2959
|
|
|
2822
2960
|
|
|
2823
2961
|
|
|
@@ -2870,6 +3008,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2870
3008
|
|
|
2871
3009
|
|
|
2872
3010
|
|
|
3011
|
+
|
|
3012
|
+
|
|
3013
|
+
|
|
2873
3014
|
|
|
2874
3015
|
|
|
2875
3016
|
|
|
@@ -2930,6 +3071,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2930
3071
|
|
|
2931
3072
|
|
|
2932
3073
|
|
|
3074
|
+
|
|
3075
|
+
|
|
3076
|
+
|
|
2933
3077
|
|
|
2934
3078
|
|
|
2935
3079
|
|
|
@@ -2980,6 +3124,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2980
3124
|
|
|
2981
3125
|
|
|
2982
3126
|
|
|
3127
|
+
|
|
3128
|
+
|
|
3129
|
+
|
|
2983
3130
|
|
|
2984
3131
|
|
|
2985
3132
|
|
|
@@ -3049,6 +3196,9 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3049
3196
|
|
|
3050
3197
|
|
|
3051
3198
|
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3052
3202
|
|
|
3053
3203
|
|
|
3054
3204
|
|
|
@@ -3158,54 +3308,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3158
3308
|
__name(_DoublyLinkedList, "DoublyLinkedList");
|
|
3159
3309
|
var DoublyLinkedList = _DoublyLinkedList;
|
|
3160
3310
|
|
|
3161
|
-
// src/common/error.ts
|
|
3162
|
-
var ERR = {
|
|
3163
|
-
// Range / index
|
|
3164
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
3165
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
3166
|
-
// Type / argument
|
|
3167
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
3168
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
3169
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
3170
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
3171
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
3172
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
3173
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
3174
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
3175
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
3176
|
-
// State / operation
|
|
3177
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
3178
|
-
// Matrix
|
|
3179
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
3180
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
3181
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
3182
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
3183
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
3184
|
-
};
|
|
3185
|
-
|
|
3186
|
-
// src/common/index.ts
|
|
3187
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
3188
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
3189
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
3190
|
-
return DFSOperation2;
|
|
3191
|
-
})(DFSOperation || {});
|
|
3192
|
-
var _Range = class _Range {
|
|
3193
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
3194
|
-
this.low = low;
|
|
3195
|
-
this.high = high;
|
|
3196
|
-
this.includeLow = includeLow;
|
|
3197
|
-
this.includeHigh = includeHigh;
|
|
3198
|
-
}
|
|
3199
|
-
// Determine whether a key is within the range
|
|
3200
|
-
isInRange(key, comparator) {
|
|
3201
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
3202
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
3203
|
-
return lowCheck && highCheck;
|
|
3204
|
-
}
|
|
3205
|
-
};
|
|
3206
|
-
__name(_Range, "Range");
|
|
3207
|
-
var Range = _Range;
|
|
3208
|
-
|
|
3209
3311
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3210
3312
|
var _IterableEntryBase = class _IterableEntryBase {
|
|
3211
3313
|
/**
|
|
@@ -3425,7 +3527,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3425
3527
|
[k, v] = toEntryFn(item);
|
|
3426
3528
|
} else {
|
|
3427
3529
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3428
|
-
|
|
3530
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3429
3531
|
}
|
|
3430
3532
|
[k, v] = item;
|
|
3431
3533
|
}
|
|
@@ -3438,7 +3540,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3438
3540
|
static createDefaultComparator() {
|
|
3439
3541
|
return (a, b) => {
|
|
3440
3542
|
if (typeof a === "number" && typeof b === "number") {
|
|
3441
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3543
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3442
3544
|
return a - b;
|
|
3443
3545
|
}
|
|
3444
3546
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3446,13 +3548,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3446
3548
|
}
|
|
3447
3549
|
if (a instanceof Date && b instanceof Date) {
|
|
3448
3550
|
const ta = a.getTime(), tb = b.getTime();
|
|
3449
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3551
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3450
3552
|
return ta - tb;
|
|
3451
3553
|
}
|
|
3452
3554
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3453
3555
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3454
3556
|
}
|
|
3455
|
-
|
|
3557
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3456
3558
|
};
|
|
3457
3559
|
}
|
|
3458
3560
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -3495,6 +3597,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3495
3597
|
|
|
3496
3598
|
|
|
3497
3599
|
|
|
3600
|
+
|
|
3601
|
+
|
|
3602
|
+
|
|
3498
3603
|
|
|
3499
3604
|
|
|
3500
3605
|
|
|
@@ -3534,6 +3639,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3534
3639
|
|
|
3535
3640
|
|
|
3536
3641
|
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3537
3645
|
|
|
3538
3646
|
|
|
3539
3647
|
|
|
@@ -3576,6 +3684,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3576
3684
|
|
|
3577
3685
|
|
|
3578
3686
|
|
|
3687
|
+
|
|
3688
|
+
|
|
3689
|
+
|
|
3579
3690
|
|
|
3580
3691
|
|
|
3581
3692
|
|
|
@@ -3626,6 +3737,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3626
3737
|
|
|
3627
3738
|
|
|
3628
3739
|
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3629
3743
|
|
|
3630
3744
|
|
|
3631
3745
|
|
|
@@ -3701,6 +3815,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3701
3815
|
|
|
3702
3816
|
|
|
3703
3817
|
|
|
3818
|
+
|
|
3819
|
+
|
|
3820
|
+
|
|
3704
3821
|
|
|
3705
3822
|
|
|
3706
3823
|
|
|
@@ -3761,6 +3878,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3761
3878
|
|
|
3762
3879
|
|
|
3763
3880
|
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3764
3884
|
|
|
3765
3885
|
|
|
3766
3886
|
|
|
@@ -3804,6 +3924,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3804
3924
|
|
|
3805
3925
|
|
|
3806
3926
|
|
|
3927
|
+
|
|
3928
|
+
|
|
3929
|
+
|
|
3807
3930
|
|
|
3808
3931
|
|
|
3809
3932
|
|
|
@@ -3867,6 +3990,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3867
3990
|
|
|
3868
3991
|
|
|
3869
3992
|
|
|
3993
|
+
|
|
3994
|
+
|
|
3995
|
+
|
|
3870
3996
|
|
|
3871
3997
|
|
|
3872
3998
|
|
|
@@ -3910,6 +4036,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3910
4036
|
|
|
3911
4037
|
|
|
3912
4038
|
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
3913
4042
|
|
|
3914
4043
|
|
|
3915
4044
|
|
|
@@ -3955,6 +4084,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3955
4084
|
|
|
3956
4085
|
|
|
3957
4086
|
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
|
|
3958
4090
|
|
|
3959
4091
|
|
|
3960
4092
|
|
|
@@ -3998,6 +4130,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3998
4130
|
|
|
3999
4131
|
|
|
4000
4132
|
|
|
4133
|
+
|
|
4134
|
+
|
|
4135
|
+
|
|
4001
4136
|
|
|
4002
4137
|
|
|
4003
4138
|
|
|
@@ -4044,6 +4179,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4044
4179
|
|
|
4045
4180
|
|
|
4046
4181
|
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4047
4185
|
|
|
4048
4186
|
|
|
4049
4187
|
|
|
@@ -4095,6 +4233,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4095
4233
|
|
|
4096
4234
|
|
|
4097
4235
|
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
|
|
4098
4239
|
|
|
4099
4240
|
|
|
4100
4241
|
|
|
@@ -4144,6 +4285,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4144
4285
|
|
|
4145
4286
|
|
|
4146
4287
|
|
|
4288
|
+
|
|
4289
|
+
|
|
4290
|
+
|
|
4147
4291
|
|
|
4148
4292
|
|
|
4149
4293
|
|
|
@@ -4192,6 +4336,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4192
4336
|
|
|
4193
4337
|
|
|
4194
4338
|
|
|
4339
|
+
|
|
4340
|
+
|
|
4341
|
+
|
|
4195
4342
|
|
|
4196
4343
|
|
|
4197
4344
|
|
|
@@ -4246,6 +4393,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4246
4393
|
|
|
4247
4394
|
|
|
4248
4395
|
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4249
4399
|
|
|
4250
4400
|
|
|
4251
4401
|
|
|
@@ -4308,6 +4458,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4308
4458
|
|
|
4309
4459
|
|
|
4310
4460
|
|
|
4461
|
+
|
|
4462
|
+
|
|
4463
|
+
|
|
4311
4464
|
|
|
4312
4465
|
|
|
4313
4466
|
|
|
@@ -4354,6 +4507,9 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4354
4507
|
|
|
4355
4508
|
|
|
4356
4509
|
|
|
4510
|
+
|
|
4511
|
+
|
|
4512
|
+
|
|
4357
4513
|
|
|
4358
4514
|
|
|
4359
4515
|
|
|
@@ -4448,5 +4604,6 @@ exports.SinglyLinkedList = SinglyLinkedList;
|
|
|
4448
4604
|
exports.SinglyLinkedListNode = SinglyLinkedListNode;
|
|
4449
4605
|
exports.SkipList = SkipList;
|
|
4450
4606
|
exports.SkipListNode = SkipListNode;
|
|
4607
|
+
exports.raise = raise;
|
|
4451
4608
|
//# sourceMappingURL=index.cjs.map
|
|
4452
4609
|
//# sourceMappingURL=index.cjs.map
|