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 +1296 -89
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1296 -89
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1296 -90
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1296 -90
- 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/linked-list-typed.js +1320 -114
- 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/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
|
@@ -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
|
}
|
|
@@ -762,6 +814,30 @@ var linkedListTyped = (() => {
|
|
|
762
814
|
|
|
763
815
|
|
|
764
816
|
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
765
841
|
* @example
|
|
766
842
|
* // basic SinglyLinkedList creation and push operation
|
|
767
843
|
* // Create a simple SinglyLinkedList with initial values
|
|
@@ -805,6 +881,30 @@ var linkedListTyped = (() => {
|
|
|
805
881
|
|
|
806
882
|
|
|
807
883
|
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
808
908
|
* @example
|
|
809
909
|
* // SinglyLinkedList pop and shift operations
|
|
810
910
|
* const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -854,6 +954,30 @@ var linkedListTyped = (() => {
|
|
|
854
954
|
|
|
855
955
|
|
|
856
956
|
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
857
981
|
* @example
|
|
858
982
|
* // Remove from the front
|
|
859
983
|
* const list = new SinglyLinkedList<number>([10, 20, 30]);
|
|
@@ -884,6 +1008,30 @@ var linkedListTyped = (() => {
|
|
|
884
1008
|
|
|
885
1009
|
|
|
886
1010
|
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
887
1035
|
* @example
|
|
888
1036
|
* // SinglyLinkedList unshift and forward traversal
|
|
889
1037
|
* const list = new SinglyLinkedList<number>([20, 30, 40]);
|
|
@@ -975,6 +1123,30 @@ var linkedListTyped = (() => {
|
|
|
975
1123
|
|
|
976
1124
|
|
|
977
1125
|
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
978
1150
|
* @example
|
|
979
1151
|
* // Access element by index
|
|
980
1152
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
|
|
@@ -1010,6 +1182,30 @@ var linkedListTyped = (() => {
|
|
|
1010
1182
|
|
|
1011
1183
|
|
|
1012
1184
|
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1013
1209
|
* @example
|
|
1014
1210
|
* // Get node at index
|
|
1015
1211
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1034,6 +1230,30 @@ var linkedListTyped = (() => {
|
|
|
1034
1230
|
|
|
1035
1231
|
|
|
1036
1232
|
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1037
1257
|
* @example
|
|
1038
1258
|
* // Remove by index
|
|
1039
1259
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1064,6 +1284,30 @@ var linkedListTyped = (() => {
|
|
|
1064
1284
|
|
|
1065
1285
|
|
|
1066
1286
|
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
|
|
1067
1311
|
* @example
|
|
1068
1312
|
* // Remove first occurrence
|
|
1069
1313
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -1099,24 +1343,48 @@ var linkedListTyped = (() => {
|
|
|
1099
1343
|
|
|
1100
1344
|
|
|
1101
1345
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
* @example
|
|
1371
|
+
* // Insert at index
|
|
1372
|
+
* const list = new SinglyLinkedList<number>([1, 3]);
|
|
1373
|
+
* list.addAt(1, 2);
|
|
1374
|
+
* console.log(list.toArray()); // [1, 2, 3];
|
|
1375
|
+
*/
|
|
1376
|
+
addAt(index, newElementOrNode) {
|
|
1377
|
+
if (index < 0 || index > this._length) return false;
|
|
1378
|
+
if (index === 0) return this.unshift(newElementOrNode);
|
|
1379
|
+
if (index === this._length) return this.push(newElementOrNode);
|
|
1380
|
+
const newNode = this._ensureNode(newElementOrNode);
|
|
1381
|
+
const prevNode = this.getNodeAt(index - 1);
|
|
1382
|
+
newNode.next = prevNode.next;
|
|
1383
|
+
prevNode.next = newNode;
|
|
1384
|
+
this._length++;
|
|
1385
|
+
return true;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1120
1388
|
* Set the element value at an index.
|
|
1121
1389
|
* @remarks Time O(N), Space O(1)
|
|
1122
1390
|
* @param index - Zero-based index.
|
|
@@ -1142,6 +1410,30 @@ var linkedListTyped = (() => {
|
|
|
1142
1410
|
|
|
1143
1411
|
|
|
1144
1412
|
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1145
1437
|
* @example
|
|
1146
1438
|
* // Check empty
|
|
1147
1439
|
* console.log(new SinglyLinkedList().isEmpty()); // true;
|
|
@@ -1162,6 +1454,30 @@ var linkedListTyped = (() => {
|
|
|
1162
1454
|
|
|
1163
1455
|
|
|
1164
1456
|
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1165
1481
|
* @example
|
|
1166
1482
|
* // Remove all
|
|
1167
1483
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1188,6 +1504,30 @@ var linkedListTyped = (() => {
|
|
|
1188
1504
|
|
|
1189
1505
|
|
|
1190
1506
|
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
|
|
1191
1531
|
* @example
|
|
1192
1532
|
* // Reverse the list in-place
|
|
1193
1533
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -1380,6 +1720,30 @@ var linkedListTyped = (() => {
|
|
|
1380
1720
|
|
|
1381
1721
|
|
|
1382
1722
|
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
|
|
1383
1747
|
* @example
|
|
1384
1748
|
* // Deep copy
|
|
1385
1749
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1410,6 +1774,30 @@ var linkedListTyped = (() => {
|
|
|
1410
1774
|
|
|
1411
1775
|
|
|
1412
1776
|
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
|
|
1413
1801
|
* @example
|
|
1414
1802
|
* // SinglyLinkedList filter and map operations
|
|
1415
1803
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -1468,6 +1856,30 @@ var linkedListTyped = (() => {
|
|
|
1468
1856
|
|
|
1469
1857
|
|
|
1470
1858
|
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
|
|
1471
1883
|
* @example
|
|
1472
1884
|
* // Transform elements
|
|
1473
1885
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1759,6 +2171,30 @@ var linkedListTyped = (() => {
|
|
|
1759
2171
|
|
|
1760
2172
|
|
|
1761
2173
|
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
1762
2198
|
* @example
|
|
1763
2199
|
* // basic DoublyLinkedList creation and push operation
|
|
1764
2200
|
* // Create a simple DoublyLinkedList with initial values
|
|
@@ -1804,6 +2240,30 @@ var linkedListTyped = (() => {
|
|
|
1804
2240
|
|
|
1805
2241
|
|
|
1806
2242
|
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
1807
2267
|
* @example
|
|
1808
2268
|
* // DoublyLinkedList pop and shift operations
|
|
1809
2269
|
* const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -1848,28 +2308,52 @@ var linkedListTyped = (() => {
|
|
|
1848
2308
|
|
|
1849
2309
|
|
|
1850
2310
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
* @example
|
|
2336
|
+
* // Remove from the front
|
|
2337
|
+
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
2338
|
+
* console.log(list.shift()); // 10;
|
|
2339
|
+
* console.log(list.first); // 20;
|
|
2340
|
+
*/
|
|
2341
|
+
shift() {
|
|
2342
|
+
if (!this.head) return void 0;
|
|
2343
|
+
const removed = this.head;
|
|
2344
|
+
if (this.head === this.tail) {
|
|
2345
|
+
this._head = void 0;
|
|
2346
|
+
this._tail = void 0;
|
|
2347
|
+
} else {
|
|
2348
|
+
this._head = removed.next;
|
|
2349
|
+
this.head.prev = void 0;
|
|
2350
|
+
}
|
|
2351
|
+
this._length--;
|
|
2352
|
+
return removed.value;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Prepend an element/node to the head.
|
|
2356
|
+
* @remarks Time O(1), Space O(1)
|
|
1873
2357
|
* @param elementOrNode - Element or node to prepend.
|
|
1874
2358
|
* @returns True when prepended.
|
|
1875
2359
|
|
|
@@ -1883,6 +2367,30 @@ var linkedListTyped = (() => {
|
|
|
1883
2367
|
|
|
1884
2368
|
|
|
1885
2369
|
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
1886
2394
|
* @example
|
|
1887
2395
|
* // Add to the front
|
|
1888
2396
|
* const list = new DoublyLinkedList<number>([2, 3]);
|
|
@@ -1947,6 +2455,30 @@ var linkedListTyped = (() => {
|
|
|
1947
2455
|
|
|
1948
2456
|
|
|
1949
2457
|
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
|
|
2462
|
+
|
|
2463
|
+
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
1950
2482
|
* @example
|
|
1951
2483
|
* // Access by index
|
|
1952
2484
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1972,6 +2504,30 @@ var linkedListTyped = (() => {
|
|
|
1972
2504
|
|
|
1973
2505
|
|
|
1974
2506
|
|
|
2507
|
+
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
1975
2531
|
* @example
|
|
1976
2532
|
* // Get node at index
|
|
1977
2533
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -2028,6 +2584,30 @@ var linkedListTyped = (() => {
|
|
|
2028
2584
|
|
|
2029
2585
|
|
|
2030
2586
|
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
|
|
2599
|
+
|
|
2600
|
+
|
|
2601
|
+
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
|
|
2609
|
+
|
|
2610
|
+
|
|
2031
2611
|
* @example
|
|
2032
2612
|
* // Insert at position
|
|
2033
2613
|
* const list = new DoublyLinkedList<number>([1, 3]);
|
|
@@ -2112,6 +2692,30 @@ var linkedListTyped = (() => {
|
|
|
2112
2692
|
|
|
2113
2693
|
|
|
2114
2694
|
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
|
|
2698
|
+
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2115
2719
|
* @example
|
|
2116
2720
|
* // Remove by index
|
|
2117
2721
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -2143,6 +2747,30 @@ var linkedListTyped = (() => {
|
|
|
2143
2747
|
|
|
2144
2748
|
|
|
2145
2749
|
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
|
|
2753
|
+
|
|
2754
|
+
|
|
2755
|
+
|
|
2756
|
+
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
|
|
2770
|
+
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
|
|
2146
2774
|
* @example
|
|
2147
2775
|
* // Remove first occurrence
|
|
2148
2776
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -2176,6 +2804,30 @@ var linkedListTyped = (() => {
|
|
|
2176
2804
|
|
|
2177
2805
|
|
|
2178
2806
|
|
|
2807
|
+
|
|
2808
|
+
|
|
2809
|
+
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
|
|
2815
|
+
|
|
2816
|
+
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
|
|
2827
|
+
|
|
2828
|
+
|
|
2829
|
+
|
|
2830
|
+
|
|
2179
2831
|
* @example
|
|
2180
2832
|
* // Check empty
|
|
2181
2833
|
* console.log(new DoublyLinkedList().isEmpty()); // true;
|
|
@@ -2196,6 +2848,30 @@ var linkedListTyped = (() => {
|
|
|
2196
2848
|
|
|
2197
2849
|
|
|
2198
2850
|
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
|
|
2854
|
+
|
|
2855
|
+
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
|
|
2861
|
+
|
|
2862
|
+
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
|
|
2869
|
+
|
|
2870
|
+
|
|
2871
|
+
|
|
2872
|
+
|
|
2873
|
+
|
|
2874
|
+
|
|
2199
2875
|
* @example
|
|
2200
2876
|
* // Remove all
|
|
2201
2877
|
* const list = new DoublyLinkedList<number>([1, 2]);
|
|
@@ -2220,24 +2896,48 @@ var linkedListTyped = (() => {
|
|
|
2220
2896
|
|
|
2221
2897
|
|
|
2222
2898
|
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2899
|
+
|
|
2900
|
+
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
|
|
2907
|
+
|
|
2908
|
+
|
|
2909
|
+
|
|
2910
|
+
|
|
2911
|
+
|
|
2912
|
+
|
|
2913
|
+
|
|
2914
|
+
|
|
2915
|
+
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
|
|
2922
|
+
|
|
2923
|
+
* @example
|
|
2924
|
+
* // Search with predicate
|
|
2925
|
+
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
2926
|
+
* const found = list.search(node => node.value > 15);
|
|
2927
|
+
* console.log(found); // 20;
|
|
2928
|
+
*/
|
|
2929
|
+
search(elementNodeOrPredicate) {
|
|
2930
|
+
const predicate = this._ensurePredicate(elementNodeOrPredicate);
|
|
2931
|
+
let current = this.head;
|
|
2932
|
+
while (current) {
|
|
2933
|
+
if (predicate(current)) return current.value;
|
|
2934
|
+
current = current.next;
|
|
2935
|
+
}
|
|
2936
|
+
return void 0;
|
|
2937
|
+
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Find the first value matching a predicate scanning backward.
|
|
2940
|
+
* @remarks Time O(N), Space O(1)
|
|
2241
2941
|
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
2242
2942
|
* @returns Matched value or undefined.
|
|
2243
2943
|
|
|
@@ -2248,6 +2948,30 @@ var linkedListTyped = (() => {
|
|
|
2248
2948
|
|
|
2249
2949
|
|
|
2250
2950
|
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
|
|
2969
|
+
|
|
2970
|
+
|
|
2971
|
+
|
|
2972
|
+
|
|
2973
|
+
|
|
2974
|
+
|
|
2251
2975
|
* @example
|
|
2252
2976
|
* // Find value scanning from tail
|
|
2253
2977
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -2279,6 +3003,30 @@ var linkedListTyped = (() => {
|
|
|
2279
3003
|
|
|
2280
3004
|
|
|
2281
3005
|
|
|
3006
|
+
|
|
3007
|
+
|
|
3008
|
+
|
|
3009
|
+
|
|
3010
|
+
|
|
3011
|
+
|
|
3012
|
+
|
|
3013
|
+
|
|
3014
|
+
|
|
3015
|
+
|
|
3016
|
+
|
|
3017
|
+
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
|
|
3028
|
+
|
|
3029
|
+
|
|
2282
3030
|
* @example
|
|
2283
3031
|
* // Reverse in-place
|
|
2284
3032
|
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
@@ -2318,6 +3066,30 @@ var linkedListTyped = (() => {
|
|
|
2318
3066
|
|
|
2319
3067
|
|
|
2320
3068
|
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
|
|
3072
|
+
|
|
3073
|
+
|
|
3074
|
+
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
|
|
3078
|
+
|
|
3079
|
+
|
|
3080
|
+
|
|
3081
|
+
|
|
3082
|
+
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
|
|
3086
|
+
|
|
3087
|
+
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
|
|
3091
|
+
|
|
3092
|
+
|
|
2321
3093
|
* @example
|
|
2322
3094
|
* // Deep copy
|
|
2323
3095
|
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
@@ -2347,6 +3119,30 @@ var linkedListTyped = (() => {
|
|
|
2347
3119
|
|
|
2348
3120
|
|
|
2349
3121
|
|
|
3122
|
+
|
|
3123
|
+
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
|
|
3127
|
+
|
|
3128
|
+
|
|
3129
|
+
|
|
3130
|
+
|
|
3131
|
+
|
|
3132
|
+
|
|
3133
|
+
|
|
3134
|
+
|
|
3135
|
+
|
|
3136
|
+
|
|
3137
|
+
|
|
3138
|
+
|
|
3139
|
+
|
|
3140
|
+
|
|
3141
|
+
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
|
|
3145
|
+
|
|
2350
3146
|
* @example
|
|
2351
3147
|
* // Filter elements
|
|
2352
3148
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -2395,6 +3191,30 @@ var linkedListTyped = (() => {
|
|
|
2395
3191
|
|
|
2396
3192
|
|
|
2397
3193
|
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
|
|
3217
|
+
|
|
2398
3218
|
* @example
|
|
2399
3219
|
* // DoublyLinkedList for...of iteration and map operation
|
|
2400
3220
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -2498,52 +3318,6 @@ var linkedListTyped = (() => {
|
|
|
2498
3318
|
}
|
|
2499
3319
|
};
|
|
2500
3320
|
|
|
2501
|
-
// src/common/error.ts
|
|
2502
|
-
var ERR = {
|
|
2503
|
-
// Range / index
|
|
2504
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
2505
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
2506
|
-
// Type / argument
|
|
2507
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
2508
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
2509
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
2510
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
2511
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
2512
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
2513
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
2514
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
2515
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
2516
|
-
// State / operation
|
|
2517
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
2518
|
-
// Matrix
|
|
2519
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
2520
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
2521
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
2522
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
2523
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
2524
|
-
};
|
|
2525
|
-
|
|
2526
|
-
// src/common/index.ts
|
|
2527
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
2528
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
2529
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
2530
|
-
return DFSOperation2;
|
|
2531
|
-
})(DFSOperation || {});
|
|
2532
|
-
var Range = class {
|
|
2533
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
2534
|
-
this.low = low;
|
|
2535
|
-
this.high = high;
|
|
2536
|
-
this.includeLow = includeLow;
|
|
2537
|
-
this.includeHigh = includeHigh;
|
|
2538
|
-
}
|
|
2539
|
-
// Determine whether a key is within the range
|
|
2540
|
-
isInRange(key, comparator) {
|
|
2541
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
2542
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
2543
|
-
return lowCheck && highCheck;
|
|
2544
|
-
}
|
|
2545
|
-
};
|
|
2546
|
-
|
|
2547
3321
|
// src/data-structures/base/iterable-entry-base.ts
|
|
2548
3322
|
var IterableEntryBase = class {
|
|
2549
3323
|
/**
|
|
@@ -2759,7 +3533,7 @@ var linkedListTyped = (() => {
|
|
|
2759
3533
|
[k, v] = toEntryFn(item);
|
|
2760
3534
|
} else {
|
|
2761
3535
|
if (!Array.isArray(item) || item.length < 2) {
|
|
2762
|
-
|
|
3536
|
+
raise(TypeError, ERR.invalidEntry("SkipList"));
|
|
2763
3537
|
}
|
|
2764
3538
|
[k, v] = item;
|
|
2765
3539
|
}
|
|
@@ -2772,7 +3546,7 @@ var linkedListTyped = (() => {
|
|
|
2772
3546
|
static createDefaultComparator() {
|
|
2773
3547
|
return (a, b) => {
|
|
2774
3548
|
if (typeof a === "number" && typeof b === "number") {
|
|
2775
|
-
if (Number.isNaN(a) || Number.isNaN(b))
|
|
3549
|
+
if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
|
|
2776
3550
|
return a - b;
|
|
2777
3551
|
}
|
|
2778
3552
|
if (typeof a === "string" && typeof b === "string") {
|
|
@@ -2780,13 +3554,13 @@ var linkedListTyped = (() => {
|
|
|
2780
3554
|
}
|
|
2781
3555
|
if (a instanceof Date && b instanceof Date) {
|
|
2782
3556
|
const ta = a.getTime(), tb = b.getTime();
|
|
2783
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
3557
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
|
|
2784
3558
|
return ta - tb;
|
|
2785
3559
|
}
|
|
2786
3560
|
if (typeof a === "bigint" && typeof b === "bigint") {
|
|
2787
3561
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
2788
3562
|
}
|
|
2789
|
-
|
|
3563
|
+
raise(TypeError, ERR.comparatorRequired("SkipList"));
|
|
2790
3564
|
};
|
|
2791
3565
|
}
|
|
2792
3566
|
// ─── Size & lifecycle ────────────────────────────────────────
|
|
@@ -2812,6 +3586,30 @@ var linkedListTyped = (() => {
|
|
|
2812
3586
|
|
|
2813
3587
|
|
|
2814
3588
|
|
|
3589
|
+
|
|
3590
|
+
|
|
3591
|
+
|
|
3592
|
+
|
|
3593
|
+
|
|
3594
|
+
|
|
3595
|
+
|
|
3596
|
+
|
|
3597
|
+
|
|
3598
|
+
|
|
3599
|
+
|
|
3600
|
+
|
|
3601
|
+
|
|
3602
|
+
|
|
3603
|
+
|
|
3604
|
+
|
|
3605
|
+
|
|
3606
|
+
|
|
3607
|
+
|
|
3608
|
+
|
|
3609
|
+
|
|
3610
|
+
|
|
3611
|
+
|
|
3612
|
+
|
|
2815
3613
|
* @example
|
|
2816
3614
|
* // Check if empty
|
|
2817
3615
|
* const sl = new SkipList<number, string>();
|
|
@@ -2830,6 +3628,30 @@ var linkedListTyped = (() => {
|
|
|
2830
3628
|
|
|
2831
3629
|
|
|
2832
3630
|
|
|
3631
|
+
|
|
3632
|
+
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3645
|
+
|
|
3646
|
+
|
|
3647
|
+
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
|
|
3651
|
+
|
|
3652
|
+
|
|
3653
|
+
|
|
3654
|
+
|
|
2833
3655
|
* @example
|
|
2834
3656
|
* // Remove all entries
|
|
2835
3657
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
@@ -2851,7 +3673,31 @@ var linkedListTyped = (() => {
|
|
|
2851
3673
|
|
|
2852
3674
|
|
|
2853
3675
|
|
|
2854
|
-
|
|
3676
|
+
|
|
3677
|
+
|
|
3678
|
+
|
|
3679
|
+
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
|
|
3689
|
+
|
|
3690
|
+
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
|
|
3697
|
+
|
|
3698
|
+
|
|
3699
|
+
|
|
3700
|
+
* @example
|
|
2855
3701
|
* // Create independent copy
|
|
2856
3702
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
2857
3703
|
* const copy = sl.clone();
|
|
@@ -2880,6 +3726,30 @@ var linkedListTyped = (() => {
|
|
|
2880
3726
|
|
|
2881
3727
|
|
|
2882
3728
|
|
|
3729
|
+
|
|
3730
|
+
|
|
3731
|
+
|
|
3732
|
+
|
|
3733
|
+
|
|
3734
|
+
|
|
3735
|
+
|
|
3736
|
+
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3749
|
+
|
|
3750
|
+
|
|
3751
|
+
|
|
3752
|
+
|
|
2883
3753
|
* @example
|
|
2884
3754
|
* // In-memory sorted key-value store
|
|
2885
3755
|
* const store = new SkipList<number, string>();
|
|
@@ -2934,6 +3804,30 @@ var linkedListTyped = (() => {
|
|
|
2934
3804
|
|
|
2935
3805
|
|
|
2936
3806
|
|
|
3807
|
+
|
|
3808
|
+
|
|
3809
|
+
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
|
|
3813
|
+
|
|
3814
|
+
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
|
|
3822
|
+
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
|
|
3829
|
+
|
|
3830
|
+
|
|
2937
3831
|
* @example
|
|
2938
3832
|
* // Building a sorted index
|
|
2939
3833
|
* type Product = { id: number; name: string; price: number };
|
|
@@ -2943,8 +3837,8 @@ var linkedListTyped = (() => {
|
|
|
2943
3837
|
* { id: 3, name: 'Doohickey', price: 15 }
|
|
2944
3838
|
* ];
|
|
2945
3839
|
*
|
|
2946
|
-
* const index = new SkipList<number, Product>(products
|
|
2947
|
-
* toEntryFn: (p:
|
|
3840
|
+
* const index = new SkipList<number, Product, Product>(products, {
|
|
3841
|
+
* toEntryFn: (p: Product) => [p.price, p]
|
|
2948
3842
|
* });
|
|
2949
3843
|
*
|
|
2950
3844
|
* // Iterate in sorted order by price
|
|
@@ -2973,6 +3867,30 @@ var linkedListTyped = (() => {
|
|
|
2973
3867
|
|
|
2974
3868
|
|
|
2975
3869
|
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3884
|
+
|
|
3885
|
+
|
|
3886
|
+
|
|
3887
|
+
|
|
3888
|
+
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
|
|
3892
|
+
|
|
3893
|
+
|
|
2976
3894
|
* @example
|
|
2977
3895
|
* // Check key existence
|
|
2978
3896
|
* const sl = new SkipList<number, string>([[1, 'a'], [3, 'c'], [5, 'e']]);
|
|
@@ -2995,6 +3913,30 @@ var linkedListTyped = (() => {
|
|
|
2995
3913
|
|
|
2996
3914
|
|
|
2997
3915
|
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3919
|
+
|
|
3920
|
+
|
|
3921
|
+
|
|
3922
|
+
|
|
3923
|
+
|
|
3924
|
+
|
|
3925
|
+
|
|
3926
|
+
|
|
3927
|
+
|
|
3928
|
+
|
|
3929
|
+
|
|
3930
|
+
|
|
3931
|
+
|
|
3932
|
+
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
|
|
3936
|
+
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
|
|
2998
3940
|
* @example
|
|
2999
3941
|
* // Fast lookup with deletion
|
|
3000
3942
|
* const cache = new SkipList<string, number>();
|
|
@@ -3037,6 +3979,30 @@ var linkedListTyped = (() => {
|
|
|
3037
3979
|
|
|
3038
3980
|
|
|
3039
3981
|
|
|
3982
|
+
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
|
|
3993
|
+
|
|
3994
|
+
|
|
3995
|
+
|
|
3996
|
+
|
|
3997
|
+
|
|
3998
|
+
|
|
3999
|
+
|
|
4000
|
+
|
|
4001
|
+
|
|
4002
|
+
|
|
4003
|
+
|
|
4004
|
+
|
|
4005
|
+
|
|
3040
4006
|
* @example
|
|
3041
4007
|
* // Access the minimum entry
|
|
3042
4008
|
* const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
|
|
@@ -3059,6 +4025,30 @@ var linkedListTyped = (() => {
|
|
|
3059
4025
|
|
|
3060
4026
|
|
|
3061
4027
|
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
3062
4052
|
* @example
|
|
3063
4053
|
* // Access the maximum entry
|
|
3064
4054
|
* const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
|
|
@@ -3083,6 +4073,30 @@ var linkedListTyped = (() => {
|
|
|
3083
4073
|
|
|
3084
4074
|
|
|
3085
4075
|
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
3086
4100
|
* @example
|
|
3087
4101
|
* // Remove and return smallest
|
|
3088
4102
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
@@ -3105,6 +4119,30 @@ var linkedListTyped = (() => {
|
|
|
3105
4119
|
|
|
3106
4120
|
|
|
3107
4121
|
|
|
4122
|
+
|
|
4123
|
+
|
|
4124
|
+
|
|
4125
|
+
|
|
4126
|
+
|
|
4127
|
+
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
|
|
4134
|
+
|
|
4135
|
+
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
|
|
4139
|
+
|
|
4140
|
+
|
|
4141
|
+
|
|
4142
|
+
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
|
|
3108
4146
|
* @example
|
|
3109
4147
|
* // Remove and return largest
|
|
3110
4148
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
@@ -3130,6 +4168,30 @@ var linkedListTyped = (() => {
|
|
|
3130
4168
|
|
|
3131
4169
|
|
|
3132
4170
|
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
|
|
4191
|
+
|
|
4192
|
+
|
|
4193
|
+
|
|
4194
|
+
|
|
3133
4195
|
* @example
|
|
3134
4196
|
* // Least entry ≥ key
|
|
3135
4197
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -3160,6 +4222,30 @@ var linkedListTyped = (() => {
|
|
|
3160
4222
|
|
|
3161
4223
|
|
|
3162
4224
|
|
|
4225
|
+
|
|
4226
|
+
|
|
4227
|
+
|
|
4228
|
+
|
|
4229
|
+
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
|
|
4244
|
+
|
|
4245
|
+
|
|
4246
|
+
|
|
4247
|
+
|
|
4248
|
+
|
|
3163
4249
|
* @example
|
|
3164
4250
|
* // Greatest entry ≤ key
|
|
3165
4251
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -3188,6 +4274,30 @@ var linkedListTyped = (() => {
|
|
|
3188
4274
|
|
|
3189
4275
|
|
|
3190
4276
|
|
|
4277
|
+
|
|
4278
|
+
|
|
4279
|
+
|
|
4280
|
+
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
4288
|
+
|
|
4289
|
+
|
|
4290
|
+
|
|
4291
|
+
|
|
4292
|
+
|
|
4293
|
+
|
|
4294
|
+
|
|
4295
|
+
|
|
4296
|
+
|
|
4297
|
+
|
|
4298
|
+
|
|
4299
|
+
|
|
4300
|
+
|
|
3191
4301
|
* @example
|
|
3192
4302
|
* // Strictly greater entry
|
|
3193
4303
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -3215,6 +4325,30 @@ var linkedListTyped = (() => {
|
|
|
3215
4325
|
|
|
3216
4326
|
|
|
3217
4327
|
|
|
4328
|
+
|
|
4329
|
+
|
|
4330
|
+
|
|
4331
|
+
|
|
4332
|
+
|
|
4333
|
+
|
|
4334
|
+
|
|
4335
|
+
|
|
4336
|
+
|
|
4337
|
+
|
|
4338
|
+
|
|
4339
|
+
|
|
4340
|
+
|
|
4341
|
+
|
|
4342
|
+
|
|
4343
|
+
|
|
4344
|
+
|
|
4345
|
+
|
|
4346
|
+
|
|
4347
|
+
|
|
4348
|
+
|
|
4349
|
+
|
|
4350
|
+
|
|
4351
|
+
|
|
3218
4352
|
* @example
|
|
3219
4353
|
* // Strictly less entry
|
|
3220
4354
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -3248,6 +4382,30 @@ var linkedListTyped = (() => {
|
|
|
3248
4382
|
|
|
3249
4383
|
|
|
3250
4384
|
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
|
|
4389
|
+
|
|
4390
|
+
|
|
4391
|
+
|
|
4392
|
+
|
|
4393
|
+
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
|
|
4403
|
+
|
|
4404
|
+
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
|
|
4408
|
+
|
|
3251
4409
|
* @example
|
|
3252
4410
|
* // Find entries in a range
|
|
3253
4411
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e']]);
|
|
@@ -3289,6 +4447,30 @@ var linkedListTyped = (() => {
|
|
|
3289
4447
|
|
|
3290
4448
|
|
|
3291
4449
|
|
|
4450
|
+
|
|
4451
|
+
|
|
4452
|
+
|
|
4453
|
+
|
|
4454
|
+
|
|
4455
|
+
|
|
4456
|
+
|
|
4457
|
+
|
|
4458
|
+
|
|
4459
|
+
|
|
4460
|
+
|
|
4461
|
+
|
|
4462
|
+
|
|
4463
|
+
|
|
4464
|
+
|
|
4465
|
+
|
|
4466
|
+
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4470
|
+
|
|
4471
|
+
|
|
4472
|
+
|
|
4473
|
+
|
|
3292
4474
|
* @example
|
|
3293
4475
|
* // Transform entries
|
|
3294
4476
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
@@ -3314,6 +4496,30 @@ var linkedListTyped = (() => {
|
|
|
3314
4496
|
|
|
3315
4497
|
|
|
3316
4498
|
|
|
4499
|
+
|
|
4500
|
+
|
|
4501
|
+
|
|
4502
|
+
|
|
4503
|
+
|
|
4504
|
+
|
|
4505
|
+
|
|
4506
|
+
|
|
4507
|
+
|
|
4508
|
+
|
|
4509
|
+
|
|
4510
|
+
|
|
4511
|
+
|
|
4512
|
+
|
|
4513
|
+
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
3317
4523
|
* @example
|
|
3318
4524
|
* // Filter entries
|
|
3319
4525
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|