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
|
@@ -38,9 +38,61 @@ var linkedListTyped = (() => {
|
|
|
38
38
|
SinglyLinkedList: () => SinglyLinkedList,
|
|
39
39
|
SinglyLinkedListNode: () => SinglyLinkedListNode,
|
|
40
40
|
SkipList: () => SkipList,
|
|
41
|
-
SkipListNode: () => SkipListNode
|
|
41
|
+
SkipListNode: () => SkipListNode,
|
|
42
|
+
raise: () => raise
|
|
42
43
|
});
|
|
43
44
|
|
|
45
|
+
// src/common/error.ts
|
|
46
|
+
function raise(ErrorClass, message) {
|
|
47
|
+
throw new ErrorClass(message);
|
|
48
|
+
}
|
|
49
|
+
var ERR = {
|
|
50
|
+
// Range / index
|
|
51
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
52
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
53
|
+
// Type / argument
|
|
54
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
55
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
56
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
57
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
58
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
59
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
60
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
61
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
62
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
63
|
+
// State / operation
|
|
64
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
65
|
+
// Matrix
|
|
66
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
67
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
68
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
69
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
70
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
71
|
+
// Order statistic
|
|
72
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/common/index.ts
|
|
76
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
77
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
78
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
79
|
+
return DFSOperation2;
|
|
80
|
+
})(DFSOperation || {});
|
|
81
|
+
var Range = class {
|
|
82
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
83
|
+
this.low = low;
|
|
84
|
+
this.high = high;
|
|
85
|
+
this.includeLow = includeLow;
|
|
86
|
+
this.includeHigh = includeHigh;
|
|
87
|
+
}
|
|
88
|
+
// Determine whether a key is within the range
|
|
89
|
+
isInRange(key, comparator) {
|
|
90
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
91
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
92
|
+
return lowCheck && highCheck;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
44
96
|
// src/data-structures/base/iterable-element-base.ts
|
|
45
97
|
var IterableElementBase = class {
|
|
46
98
|
/**
|
|
@@ -63,7 +115,7 @@ var linkedListTyped = (() => {
|
|
|
63
115
|
if (options) {
|
|
64
116
|
const { toElementFn } = options;
|
|
65
117
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
66
|
-
else if (toElementFn)
|
|
118
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
67
119
|
}
|
|
68
120
|
}
|
|
69
121
|
/**
|
|
@@ -219,7 +271,7 @@ var linkedListTyped = (() => {
|
|
|
219
271
|
acc = initialValue;
|
|
220
272
|
} else {
|
|
221
273
|
const first = iter.next();
|
|
222
|
-
if (first.done)
|
|
274
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
223
275
|
acc = first.value;
|
|
224
276
|
index = 1;
|
|
225
277
|
}
|
|
@@ -775,6 +827,13 @@ var linkedListTyped = (() => {
|
|
|
775
827
|
|
|
776
828
|
|
|
777
829
|
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
778
837
|
|
|
779
838
|
|
|
780
839
|
|
|
@@ -839,6 +898,13 @@ var linkedListTyped = (() => {
|
|
|
839
898
|
|
|
840
899
|
|
|
841
900
|
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
842
908
|
|
|
843
909
|
|
|
844
910
|
|
|
@@ -909,6 +975,13 @@ var linkedListTyped = (() => {
|
|
|
909
975
|
|
|
910
976
|
|
|
911
977
|
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
912
985
|
|
|
913
986
|
|
|
914
987
|
|
|
@@ -960,6 +1033,13 @@ var linkedListTyped = (() => {
|
|
|
960
1033
|
|
|
961
1034
|
|
|
962
1035
|
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
963
1043
|
|
|
964
1044
|
|
|
965
1045
|
|
|
@@ -1072,6 +1152,13 @@ var linkedListTyped = (() => {
|
|
|
1072
1152
|
|
|
1073
1153
|
|
|
1074
1154
|
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1075
1162
|
|
|
1076
1163
|
|
|
1077
1164
|
|
|
@@ -1128,6 +1215,13 @@ var linkedListTyped = (() => {
|
|
|
1128
1215
|
|
|
1129
1216
|
|
|
1130
1217
|
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1131
1225
|
|
|
1132
1226
|
|
|
1133
1227
|
|
|
@@ -1173,6 +1267,13 @@ var linkedListTyped = (() => {
|
|
|
1173
1267
|
|
|
1174
1268
|
|
|
1175
1269
|
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
|
|
1275
|
+
|
|
1276
|
+
|
|
1176
1277
|
|
|
1177
1278
|
|
|
1178
1279
|
|
|
@@ -1224,6 +1325,13 @@ var linkedListTyped = (() => {
|
|
|
1224
1325
|
|
|
1225
1326
|
|
|
1226
1327
|
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
|
|
1227
1335
|
|
|
1228
1336
|
|
|
1229
1337
|
|
|
@@ -1280,6 +1388,13 @@ var linkedListTyped = (() => {
|
|
|
1280
1388
|
|
|
1281
1389
|
|
|
1282
1390
|
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
|
|
1397
|
+
|
|
1283
1398
|
|
|
1284
1399
|
|
|
1285
1400
|
|
|
@@ -1344,6 +1459,13 @@ var linkedListTyped = (() => {
|
|
|
1344
1459
|
|
|
1345
1460
|
|
|
1346
1461
|
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1347
1469
|
|
|
1348
1470
|
|
|
1349
1471
|
|
|
@@ -1385,6 +1507,13 @@ var linkedListTyped = (() => {
|
|
|
1385
1507
|
|
|
1386
1508
|
|
|
1387
1509
|
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1388
1517
|
|
|
1389
1518
|
|
|
1390
1519
|
|
|
@@ -1432,6 +1561,13 @@ var linkedListTyped = (() => {
|
|
|
1432
1561
|
|
|
1433
1562
|
|
|
1434
1563
|
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1435
1571
|
|
|
1436
1572
|
|
|
1437
1573
|
|
|
@@ -1645,6 +1781,13 @@ var linkedListTyped = (() => {
|
|
|
1645
1781
|
|
|
1646
1782
|
|
|
1647
1783
|
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1648
1791
|
|
|
1649
1792
|
|
|
1650
1793
|
|
|
@@ -1696,6 +1839,13 @@ var linkedListTyped = (() => {
|
|
|
1696
1839
|
|
|
1697
1840
|
|
|
1698
1841
|
|
|
1842
|
+
|
|
1843
|
+
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1699
1849
|
|
|
1700
1850
|
|
|
1701
1851
|
|
|
@@ -1775,6 +1925,13 @@ var linkedListTyped = (() => {
|
|
|
1775
1925
|
|
|
1776
1926
|
|
|
1777
1927
|
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1778
1935
|
|
|
1779
1936
|
|
|
1780
1937
|
|
|
@@ -2087,6 +2244,13 @@ var linkedListTyped = (() => {
|
|
|
2087
2244
|
|
|
2088
2245
|
|
|
2089
2246
|
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2253
|
+
|
|
2090
2254
|
|
|
2091
2255
|
|
|
2092
2256
|
|
|
@@ -2153,6 +2317,13 @@ var linkedListTyped = (() => {
|
|
|
2153
2317
|
|
|
2154
2318
|
|
|
2155
2319
|
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2156
2327
|
|
|
2157
2328
|
|
|
2158
2329
|
|
|
@@ -2218,6 +2389,13 @@ var linkedListTyped = (() => {
|
|
|
2218
2389
|
|
|
2219
2390
|
|
|
2220
2391
|
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2221
2399
|
|
|
2222
2400
|
|
|
2223
2401
|
|
|
@@ -2274,6 +2452,13 @@ var linkedListTyped = (() => {
|
|
|
2274
2452
|
|
|
2275
2453
|
|
|
2276
2454
|
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
|
|
2277
2462
|
|
|
2278
2463
|
|
|
2279
2464
|
|
|
@@ -2359,6 +2544,13 @@ var linkedListTyped = (() => {
|
|
|
2359
2544
|
|
|
2360
2545
|
|
|
2361
2546
|
|
|
2547
|
+
|
|
2548
|
+
|
|
2549
|
+
|
|
2550
|
+
|
|
2551
|
+
|
|
2552
|
+
|
|
2553
|
+
|
|
2362
2554
|
|
|
2363
2555
|
|
|
2364
2556
|
|
|
@@ -2405,6 +2597,13 @@ var linkedListTyped = (() => {
|
|
|
2405
2597
|
|
|
2406
2598
|
|
|
2407
2599
|
|
|
2600
|
+
|
|
2601
|
+
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
|
|
2408
2607
|
|
|
2409
2608
|
|
|
2410
2609
|
|
|
@@ -2482,6 +2681,13 @@ var linkedListTyped = (() => {
|
|
|
2482
2681
|
|
|
2483
2682
|
|
|
2484
2683
|
|
|
2684
|
+
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
|
|
2688
|
+
|
|
2689
|
+
|
|
2690
|
+
|
|
2485
2691
|
|
|
2486
2692
|
|
|
2487
2693
|
|
|
@@ -2587,6 +2793,13 @@ var linkedListTyped = (() => {
|
|
|
2587
2793
|
|
|
2588
2794
|
|
|
2589
2795
|
|
|
2796
|
+
|
|
2797
|
+
|
|
2798
|
+
|
|
2799
|
+
|
|
2800
|
+
|
|
2801
|
+
|
|
2802
|
+
|
|
2590
2803
|
|
|
2591
2804
|
|
|
2592
2805
|
|
|
@@ -2639,6 +2852,13 @@ var linkedListTyped = (() => {
|
|
|
2639
2852
|
|
|
2640
2853
|
|
|
2641
2854
|
|
|
2855
|
+
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
|
|
2861
|
+
|
|
2642
2862
|
|
|
2643
2863
|
|
|
2644
2864
|
|
|
@@ -2693,6 +2913,13 @@ var linkedListTyped = (() => {
|
|
|
2693
2913
|
|
|
2694
2914
|
|
|
2695
2915
|
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
|
|
2922
|
+
|
|
2696
2923
|
|
|
2697
2924
|
|
|
2698
2925
|
|
|
@@ -2734,6 +2961,13 @@ var linkedListTyped = (() => {
|
|
|
2734
2961
|
|
|
2735
2962
|
|
|
2736
2963
|
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
|
|
2969
|
+
|
|
2970
|
+
|
|
2737
2971
|
|
|
2738
2972
|
|
|
2739
2973
|
|
|
@@ -2779,6 +3013,13 @@ var linkedListTyped = (() => {
|
|
|
2779
3013
|
|
|
2780
3014
|
|
|
2781
3015
|
|
|
3016
|
+
|
|
3017
|
+
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
2782
3023
|
|
|
2783
3024
|
|
|
2784
3025
|
|
|
@@ -2828,6 +3069,13 @@ var linkedListTyped = (() => {
|
|
|
2828
3069
|
|
|
2829
3070
|
|
|
2830
3071
|
|
|
3072
|
+
|
|
3073
|
+
|
|
3074
|
+
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
|
|
3078
|
+
|
|
2831
3079
|
|
|
2832
3080
|
|
|
2833
3081
|
|
|
@@ -2880,6 +3128,13 @@ var linkedListTyped = (() => {
|
|
|
2880
3128
|
|
|
2881
3129
|
|
|
2882
3130
|
|
|
3131
|
+
|
|
3132
|
+
|
|
3133
|
+
|
|
3134
|
+
|
|
3135
|
+
|
|
3136
|
+
|
|
3137
|
+
|
|
2883
3138
|
|
|
2884
3139
|
|
|
2885
3140
|
|
|
@@ -2904,6 +3159,25 @@ var linkedListTyped = (() => {
|
|
|
2904
3159
|
}
|
|
2905
3160
|
return this;
|
|
2906
3161
|
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Delete the first element that satisfies a predicate.
|
|
3164
|
+
* @remarks Time O(N), Space O(1)
|
|
3165
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3166
|
+
* @returns True if a match was removed.
|
|
3167
|
+
*/
|
|
3168
|
+
deleteWhere(predicate) {
|
|
3169
|
+
let current = this.head;
|
|
3170
|
+
let index = 0;
|
|
3171
|
+
while (current) {
|
|
3172
|
+
if (predicate(current.value, index, this)) {
|
|
3173
|
+
this.delete(current);
|
|
3174
|
+
return true;
|
|
3175
|
+
}
|
|
3176
|
+
current = current.next;
|
|
3177
|
+
index++;
|
|
3178
|
+
}
|
|
3179
|
+
return false;
|
|
3180
|
+
}
|
|
2907
3181
|
/**
|
|
2908
3182
|
* Set the equality comparator used to compare values.
|
|
2909
3183
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2940,6 +3214,13 @@ var linkedListTyped = (() => {
|
|
|
2940
3214
|
|
|
2941
3215
|
|
|
2942
3216
|
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
|
|
3220
|
+
|
|
3221
|
+
|
|
3222
|
+
|
|
3223
|
+
|
|
2943
3224
|
|
|
2944
3225
|
|
|
2945
3226
|
|
|
@@ -2990,6 +3271,13 @@ var linkedListTyped = (() => {
|
|
|
2990
3271
|
|
|
2991
3272
|
|
|
2992
3273
|
|
|
3274
|
+
|
|
3275
|
+
|
|
3276
|
+
|
|
3277
|
+
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
|
|
2993
3281
|
|
|
2994
3282
|
|
|
2995
3283
|
|
|
@@ -3059,6 +3347,13 @@ var linkedListTyped = (() => {
|
|
|
3059
3347
|
|
|
3060
3348
|
|
|
3061
3349
|
|
|
3350
|
+
|
|
3351
|
+
|
|
3352
|
+
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
|
|
3356
|
+
|
|
3062
3357
|
|
|
3063
3358
|
|
|
3064
3359
|
|
|
@@ -3170,52 +3465,6 @@ var linkedListTyped = (() => {
|
|
|
3170
3465
|
}
|
|
3171
3466
|
};
|
|
3172
3467
|
|
|
3173
|
-
// src/common/error.ts
|
|
3174
|
-
var ERR = {
|
|
3175
|
-
// Range / index
|
|
3176
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
3177
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
3178
|
-
// Type / argument
|
|
3179
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
3180
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
3181
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
3182
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
3183
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
3184
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
3185
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
3186
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
3187
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
3188
|
-
// State / operation
|
|
3189
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
3190
|
-
// Matrix
|
|
3191
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
3192
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
3193
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
3194
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
3195
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
3196
|
-
};
|
|
3197
|
-
|
|
3198
|
-
// src/common/index.ts
|
|
3199
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
3200
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
3201
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
3202
|
-
return DFSOperation2;
|
|
3203
|
-
})(DFSOperation || {});
|
|
3204
|
-
var Range = class {
|
|
3205
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
3206
|
-
this.low = low;
|
|
3207
|
-
this.high = high;
|
|
3208
|
-
this.includeLow = includeLow;
|
|
3209
|
-
this.includeHigh = includeHigh;
|
|
3210
|
-
}
|
|
3211
|
-
// Determine whether a key is within the range
|
|
3212
|
-
isInRange(key, comparator) {
|
|
3213
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
3214
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
3215
|
-
return lowCheck && highCheck;
|
|
3216
|
-
}
|
|
3217
|
-
};
|
|
3218
|
-
|
|
3219
3468
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3220
3469
|
var IterableEntryBase = class {
|
|
3221
3470
|
/**
|
|
@@ -3431,7 +3680,7 @@ var linkedListTyped = (() => {
|
|
|
3431
3680
|
[k, v] = toEntryFn(item);
|
|
3432
3681
|
} else {
|
|
3433
3682
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3434
|
-
|
|
3683
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3435
3684
|
}
|
|
3436
3685
|
[k, v] = item;
|
|
3437
3686
|
}
|
|
@@ -3444,7 +3693,7 @@ var linkedListTyped = (() => {
|
|
|
3444
3693
|
static createDefaultComparator() {
|
|
3445
3694
|
return (a, b) => {
|
|
3446
3695
|
if (typeof a === "number" && typeof b === "number") {
|
|
3447
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3696
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3448
3697
|
return a - b;
|
|
3449
3698
|
}
|
|
3450
3699
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3452,13 +3701,13 @@ var linkedListTyped = (() => {
|
|
|
3452
3701
|
}
|
|
3453
3702
|
if (a instanceof Date && b instanceof Date) {
|
|
3454
3703
|
const ta = a.getTime(), tb = b.getTime();
|
|
3455
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3704
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3456
3705
|
return ta - tb;
|
|
3457
3706
|
}
|
|
3458
3707
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3459
3708
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3460
3709
|
}
|
|
3461
|
-
|
|
3710
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3462
3711
|
};
|
|
3463
3712
|
}
|
|
3464
3713
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -3497,6 +3746,13 @@ var linkedListTyped = (() => {
|
|
|
3497
3746
|
|
|
3498
3747
|
|
|
3499
3748
|
|
|
3749
|
+
|
|
3750
|
+
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
|
|
3500
3756
|
|
|
3501
3757
|
|
|
3502
3758
|
|
|
@@ -3536,6 +3792,13 @@ var linkedListTyped = (() => {
|
|
|
3536
3792
|
|
|
3537
3793
|
|
|
3538
3794
|
|
|
3795
|
+
|
|
3796
|
+
|
|
3797
|
+
|
|
3798
|
+
|
|
3799
|
+
|
|
3800
|
+
|
|
3801
|
+
|
|
3539
3802
|
|
|
3540
3803
|
|
|
3541
3804
|
|
|
@@ -3578,6 +3841,13 @@ var linkedListTyped = (() => {
|
|
|
3578
3841
|
|
|
3579
3842
|
|
|
3580
3843
|
|
|
3844
|
+
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
|
|
3849
|
+
|
|
3850
|
+
|
|
3581
3851
|
|
|
3582
3852
|
|
|
3583
3853
|
|
|
@@ -3628,6 +3898,13 @@ var linkedListTyped = (() => {
|
|
|
3628
3898
|
|
|
3629
3899
|
|
|
3630
3900
|
|
|
3901
|
+
|
|
3902
|
+
|
|
3903
|
+
|
|
3904
|
+
|
|
3905
|
+
|
|
3906
|
+
|
|
3907
|
+
|
|
3631
3908
|
|
|
3632
3909
|
|
|
3633
3910
|
|
|
@@ -3703,6 +3980,13 @@ var linkedListTyped = (() => {
|
|
|
3703
3980
|
|
|
3704
3981
|
|
|
3705
3982
|
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
|
|
3706
3990
|
|
|
3707
3991
|
|
|
3708
3992
|
|
|
@@ -3763,6 +4047,13 @@ var linkedListTyped = (() => {
|
|
|
3763
4047
|
|
|
3764
4048
|
|
|
3765
4049
|
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
|
|
3766
4057
|
|
|
3767
4058
|
|
|
3768
4059
|
|
|
@@ -3806,6 +4097,13 @@ var linkedListTyped = (() => {
|
|
|
3806
4097
|
|
|
3807
4098
|
|
|
3808
4099
|
|
|
4100
|
+
|
|
4101
|
+
|
|
4102
|
+
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
|
|
4106
|
+
|
|
3809
4107
|
|
|
3810
4108
|
|
|
3811
4109
|
|
|
@@ -3869,6 +4167,13 @@ var linkedListTyped = (() => {
|
|
|
3869
4167
|
|
|
3870
4168
|
|
|
3871
4169
|
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
3872
4177
|
|
|
3873
4178
|
|
|
3874
4179
|
|
|
@@ -3912,6 +4217,13 @@ var linkedListTyped = (() => {
|
|
|
3912
4217
|
|
|
3913
4218
|
|
|
3914
4219
|
|
|
4220
|
+
|
|
4221
|
+
|
|
4222
|
+
|
|
4223
|
+
|
|
4224
|
+
|
|
4225
|
+
|
|
4226
|
+
|
|
3915
4227
|
|
|
3916
4228
|
|
|
3917
4229
|
|
|
@@ -3957,6 +4269,13 @@ var linkedListTyped = (() => {
|
|
|
3957
4269
|
|
|
3958
4270
|
|
|
3959
4271
|
|
|
4272
|
+
|
|
4273
|
+
|
|
4274
|
+
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
|
|
3960
4279
|
|
|
3961
4280
|
|
|
3962
4281
|
|
|
@@ -4000,6 +4319,13 @@ var linkedListTyped = (() => {
|
|
|
4000
4319
|
|
|
4001
4320
|
|
|
4002
4321
|
|
|
4322
|
+
|
|
4323
|
+
|
|
4324
|
+
|
|
4325
|
+
|
|
4326
|
+
|
|
4327
|
+
|
|
4328
|
+
|
|
4003
4329
|
|
|
4004
4330
|
|
|
4005
4331
|
|
|
@@ -4046,6 +4372,13 @@ var linkedListTyped = (() => {
|
|
|
4046
4372
|
|
|
4047
4373
|
|
|
4048
4374
|
|
|
4375
|
+
|
|
4376
|
+
|
|
4377
|
+
|
|
4378
|
+
|
|
4379
|
+
|
|
4380
|
+
|
|
4381
|
+
|
|
4049
4382
|
|
|
4050
4383
|
|
|
4051
4384
|
|
|
@@ -4097,6 +4430,13 @@ var linkedListTyped = (() => {
|
|
|
4097
4430
|
|
|
4098
4431
|
|
|
4099
4432
|
|
|
4433
|
+
|
|
4434
|
+
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
|
|
4438
|
+
|
|
4439
|
+
|
|
4100
4440
|
|
|
4101
4441
|
|
|
4102
4442
|
|
|
@@ -4146,6 +4486,13 @@ var linkedListTyped = (() => {
|
|
|
4146
4486
|
|
|
4147
4487
|
|
|
4148
4488
|
|
|
4489
|
+
|
|
4490
|
+
|
|
4491
|
+
|
|
4492
|
+
|
|
4493
|
+
|
|
4494
|
+
|
|
4495
|
+
|
|
4149
4496
|
|
|
4150
4497
|
|
|
4151
4498
|
|
|
@@ -4194,6 +4541,13 @@ var linkedListTyped = (() => {
|
|
|
4194
4541
|
|
|
4195
4542
|
|
|
4196
4543
|
|
|
4544
|
+
|
|
4545
|
+
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
|
|
4549
|
+
|
|
4550
|
+
|
|
4197
4551
|
|
|
4198
4552
|
|
|
4199
4553
|
|
|
@@ -4248,6 +4602,13 @@ var linkedListTyped = (() => {
|
|
|
4248
4602
|
|
|
4249
4603
|
|
|
4250
4604
|
|
|
4605
|
+
|
|
4606
|
+
|
|
4607
|
+
|
|
4608
|
+
|
|
4609
|
+
|
|
4610
|
+
|
|
4611
|
+
|
|
4251
4612
|
|
|
4252
4613
|
|
|
4253
4614
|
|
|
@@ -4310,6 +4671,13 @@ var linkedListTyped = (() => {
|
|
|
4310
4671
|
|
|
4311
4672
|
|
|
4312
4673
|
|
|
4674
|
+
|
|
4675
|
+
|
|
4676
|
+
|
|
4677
|
+
|
|
4678
|
+
|
|
4679
|
+
|
|
4680
|
+
|
|
4313
4681
|
|
|
4314
4682
|
|
|
4315
4683
|
|
|
@@ -4356,6 +4724,13 @@ var linkedListTyped = (() => {
|
|
|
4356
4724
|
|
|
4357
4725
|
|
|
4358
4726
|
|
|
4727
|
+
|
|
4728
|
+
|
|
4729
|
+
|
|
4730
|
+
|
|
4731
|
+
|
|
4732
|
+
|
|
4733
|
+
|
|
4359
4734
|
|
|
4360
4735
|
|
|
4361
4736
|
|