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
|
@@ -8,6 +8,11 @@ export interface TreeMapOptions<K, V, R = [K, V]> {
|
|
|
8
8
|
* - `false`: store values on tree nodes (Node Mode).
|
|
9
9
|
*/
|
|
10
10
|
isMapMode?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
13
|
+
* When true, subtree counts are maintained on every node.
|
|
14
|
+
*/
|
|
15
|
+
enableOrderStatistic?: boolean;
|
|
11
16
|
/**
|
|
12
17
|
* Transform raw elements into `[key, value]` entries.
|
|
13
18
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<[K, V]>`.
|
|
@@ -8,6 +8,10 @@ export interface TreeMultiSetOptions<K, R = K> {
|
|
|
8
8
|
* - `false`: Node Mode.
|
|
9
9
|
*/
|
|
10
10
|
isMapMode?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
13
|
+
*/
|
|
14
|
+
enableOrderStatistic?: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* Transform raw elements into keys.
|
|
13
17
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|
|
@@ -8,6 +8,10 @@ export interface TreeSetOptions<K, R = K> {
|
|
|
8
8
|
* - `false`: store values on tree nodes (Node Mode).
|
|
9
9
|
*/
|
|
10
10
|
isMapMode?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Enable order-statistic operations (select, rank, rangeByRank).
|
|
13
|
+
*/
|
|
14
|
+
enableOrderStatistic?: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* Transform raw elements into keys.
|
|
13
17
|
* When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
|
|
@@ -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
|
}
|
|
@@ -779,6 +831,9 @@ var linkedListTyped = (() => {
|
|
|
779
831
|
|
|
780
832
|
|
|
781
833
|
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
782
837
|
|
|
783
838
|
|
|
784
839
|
|
|
@@ -843,6 +898,9 @@ var linkedListTyped = (() => {
|
|
|
843
898
|
|
|
844
899
|
|
|
845
900
|
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
846
904
|
|
|
847
905
|
|
|
848
906
|
|
|
@@ -913,6 +971,9 @@ var linkedListTyped = (() => {
|
|
|
913
971
|
|
|
914
972
|
|
|
915
973
|
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
916
977
|
|
|
917
978
|
|
|
918
979
|
|
|
@@ -964,6 +1025,9 @@ var linkedListTyped = (() => {
|
|
|
964
1025
|
|
|
965
1026
|
|
|
966
1027
|
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
967
1031
|
|
|
968
1032
|
|
|
969
1033
|
|
|
@@ -1076,6 +1140,9 @@ var linkedListTyped = (() => {
|
|
|
1076
1140
|
|
|
1077
1141
|
|
|
1078
1142
|
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1079
1146
|
|
|
1080
1147
|
|
|
1081
1148
|
|
|
@@ -1132,6 +1199,9 @@ var linkedListTyped = (() => {
|
|
|
1132
1199
|
|
|
1133
1200
|
|
|
1134
1201
|
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1135
1205
|
|
|
1136
1206
|
|
|
1137
1207
|
|
|
@@ -1177,6 +1247,9 @@ var linkedListTyped = (() => {
|
|
|
1177
1247
|
|
|
1178
1248
|
|
|
1179
1249
|
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1180
1253
|
|
|
1181
1254
|
|
|
1182
1255
|
|
|
@@ -1228,6 +1301,9 @@ var linkedListTyped = (() => {
|
|
|
1228
1301
|
|
|
1229
1302
|
|
|
1230
1303
|
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
|
|
1231
1307
|
|
|
1232
1308
|
|
|
1233
1309
|
|
|
@@ -1284,6 +1360,9 @@ var linkedListTyped = (() => {
|
|
|
1284
1360
|
|
|
1285
1361
|
|
|
1286
1362
|
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1287
1366
|
|
|
1288
1367
|
|
|
1289
1368
|
|
|
@@ -1348,6 +1427,9 @@ var linkedListTyped = (() => {
|
|
|
1348
1427
|
|
|
1349
1428
|
|
|
1350
1429
|
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1351
1433
|
|
|
1352
1434
|
|
|
1353
1435
|
|
|
@@ -1389,6 +1471,9 @@ var linkedListTyped = (() => {
|
|
|
1389
1471
|
|
|
1390
1472
|
|
|
1391
1473
|
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1392
1477
|
|
|
1393
1478
|
|
|
1394
1479
|
|
|
@@ -1436,6 +1521,9 @@ var linkedListTyped = (() => {
|
|
|
1436
1521
|
|
|
1437
1522
|
|
|
1438
1523
|
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1439
1527
|
|
|
1440
1528
|
|
|
1441
1529
|
|
|
@@ -1649,6 +1737,9 @@ var linkedListTyped = (() => {
|
|
|
1649
1737
|
|
|
1650
1738
|
|
|
1651
1739
|
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
|
|
1652
1743
|
|
|
1653
1744
|
|
|
1654
1745
|
|
|
@@ -1700,6 +1791,9 @@ var linkedListTyped = (() => {
|
|
|
1700
1791
|
|
|
1701
1792
|
|
|
1702
1793
|
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
|
|
1703
1797
|
|
|
1704
1798
|
|
|
1705
1799
|
|
|
@@ -1779,6 +1873,9 @@ var linkedListTyped = (() => {
|
|
|
1779
1873
|
|
|
1780
1874
|
|
|
1781
1875
|
|
|
1876
|
+
|
|
1877
|
+
|
|
1878
|
+
|
|
1782
1879
|
|
|
1783
1880
|
|
|
1784
1881
|
|
|
@@ -2091,6 +2188,9 @@ var linkedListTyped = (() => {
|
|
|
2091
2188
|
|
|
2092
2189
|
|
|
2093
2190
|
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
2094
2194
|
|
|
2095
2195
|
|
|
2096
2196
|
|
|
@@ -2157,6 +2257,9 @@ var linkedListTyped = (() => {
|
|
|
2157
2257
|
|
|
2158
2258
|
|
|
2159
2259
|
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2160
2263
|
|
|
2161
2264
|
|
|
2162
2265
|
|
|
@@ -2222,6 +2325,9 @@ var linkedListTyped = (() => {
|
|
|
2222
2325
|
|
|
2223
2326
|
|
|
2224
2327
|
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2225
2331
|
|
|
2226
2332
|
|
|
2227
2333
|
|
|
@@ -2278,6 +2384,9 @@ var linkedListTyped = (() => {
|
|
|
2278
2384
|
|
|
2279
2385
|
|
|
2280
2386
|
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
|
|
2281
2390
|
|
|
2282
2391
|
|
|
2283
2392
|
|
|
@@ -2363,6 +2472,9 @@ var linkedListTyped = (() => {
|
|
|
2363
2472
|
|
|
2364
2473
|
|
|
2365
2474
|
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2366
2478
|
|
|
2367
2479
|
|
|
2368
2480
|
|
|
@@ -2409,6 +2521,9 @@ var linkedListTyped = (() => {
|
|
|
2409
2521
|
|
|
2410
2522
|
|
|
2411
2523
|
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2412
2527
|
|
|
2413
2528
|
|
|
2414
2529
|
|
|
@@ -2486,6 +2601,9 @@ var linkedListTyped = (() => {
|
|
|
2486
2601
|
|
|
2487
2602
|
|
|
2488
2603
|
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
|
|
2489
2607
|
|
|
2490
2608
|
|
|
2491
2609
|
|
|
@@ -2591,6 +2709,9 @@ var linkedListTyped = (() => {
|
|
|
2591
2709
|
|
|
2592
2710
|
|
|
2593
2711
|
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2594
2715
|
|
|
2595
2716
|
|
|
2596
2717
|
|
|
@@ -2643,6 +2764,9 @@ var linkedListTyped = (() => {
|
|
|
2643
2764
|
|
|
2644
2765
|
|
|
2645
2766
|
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
|
|
2646
2770
|
|
|
2647
2771
|
|
|
2648
2772
|
|
|
@@ -2697,6 +2821,9 @@ var linkedListTyped = (() => {
|
|
|
2697
2821
|
|
|
2698
2822
|
|
|
2699
2823
|
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
|
|
2700
2827
|
|
|
2701
2828
|
|
|
2702
2829
|
|
|
@@ -2738,6 +2865,9 @@ var linkedListTyped = (() => {
|
|
|
2738
2865
|
|
|
2739
2866
|
|
|
2740
2867
|
|
|
2868
|
+
|
|
2869
|
+
|
|
2870
|
+
|
|
2741
2871
|
|
|
2742
2872
|
|
|
2743
2873
|
|
|
@@ -2783,6 +2913,9 @@ var linkedListTyped = (() => {
|
|
|
2783
2913
|
|
|
2784
2914
|
|
|
2785
2915
|
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2786
2919
|
|
|
2787
2920
|
|
|
2788
2921
|
|
|
@@ -2832,6 +2965,9 @@ var linkedListTyped = (() => {
|
|
|
2832
2965
|
|
|
2833
2966
|
|
|
2834
2967
|
|
|
2968
|
+
|
|
2969
|
+
|
|
2970
|
+
|
|
2835
2971
|
|
|
2836
2972
|
|
|
2837
2973
|
|
|
@@ -2884,6 +3020,9 @@ var linkedListTyped = (() => {
|
|
|
2884
3020
|
|
|
2885
3021
|
|
|
2886
3022
|
|
|
3023
|
+
|
|
3024
|
+
|
|
3025
|
+
|
|
2887
3026
|
|
|
2888
3027
|
|
|
2889
3028
|
|
|
@@ -2944,6 +3083,9 @@ var linkedListTyped = (() => {
|
|
|
2944
3083
|
|
|
2945
3084
|
|
|
2946
3085
|
|
|
3086
|
+
|
|
3087
|
+
|
|
3088
|
+
|
|
2947
3089
|
|
|
2948
3090
|
|
|
2949
3091
|
|
|
@@ -2994,6 +3136,9 @@ var linkedListTyped = (() => {
|
|
|
2994
3136
|
|
|
2995
3137
|
|
|
2996
3138
|
|
|
3139
|
+
|
|
3140
|
+
|
|
3141
|
+
|
|
2997
3142
|
|
|
2998
3143
|
|
|
2999
3144
|
|
|
@@ -3063,6 +3208,9 @@ var linkedListTyped = (() => {
|
|
|
3063
3208
|
|
|
3064
3209
|
|
|
3065
3210
|
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
|
|
3066
3214
|
|
|
3067
3215
|
|
|
3068
3216
|
|
|
@@ -3170,52 +3318,6 @@ var linkedListTyped = (() => {
|
|
|
3170
3318
|
}
|
|
3171
3319
|
};
|
|
3172
3320
|
|
|
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
3321
|
// src/data-structures/base/iterable-entry-base.ts
|
|
3220
3322
|
var IterableEntryBase = class {
|
|
3221
3323
|
/**
|
|
@@ -3431,7 +3533,7 @@ var linkedListTyped = (() => {
|
|
|
3431
3533
|
[k, v] = toEntryFn(item);
|
|
3432
3534
|
} else {
|
|
3433
3535
|
if (!Array.isArray(item) || item.length < 2) {
|
|
3434
|
-
|
|
3536
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
3435
3537
|
}
|
|
3436
3538
|
[k, v] = item;
|
|
3437
3539
|
}
|
|
@@ -3444,7 +3546,7 @@ var linkedListTyped = (() => {
|
|
|
3444
3546
|
static createDefaultComparator() {
|
|
3445
3547
|
return (a, b) => {
|
|
3446
3548
|
if (typeof a === "number" && typeof b === "number") {
|
|
3447
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3549
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
3448
3550
|
return a - b;
|
|
3449
3551
|
}
|
|
3450
3552
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -3452,13 +3554,13 @@ var linkedListTyped = (() => {
|
|
|
3452
3554
|
}
|
|
3453
3555
|
if (a instanceof Date && b instanceof Date) {
|
|
3454
3556
|
const ta = a.getTime(), tb = b.getTime();
|
|
3455
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3557
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
3456
3558
|
return ta - tb;
|
|
3457
3559
|
}
|
|
3458
3560
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
3459
3561
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3460
3562
|
}
|
|
3461
|
-
|
|
3563
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
3462
3564
|
};
|
|
3463
3565
|
}
|
|
3464
3566
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -3501,6 +3603,9 @@ var linkedListTyped = (() => {
|
|
|
3501
3603
|
|
|
3502
3604
|
|
|
3503
3605
|
|
|
3606
|
+
|
|
3607
|
+
|
|
3608
|
+
|
|
3504
3609
|
|
|
3505
3610
|
|
|
3506
3611
|
|
|
@@ -3540,6 +3645,9 @@ var linkedListTyped = (() => {
|
|
|
3540
3645
|
|
|
3541
3646
|
|
|
3542
3647
|
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
|
|
3543
3651
|
|
|
3544
3652
|
|
|
3545
3653
|
|
|
@@ -3582,6 +3690,9 @@ var linkedListTyped = (() => {
|
|
|
3582
3690
|
|
|
3583
3691
|
|
|
3584
3692
|
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
|
|
3585
3696
|
|
|
3586
3697
|
|
|
3587
3698
|
|
|
@@ -3632,6 +3743,9 @@ var linkedListTyped = (() => {
|
|
|
3632
3743
|
|
|
3633
3744
|
|
|
3634
3745
|
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3635
3749
|
|
|
3636
3750
|
|
|
3637
3751
|
|
|
@@ -3707,6 +3821,9 @@ var linkedListTyped = (() => {
|
|
|
3707
3821
|
|
|
3708
3822
|
|
|
3709
3823
|
|
|
3824
|
+
|
|
3825
|
+
|
|
3826
|
+
|
|
3710
3827
|
|
|
3711
3828
|
|
|
3712
3829
|
|
|
@@ -3767,6 +3884,9 @@ var linkedListTyped = (() => {
|
|
|
3767
3884
|
|
|
3768
3885
|
|
|
3769
3886
|
|
|
3887
|
+
|
|
3888
|
+
|
|
3889
|
+
|
|
3770
3890
|
|
|
3771
3891
|
|
|
3772
3892
|
|
|
@@ -3810,6 +3930,9 @@ var linkedListTyped = (() => {
|
|
|
3810
3930
|
|
|
3811
3931
|
|
|
3812
3932
|
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
|
|
3813
3936
|
|
|
3814
3937
|
|
|
3815
3938
|
|
|
@@ -3873,6 +3996,9 @@ var linkedListTyped = (() => {
|
|
|
3873
3996
|
|
|
3874
3997
|
|
|
3875
3998
|
|
|
3999
|
+
|
|
4000
|
+
|
|
4001
|
+
|
|
3876
4002
|
|
|
3877
4003
|
|
|
3878
4004
|
|
|
@@ -3916,6 +4042,9 @@ var linkedListTyped = (() => {
|
|
|
3916
4042
|
|
|
3917
4043
|
|
|
3918
4044
|
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
3919
4048
|
|
|
3920
4049
|
|
|
3921
4050
|
|
|
@@ -3961,6 +4090,9 @@ var linkedListTyped = (() => {
|
|
|
3961
4090
|
|
|
3962
4091
|
|
|
3963
4092
|
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
3964
4096
|
|
|
3965
4097
|
|
|
3966
4098
|
|
|
@@ -4004,6 +4136,9 @@ var linkedListTyped = (() => {
|
|
|
4004
4136
|
|
|
4005
4137
|
|
|
4006
4138
|
|
|
4139
|
+
|
|
4140
|
+
|
|
4141
|
+
|
|
4007
4142
|
|
|
4008
4143
|
|
|
4009
4144
|
|
|
@@ -4050,6 +4185,9 @@ var linkedListTyped = (() => {
|
|
|
4050
4185
|
|
|
4051
4186
|
|
|
4052
4187
|
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
|
|
4053
4191
|
|
|
4054
4192
|
|
|
4055
4193
|
|
|
@@ -4101,6 +4239,9 @@ var linkedListTyped = (() => {
|
|
|
4101
4239
|
|
|
4102
4240
|
|
|
4103
4241
|
|
|
4242
|
+
|
|
4243
|
+
|
|
4244
|
+
|
|
4104
4245
|
|
|
4105
4246
|
|
|
4106
4247
|
|
|
@@ -4150,6 +4291,9 @@ var linkedListTyped = (() => {
|
|
|
4150
4291
|
|
|
4151
4292
|
|
|
4152
4293
|
|
|
4294
|
+
|
|
4295
|
+
|
|
4296
|
+
|
|
4153
4297
|
|
|
4154
4298
|
|
|
4155
4299
|
|
|
@@ -4198,6 +4342,9 @@ var linkedListTyped = (() => {
|
|
|
4198
4342
|
|
|
4199
4343
|
|
|
4200
4344
|
|
|
4345
|
+
|
|
4346
|
+
|
|
4347
|
+
|
|
4201
4348
|
|
|
4202
4349
|
|
|
4203
4350
|
|
|
@@ -4252,6 +4399,9 @@ var linkedListTyped = (() => {
|
|
|
4252
4399
|
|
|
4253
4400
|
|
|
4254
4401
|
|
|
4402
|
+
|
|
4403
|
+
|
|
4404
|
+
|
|
4255
4405
|
|
|
4256
4406
|
|
|
4257
4407
|
|
|
@@ -4314,6 +4464,9 @@ var linkedListTyped = (() => {
|
|
|
4314
4464
|
|
|
4315
4465
|
|
|
4316
4466
|
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4317
4470
|
|
|
4318
4471
|
|
|
4319
4472
|
|
|
@@ -4360,6 +4513,9 @@ var linkedListTyped = (() => {
|
|
|
4360
4513
|
|
|
4361
4514
|
|
|
4362
4515
|
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4363
4519
|
|
|
4364
4520
|
|
|
4365
4521
|
|