singly-linked-list-typed 2.5.0 → 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 +418 -51
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +417 -50
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +418 -52
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +417 -51
- 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/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
- package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
- package/dist/types/data-structures/heap/heap.d.ts +336 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
- package/dist/types/data-structures/queue/deque.d.ts +364 -4
- package/dist/types/data-structures/queue/queue.d.ts +288 -0
- package/dist/types/data-structures/stack/stack.d.ts +240 -0
- package/dist/types/data-structures/trie/trie.d.ts +292 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- 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/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/singly-linked-list-typed.js +415 -49
- package/dist/umd/singly-linked-list-typed.js.map +1 -1
- package/dist/umd/singly-linked-list-typed.min.js +1 -1
- package/dist/umd/singly-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/index.ts +1 -0
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +299 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
- package/src/data-structures/binary-tree/binary-tree.ts +606 -6
- package/src/data-structures/binary-tree/bst.ts +946 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
- package/src/data-structures/binary-tree/segment-tree.ts +145 -2
- package/src/data-structures/binary-tree/tree-map.ts +3423 -499
- package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
- package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
- package/src/data-structures/binary-tree/tree-set.ts +3209 -413
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +240 -0
- package/src/data-structures/graph/undirected-graph.ts +216 -0
- package/src/data-structures/hash/hash-map.ts +281 -19
- package/src/data-structures/heap/heap.ts +340 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
- package/src/data-structures/matrix/matrix.ts +202 -10
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +365 -5
- package/src/data-structures/queue/queue.ts +288 -0
- package/src/data-structures/stack/stack.ts +240 -0
- package/src/data-structures/trie/trie.ts +295 -7
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -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
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -27,9 +27,61 @@ var singlyLinkedListTyped = (() => {
|
|
|
27
27
|
ERR: () => ERR,
|
|
28
28
|
Range: () => Range,
|
|
29
29
|
SinglyLinkedList: () => SinglyLinkedList,
|
|
30
|
-
SinglyLinkedListNode: () => SinglyLinkedListNode
|
|
30
|
+
SinglyLinkedListNode: () => SinglyLinkedListNode,
|
|
31
|
+
raise: () => raise
|
|
31
32
|
});
|
|
32
33
|
|
|
34
|
+
// src/common/error.ts
|
|
35
|
+
function raise(ErrorClass, message) {
|
|
36
|
+
throw new ErrorClass(message);
|
|
37
|
+
}
|
|
38
|
+
var ERR = {
|
|
39
|
+
// Range / index
|
|
40
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
41
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
42
|
+
// Type / argument
|
|
43
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
44
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
45
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
46
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
47
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
48
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
49
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
50
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
51
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
52
|
+
// State / operation
|
|
53
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
54
|
+
// Matrix
|
|
55
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
56
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
57
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
58
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
59
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
60
|
+
// Order statistic
|
|
61
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/common/index.ts
|
|
65
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
66
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
67
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
68
|
+
return DFSOperation2;
|
|
69
|
+
})(DFSOperation || {});
|
|
70
|
+
var Range = class {
|
|
71
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
72
|
+
this.low = low;
|
|
73
|
+
this.high = high;
|
|
74
|
+
this.includeLow = includeLow;
|
|
75
|
+
this.includeHigh = includeHigh;
|
|
76
|
+
}
|
|
77
|
+
// Determine whether a key is within the range
|
|
78
|
+
isInRange(key, comparator) {
|
|
79
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
80
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
81
|
+
return lowCheck && highCheck;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
33
85
|
// src/data-structures/base/iterable-element-base.ts
|
|
34
86
|
var IterableElementBase = class {
|
|
35
87
|
/**
|
|
@@ -52,7 +104,7 @@ var singlyLinkedListTyped = (() => {
|
|
|
52
104
|
if (options) {
|
|
53
105
|
const { toElementFn } = options;
|
|
54
106
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
55
|
-
else if (toElementFn)
|
|
107
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
56
108
|
}
|
|
57
109
|
}
|
|
58
110
|
/**
|
|
@@ -208,7 +260,7 @@ var singlyLinkedListTyped = (() => {
|
|
|
208
260
|
acc = initialValue;
|
|
209
261
|
} else {
|
|
210
262
|
const first = iter.next();
|
|
211
|
-
if (first.done)
|
|
263
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
212
264
|
acc = first.value;
|
|
213
265
|
index = 1;
|
|
214
266
|
}
|
|
@@ -751,6 +803,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
751
803
|
|
|
752
804
|
|
|
753
805
|
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
754
830
|
* @example
|
|
755
831
|
* // basic SinglyLinkedList creation and push operation
|
|
756
832
|
* // Create a simple SinglyLinkedList with initial values
|
|
@@ -794,6 +870,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
794
870
|
|
|
795
871
|
|
|
796
872
|
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
797
897
|
* @example
|
|
798
898
|
* // SinglyLinkedList pop and shift operations
|
|
799
899
|
* const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -843,6 +943,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
843
943
|
|
|
844
944
|
|
|
845
945
|
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
846
970
|
* @example
|
|
847
971
|
* // Remove from the front
|
|
848
972
|
* const list = new SinglyLinkedList<number>([10, 20, 30]);
|
|
@@ -873,6 +997,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
873
997
|
|
|
874
998
|
|
|
875
999
|
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
876
1024
|
* @example
|
|
877
1025
|
* // SinglyLinkedList unshift and forward traversal
|
|
878
1026
|
* const list = new SinglyLinkedList<number>([20, 30, 40]);
|
|
@@ -964,6 +1112,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
964
1112
|
|
|
965
1113
|
|
|
966
1114
|
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
967
1139
|
* @example
|
|
968
1140
|
* // Access element by index
|
|
969
1141
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
|
|
@@ -999,6 +1171,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
999
1171
|
|
|
1000
1172
|
|
|
1001
1173
|
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1002
1198
|
* @example
|
|
1003
1199
|
* // Get node at index
|
|
1004
1200
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1023,6 +1219,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1023
1219
|
|
|
1024
1220
|
|
|
1025
1221
|
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1026
1246
|
* @example
|
|
1027
1247
|
* // Remove by index
|
|
1028
1248
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1053,6 +1273,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1053
1273
|
|
|
1054
1274
|
|
|
1055
1275
|
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1056
1300
|
* @example
|
|
1057
1301
|
* // Remove first occurrence
|
|
1058
1302
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -1088,6 +1332,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1088
1332
|
|
|
1089
1333
|
|
|
1090
1334
|
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1091
1359
|
* @example
|
|
1092
1360
|
* // Insert at index
|
|
1093
1361
|
* const list = new SinglyLinkedList<number>([1, 3]);
|
|
@@ -1131,6 +1399,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1131
1399
|
|
|
1132
1400
|
|
|
1133
1401
|
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1134
1426
|
* @example
|
|
1135
1427
|
* // Check empty
|
|
1136
1428
|
* console.log(new SinglyLinkedList().isEmpty()); // true;
|
|
@@ -1151,6 +1443,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1151
1443
|
|
|
1152
1444
|
|
|
1153
1445
|
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1154
1470
|
* @example
|
|
1155
1471
|
* // Remove all
|
|
1156
1472
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1177,6 +1493,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1177
1493
|
|
|
1178
1494
|
|
|
1179
1495
|
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1180
1520
|
* @example
|
|
1181
1521
|
* // Reverse the list in-place
|
|
1182
1522
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -1369,6 +1709,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1369
1709
|
|
|
1370
1710
|
|
|
1371
1711
|
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
|
|
1372
1736
|
* @example
|
|
1373
1737
|
* // Deep copy
|
|
1374
1738
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1399,6 +1763,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1399
1763
|
|
|
1400
1764
|
|
|
1401
1765
|
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1402
1790
|
* @example
|
|
1403
1791
|
* // SinglyLinkedList filter and map operations
|
|
1404
1792
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -1457,6 +1845,30 @@ var singlyLinkedListTyped = (() => {
|
|
|
1457
1845
|
|
|
1458
1846
|
|
|
1459
1847
|
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1460
1872
|
* @example
|
|
1461
1873
|
* // Transform elements
|
|
1462
1874
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1595,52 +2007,6 @@ var singlyLinkedListTyped = (() => {
|
|
|
1595
2007
|
const value = input;
|
|
1596
2008
|
return (node) => equals(node.value, value);
|
|
1597
2009
|
}
|
|
1598
|
-
|
|
1599
|
-
// src/common/error.ts
|
|
1600
|
-
var ERR = {
|
|
1601
|
-
// Range / index
|
|
1602
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
1603
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
1604
|
-
// Type / argument
|
|
1605
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1606
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
1607
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1608
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
1609
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
1610
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
1611
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
1612
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
1613
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
1614
|
-
// State / operation
|
|
1615
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1616
|
-
// Matrix
|
|
1617
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
1618
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
1619
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
1620
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
1621
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
1622
|
-
};
|
|
1623
|
-
|
|
1624
|
-
// src/common/index.ts
|
|
1625
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1626
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1627
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1628
|
-
return DFSOperation2;
|
|
1629
|
-
})(DFSOperation || {});
|
|
1630
|
-
var Range = class {
|
|
1631
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1632
|
-
this.low = low;
|
|
1633
|
-
this.high = high;
|
|
1634
|
-
this.includeLow = includeLow;
|
|
1635
|
-
this.includeHigh = includeHigh;
|
|
1636
|
-
}
|
|
1637
|
-
// Determine whether a key is within the range
|
|
1638
|
-
isInRange(key, comparator) {
|
|
1639
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1640
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1641
|
-
return lowCheck && highCheck;
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
2010
|
return __toCommonJS(src_exports);
|
|
1645
2011
|
})();
|
|
1646
2012
|
/**
|