linked-list-typed 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +431 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +430 -54
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +431 -56
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +430 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/linked-list-typed.js +428 -53
- package/dist/umd/linked-list-typed.js.map +1 -1
- package/dist/umd/linked-list-typed.min.js +1 -1
- package/dist/umd/linked-list-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -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
|
}
|
|
@@ -756,6 +810,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
756
810
|
|
|
757
811
|
|
|
758
812
|
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
759
820
|
|
|
760
821
|
|
|
761
822
|
|
|
@@ -820,6 +881,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
820
881
|
|
|
821
882
|
|
|
822
883
|
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
823
891
|
|
|
824
892
|
|
|
825
893
|
|
|
@@ -890,6 +958,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
890
958
|
|
|
891
959
|
|
|
892
960
|
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
893
968
|
|
|
894
969
|
|
|
895
970
|
|
|
@@ -941,6 +1016,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
941
1016
|
|
|
942
1017
|
|
|
943
1018
|
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
944
1026
|
|
|
945
1027
|
|
|
946
1028
|
|
|
@@ -1053,6 +1135,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1053
1135
|
|
|
1054
1136
|
|
|
1055
1137
|
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
|
|
1056
1145
|
|
|
1057
1146
|
|
|
1058
1147
|
|
|
@@ -1109,6 +1198,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1109
1198
|
|
|
1110
1199
|
|
|
1111
1200
|
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1112
1208
|
|
|
1113
1209
|
|
|
1114
1210
|
|
|
@@ -1154,6 +1250,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1154
1250
|
|
|
1155
1251
|
|
|
1156
1252
|
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1157
1260
|
|
|
1158
1261
|
|
|
1159
1262
|
|
|
@@ -1205,6 +1308,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1205
1308
|
|
|
1206
1309
|
|
|
1207
1310
|
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1208
1318
|
|
|
1209
1319
|
|
|
1210
1320
|
|
|
@@ -1261,6 +1371,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1261
1371
|
|
|
1262
1372
|
|
|
1263
1373
|
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1264
1381
|
|
|
1265
1382
|
|
|
1266
1383
|
|
|
@@ -1325,6 +1442,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1325
1442
|
|
|
1326
1443
|
|
|
1327
1444
|
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1328
1452
|
|
|
1329
1453
|
|
|
1330
1454
|
|
|
@@ -1366,6 +1490,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1366
1490
|
|
|
1367
1491
|
|
|
1368
1492
|
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1369
1500
|
|
|
1370
1501
|
|
|
1371
1502
|
|
|
@@ -1413,6 +1544,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1413
1544
|
|
|
1414
1545
|
|
|
1415
1546
|
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
|
|
1416
1554
|
|
|
1417
1555
|
|
|
1418
1556
|
|
|
@@ -1626,6 +1764,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1626
1764
|
|
|
1627
1765
|
|
|
1628
1766
|
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1629
1774
|
|
|
1630
1775
|
|
|
1631
1776
|
|
|
@@ -1677,6 +1822,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1677
1822
|
|
|
1678
1823
|
|
|
1679
1824
|
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
|
|
1680
1832
|
|
|
1681
1833
|
|
|
1682
1834
|
|
|
@@ -1756,6 +1908,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1756
1908
|
|
|
1757
1909
|
|
|
1758
1910
|
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1759
1918
|
|
|
1760
1919
|
|
|
1761
1920
|
|
|
@@ -2073,6 +2232,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2073
2232
|
|
|
2074
2233
|
|
|
2075
2234
|
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2076
2242
|
|
|
2077
2243
|
|
|
2078
2244
|
|
|
@@ -2139,6 +2305,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2139
2305
|
|
|
2140
2306
|
|
|
2141
2307
|
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2142
2315
|
|
|
2143
2316
|
|
|
2144
2317
|
|
|
@@ -2204,6 +2377,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2204
2377
|
|
|
2205
2378
|
|
|
2206
2379
|
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2207
2387
|
|
|
2208
2388
|
|
|
2209
2389
|
|
|
@@ -2260,6 +2440,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2260
2440
|
|
|
2261
2441
|
|
|
2262
2442
|
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2263
2450
|
|
|
2264
2451
|
|
|
2265
2452
|
|
|
@@ -2345,6 +2532,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2345
2532
|
|
|
2346
2533
|
|
|
2347
2534
|
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2348
2542
|
|
|
2349
2543
|
|
|
2350
2544
|
|
|
@@ -2391,6 +2585,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2391
2585
|
|
|
2392
2586
|
|
|
2393
2587
|
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2394
2595
|
|
|
2395
2596
|
|
|
2396
2597
|
|
|
@@ -2468,6 +2669,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2468
2669
|
|
|
2469
2670
|
|
|
2470
2671
|
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2471
2679
|
|
|
2472
2680
|
|
|
2473
2681
|
|
|
@@ -2573,6 +2781,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2573
2781
|
|
|
2574
2782
|
|
|
2575
2783
|
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
|
|
2790
|
+
|
|
2576
2791
|
|
|
2577
2792
|
|
|
2578
2793
|
|
|
@@ -2625,6 +2840,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2625
2840
|
|
|
2626
2841
|
|
|
2627
2842
|
|
|
2843
|
+
|
|
2844
|
+
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
|
|
2849
|
+
|
|
2628
2850
|
|
|
2629
2851
|
|
|
2630
2852
|
|
|
@@ -2679,6 +2901,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2679
2901
|
|
|
2680
2902
|
|
|
2681
2903
|
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
|
|
2907
|
+
|
|
2908
|
+
|
|
2909
|
+
|
|
2910
|
+
|
|
2682
2911
|
|
|
2683
2912
|
|
|
2684
2913
|
|
|
@@ -2720,6 +2949,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2720
2949
|
|
|
2721
2950
|
|
|
2722
2951
|
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2723
2959
|
|
|
2724
2960
|
|
|
2725
2961
|
|
|
@@ -2765,6 +3001,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2765
3001
|
|
|
2766
3002
|
|
|
2767
3003
|
|
|
3004
|
+
|
|
3005
|
+
|
|
3006
|
+
|
|
3007
|
+
|
|
3008
|
+
|
|
3009
|
+
|
|
3010
|
+
|
|
2768
3011
|
|
|
2769
3012
|
|
|
2770
3013
|
|
|
@@ -2814,6 +3057,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2814
3057
|
|
|
2815
3058
|
|
|
2816
3059
|
|
|
3060
|
+
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
|
|
3064
|
+
|
|
3065
|
+
|
|
3066
|
+
|
|
2817
3067
|
|
|
2818
3068
|
|
|
2819
3069
|
|
|
@@ -2866,6 +3116,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2866
3116
|
|
|
2867
3117
|
|
|
2868
3118
|
|
|
3119
|
+
|
|
3120
|
+
|
|
3121
|
+
|
|
3122
|
+
|
|
3123
|
+
|
|
3124
|
+
|
|
3125
|
+
|
|
2869
3126
|
|
|
2870
3127
|
|
|
2871
3128
|
|
|
@@ -2890,6 +3147,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2890
3147
|
}
|
|
2891
3148
|
return this;
|
|
2892
3149
|
}
|
|
3150
|
+
/**
|
|
3151
|
+
* Delete the first element that satisfies a predicate.
|
|
3152
|
+
* @remarks Time O(N), Space O(1)
|
|
3153
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3154
|
+
* @returns True if a match was removed.
|
|
3155
|
+
*/
|
|
3156
|
+
deleteWhere(predicate) {
|
|
3157
|
+
let current = this.head;
|
|
3158
|
+
let index = 0;
|
|
3159
|
+
while (current) {
|
|
3160
|
+
if (predicate(current.value, index, this)) {
|
|
3161
|
+
this.delete(current);
|
|
3162
|
+
return true;
|
|
3163
|
+
}
|
|
3164
|
+
current = current.next;
|
|
3165
|
+
index++;
|
|
3166
|
+
}
|
|
3167
|
+
return false;
|
|
3168
|
+
}
|
|
2893
3169
|
/**
|
|
2894
3170
|
* Set the equality comparator used to compare values.
|
|
2895
3171
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2926,6 +3202,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2926
3202
|
|
|
2927
3203
|
|
|
2928
3204
|
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
2929
3212
|
|
|
2930
3213
|
|
|
2931
3214
|
|
|
@@ -2976,6 +3259,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2976
3259
|
|
|
2977
3260
|
|
|
2978
3261
|
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
|
|
2979
3269
|
|
|
2980
3270
|
|
|
2981
3271
|
|
|
@@ -3045,6 +3335,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3045
3335
|
|
|
3046
3336
|
|
|
3047
3337
|
|
|
3338
|
+
|
|
3339
|
+
|
|
3340
|
+
|
|
3341
|
+
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
|
|
3048
3345
|
|
|
3049
3346
|
|
|
3050
3347
|
|
|
@@ -3158,54 +3455,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3158
3455
|
__name(_DoublyLinkedList, "DoublyLinkedList");
|
|
3159
3456
|
var DoublyLinkedList = _DoublyLinkedList;
|
|
3160
3457
|
|
|
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
3458
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3210
3459
|
var _IterableEntryBase = class _IterableEntryBase {
|
|
3211
3460
|
/**
|
|
@@ -3425,7 +3674,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3425
3674
|
[k, v] = toEntryFn(item);
|
|
3426
3675
|
} else {
|
|
3427
3676
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3428
|
-
|
|
3677
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3429
3678
|
}
|
|
3430
3679
|
[k, v] = item;
|
|
3431
3680
|
}
|
|
@@ -3438,7 +3687,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3438
3687
|
static createDefaultComparator() {
|
|
3439
3688
|
return (a, b) => {
|
|
3440
3689
|
if (typeof a === "number" && typeof b === "number") {
|
|
3441
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3690
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3442
3691
|
return a - b;
|
|
3443
3692
|
}
|
|
3444
3693
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3446,13 +3695,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3446
3695
|
}
|
|
3447
3696
|
if (a instanceof Date && b instanceof Date) {
|
|
3448
3697
|
const ta = a.getTime(), tb = b.getTime();
|
|
3449
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3698
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3450
3699
|
return ta - tb;
|
|
3451
3700
|
}
|
|
3452
3701
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3453
3702
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3454
3703
|
}
|
|
3455
|
-
|
|
3704
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3456
3705
|
};
|
|
3457
3706
|
}
|
|
3458
3707
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -3491,6 +3740,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3491
3740
|
|
|
3492
3741
|
|
|
3493
3742
|
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3749
|
+
|
|
3494
3750
|
|
|
3495
3751
|
|
|
3496
3752
|
|
|
@@ -3530,6 +3786,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3530
3786
|
|
|
3531
3787
|
|
|
3532
3788
|
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3794
|
+
|
|
3795
|
+
|
|
3533
3796
|
|
|
3534
3797
|
|
|
3535
3798
|
|
|
@@ -3572,6 +3835,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3572
3835
|
|
|
3573
3836
|
|
|
3574
3837
|
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3844
|
+
|
|
3575
3845
|
|
|
3576
3846
|
|
|
3577
3847
|
|
|
@@ -3622,6 +3892,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3622
3892
|
|
|
3623
3893
|
|
|
3624
3894
|
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
|
|
3899
|
+
|
|
3900
|
+
|
|
3901
|
+
|
|
3625
3902
|
|
|
3626
3903
|
|
|
3627
3904
|
|
|
@@ -3697,6 +3974,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3697
3974
|
|
|
3698
3975
|
|
|
3699
3976
|
|
|
3977
|
+
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3983
|
+
|
|
3700
3984
|
|
|
3701
3985
|
|
|
3702
3986
|
|
|
@@ -3757,6 +4041,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3757
4041
|
|
|
3758
4042
|
|
|
3759
4043
|
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
3760
4051
|
|
|
3761
4052
|
|
|
3762
4053
|
|
|
@@ -3800,6 +4091,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3800
4091
|
|
|
3801
4092
|
|
|
3802
4093
|
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
4100
|
+
|
|
3803
4101
|
|
|
3804
4102
|
|
|
3805
4103
|
|
|
@@ -3863,6 +4161,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3863
4161
|
|
|
3864
4162
|
|
|
3865
4163
|
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
3866
4171
|
|
|
3867
4172
|
|
|
3868
4173
|
|
|
@@ -3906,6 +4211,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3906
4211
|
|
|
3907
4212
|
|
|
3908
4213
|
|
|
4214
|
+
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
4219
|
+
|
|
4220
|
+
|
|
3909
4221
|
|
|
3910
4222
|
|
|
3911
4223
|
|
|
@@ -3951,6 +4263,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3951
4263
|
|
|
3952
4264
|
|
|
3953
4265
|
|
|
4266
|
+
|
|
4267
|
+
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
|
|
4271
|
+
|
|
4272
|
+
|
|
3954
4273
|
|
|
3955
4274
|
|
|
3956
4275
|
|
|
@@ -3994,6 +4313,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3994
4313
|
|
|
3995
4314
|
|
|
3996
4315
|
|
|
4316
|
+
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
|
|
4320
|
+
|
|
4321
|
+
|
|
4322
|
+
|
|
3997
4323
|
|
|
3998
4324
|
|
|
3999
4325
|
|
|
@@ -4040,6 +4366,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4040
4366
|
|
|
4041
4367
|
|
|
4042
4368
|
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
|
|
4374
|
+
|
|
4375
|
+
|
|
4043
4376
|
|
|
4044
4377
|
|
|
4045
4378
|
|
|
@@ -4091,6 +4424,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4091
4424
|
|
|
4092
4425
|
|
|
4093
4426
|
|
|
4427
|
+
|
|
4428
|
+
|
|
4429
|
+
|
|
4430
|
+
|
|
4431
|
+
|
|
4432
|
+
|
|
4433
|
+
|
|
4094
4434
|
|
|
4095
4435
|
|
|
4096
4436
|
|
|
@@ -4140,6 +4480,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4140
4480
|
|
|
4141
4481
|
|
|
4142
4482
|
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
|
|
4486
|
+
|
|
4487
|
+
|
|
4488
|
+
|
|
4489
|
+
|
|
4143
4490
|
|
|
4144
4491
|
|
|
4145
4492
|
|
|
@@ -4188,6 +4535,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4188
4535
|
|
|
4189
4536
|
|
|
4190
4537
|
|
|
4538
|
+
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
|
|
4542
|
+
|
|
4543
|
+
|
|
4544
|
+
|
|
4191
4545
|
|
|
4192
4546
|
|
|
4193
4547
|
|
|
@@ -4242,6 +4596,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4242
4596
|
|
|
4243
4597
|
|
|
4244
4598
|
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
|
|
4602
|
+
|
|
4603
|
+
|
|
4604
|
+
|
|
4605
|
+
|
|
4245
4606
|
|
|
4246
4607
|
|
|
4247
4608
|
|
|
@@ -4304,6 +4665,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4304
4665
|
|
|
4305
4666
|
|
|
4306
4667
|
|
|
4668
|
+
|
|
4669
|
+
|
|
4670
|
+
|
|
4671
|
+
|
|
4672
|
+
|
|
4673
|
+
|
|
4674
|
+
|
|
4307
4675
|
|
|
4308
4676
|
|
|
4309
4677
|
|
|
@@ -4350,6 +4718,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4350
4718
|
|
|
4351
4719
|
|
|
4352
4720
|
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
|
|
4724
|
+
|
|
4725
|
+
|
|
4726
|
+
|
|
4727
|
+
|
|
4353
4728
|
|
|
4354
4729
|
|
|
4355
4730
|
|
|
@@ -4448,5 +4823,6 @@ exports.SinglyLinkedList = SinglyLinkedList;
|
|
|
4448
4823
|
exports.SinglyLinkedListNode = SinglyLinkedListNode;
|
|
4449
4824
|
exports.SkipList = SkipList;
|
|
4450
4825
|
exports.SkipListNode = SkipListNode;
|
|
4826
|
+
exports.raise = raise;
|
|
4451
4827
|
//# sourceMappingURL=index.cjs.map
|
|
4452
4828
|
//# sourceMappingURL=index.cjs.map
|