queue-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 +1081 -66
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1081 -66
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1081 -67
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1081 -67
- 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/queue-typed.js +1081 -67
- package/dist/umd/queue-typed.js.map +1 -1
- package/dist/umd/queue-typed.min.js +1 -1
- package/dist/umd/queue-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
package/dist/umd/queue-typed.js
CHANGED
|
@@ -28,9 +28,61 @@ var queueTyped = (() => {
|
|
|
28
28
|
ERR: () => ERR,
|
|
29
29
|
LinkedListQueue: () => LinkedListQueue,
|
|
30
30
|
Queue: () => Queue,
|
|
31
|
-
Range: () => Range
|
|
31
|
+
Range: () => Range,
|
|
32
|
+
raise: () => raise
|
|
32
33
|
});
|
|
33
34
|
|
|
35
|
+
// src/common/error.ts
|
|
36
|
+
function raise(ErrorClass, message) {
|
|
37
|
+
throw new ErrorClass(message);
|
|
38
|
+
}
|
|
39
|
+
var ERR = {
|
|
40
|
+
// Range / index
|
|
41
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
42
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
43
|
+
// Type / argument
|
|
44
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
45
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
46
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
47
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
48
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
49
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
50
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
51
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
52
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
53
|
+
// State / operation
|
|
54
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
55
|
+
// Matrix
|
|
56
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
57
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
58
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
59
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
60
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
61
|
+
// Order statistic
|
|
62
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// src/common/index.ts
|
|
66
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
67
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
68
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
69
|
+
return DFSOperation2;
|
|
70
|
+
})(DFSOperation || {});
|
|
71
|
+
var Range = class {
|
|
72
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
73
|
+
this.low = low;
|
|
74
|
+
this.high = high;
|
|
75
|
+
this.includeLow = includeLow;
|
|
76
|
+
this.includeHigh = includeHigh;
|
|
77
|
+
}
|
|
78
|
+
// Determine whether a key is within the range
|
|
79
|
+
isInRange(key, comparator) {
|
|
80
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
81
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
82
|
+
return lowCheck && highCheck;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
34
86
|
// src/data-structures/base/iterable-element-base.ts
|
|
35
87
|
var IterableElementBase = class {
|
|
36
88
|
/**
|
|
@@ -53,7 +105,7 @@ var queueTyped = (() => {
|
|
|
53
105
|
if (options) {
|
|
54
106
|
const { toElementFn } = options;
|
|
55
107
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
56
|
-
else if (toElementFn)
|
|
108
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
57
109
|
}
|
|
58
110
|
}
|
|
59
111
|
/**
|
|
@@ -209,7 +261,7 @@ var queueTyped = (() => {
|
|
|
209
261
|
acc = initialValue;
|
|
210
262
|
} else {
|
|
211
263
|
const first = iter.next();
|
|
212
|
-
if (first.done)
|
|
264
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
213
265
|
acc = first.value;
|
|
214
266
|
index = 1;
|
|
215
267
|
}
|
|
@@ -752,6 +804,30 @@ var queueTyped = (() => {
|
|
|
752
804
|
|
|
753
805
|
|
|
754
806
|
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
755
831
|
* @example
|
|
756
832
|
* // basic SinglyLinkedList creation and push operation
|
|
757
833
|
* // Create a simple SinglyLinkedList with initial values
|
|
@@ -795,6 +871,30 @@ var queueTyped = (() => {
|
|
|
795
871
|
|
|
796
872
|
|
|
797
873
|
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
798
898
|
* @example
|
|
799
899
|
* // SinglyLinkedList pop and shift operations
|
|
800
900
|
* const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -844,6 +944,30 @@ var queueTyped = (() => {
|
|
|
844
944
|
|
|
845
945
|
|
|
846
946
|
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
847
971
|
* @example
|
|
848
972
|
* // Remove from the front
|
|
849
973
|
* const list = new SinglyLinkedList<number>([10, 20, 30]);
|
|
@@ -874,6 +998,30 @@ var queueTyped = (() => {
|
|
|
874
998
|
|
|
875
999
|
|
|
876
1000
|
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
877
1025
|
* @example
|
|
878
1026
|
* // SinglyLinkedList unshift and forward traversal
|
|
879
1027
|
* const list = new SinglyLinkedList<number>([20, 30, 40]);
|
|
@@ -965,6 +1113,30 @@ var queueTyped = (() => {
|
|
|
965
1113
|
|
|
966
1114
|
|
|
967
1115
|
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
968
1140
|
* @example
|
|
969
1141
|
* // Access element by index
|
|
970
1142
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
|
|
@@ -1000,6 +1172,30 @@ var queueTyped = (() => {
|
|
|
1000
1172
|
|
|
1001
1173
|
|
|
1002
1174
|
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1003
1199
|
* @example
|
|
1004
1200
|
* // Get node at index
|
|
1005
1201
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1024,6 +1220,30 @@ var queueTyped = (() => {
|
|
|
1024
1220
|
|
|
1025
1221
|
|
|
1026
1222
|
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1027
1247
|
* @example
|
|
1028
1248
|
* // Remove by index
|
|
1029
1249
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -1054,6 +1274,30 @@ var queueTyped = (() => {
|
|
|
1054
1274
|
|
|
1055
1275
|
|
|
1056
1276
|
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
|
|
1057
1301
|
* @example
|
|
1058
1302
|
* // Remove first occurrence
|
|
1059
1303
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -1089,24 +1333,48 @@ var queueTyped = (() => {
|
|
|
1089
1333
|
|
|
1090
1334
|
|
|
1091
1335
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
* @example
|
|
1361
|
+
* // Insert at index
|
|
1362
|
+
* const list = new SinglyLinkedList<number>([1, 3]);
|
|
1363
|
+
* list.addAt(1, 2);
|
|
1364
|
+
* console.log(list.toArray()); // [1, 2, 3];
|
|
1365
|
+
*/
|
|
1366
|
+
addAt(index, newElementOrNode) {
|
|
1367
|
+
if (index < 0 || index > this._length) return false;
|
|
1368
|
+
if (index === 0) return this.unshift(newElementOrNode);
|
|
1369
|
+
if (index === this._length) return this.push(newElementOrNode);
|
|
1370
|
+
const newNode = this._ensureNode(newElementOrNode);
|
|
1371
|
+
const prevNode = this.getNodeAt(index - 1);
|
|
1372
|
+
newNode.next = prevNode.next;
|
|
1373
|
+
prevNode.next = newNode;
|
|
1374
|
+
this._length++;
|
|
1375
|
+
return true;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1110
1378
|
* Set the element value at an index.
|
|
1111
1379
|
* @remarks Time O(N), Space O(1)
|
|
1112
1380
|
* @param index - Zero-based index.
|
|
@@ -1132,6 +1400,30 @@ var queueTyped = (() => {
|
|
|
1132
1400
|
|
|
1133
1401
|
|
|
1134
1402
|
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1135
1427
|
* @example
|
|
1136
1428
|
* // Check empty
|
|
1137
1429
|
* console.log(new SinglyLinkedList().isEmpty()); // true;
|
|
@@ -1152,6 +1444,30 @@ var queueTyped = (() => {
|
|
|
1152
1444
|
|
|
1153
1445
|
|
|
1154
1446
|
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1155
1471
|
* @example
|
|
1156
1472
|
* // Remove all
|
|
1157
1473
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1178,6 +1494,30 @@ var queueTyped = (() => {
|
|
|
1178
1494
|
|
|
1179
1495
|
|
|
1180
1496
|
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1181
1521
|
* @example
|
|
1182
1522
|
* // Reverse the list in-place
|
|
1183
1523
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -1370,6 +1710,30 @@ var queueTyped = (() => {
|
|
|
1370
1710
|
|
|
1371
1711
|
|
|
1372
1712
|
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
|
|
1373
1737
|
* @example
|
|
1374
1738
|
* // Deep copy
|
|
1375
1739
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1400,6 +1764,30 @@ var queueTyped = (() => {
|
|
|
1400
1764
|
|
|
1401
1765
|
|
|
1402
1766
|
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1403
1791
|
* @example
|
|
1404
1792
|
* // SinglyLinkedList filter and map operations
|
|
1405
1793
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -1458,6 +1846,30 @@ var queueTyped = (() => {
|
|
|
1458
1846
|
|
|
1459
1847
|
|
|
1460
1848
|
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1461
1873
|
* @example
|
|
1462
1874
|
* // Transform elements
|
|
1463
1875
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -1597,52 +2009,6 @@ var queueTyped = (() => {
|
|
|
1597
2009
|
return (node) => equals(node.value, value);
|
|
1598
2010
|
}
|
|
1599
2011
|
|
|
1600
|
-
// src/common/error.ts
|
|
1601
|
-
var ERR = {
|
|
1602
|
-
// Range / index
|
|
1603
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
1604
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
1605
|
-
// Type / argument
|
|
1606
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1607
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
1608
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1609
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
1610
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
1611
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
1612
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
1613
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
1614
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
1615
|
-
// State / operation
|
|
1616
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1617
|
-
// Matrix
|
|
1618
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
1619
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
1620
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
1621
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
1622
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
1623
|
-
};
|
|
1624
|
-
|
|
1625
|
-
// src/common/index.ts
|
|
1626
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1627
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1628
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1629
|
-
return DFSOperation2;
|
|
1630
|
-
})(DFSOperation || {});
|
|
1631
|
-
var Range = class {
|
|
1632
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1633
|
-
this.low = low;
|
|
1634
|
-
this.high = high;
|
|
1635
|
-
this.includeLow = includeLow;
|
|
1636
|
-
this.includeHigh = includeHigh;
|
|
1637
|
-
}
|
|
1638
|
-
// Determine whether a key is within the range
|
|
1639
|
-
isInRange(key, comparator) {
|
|
1640
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1641
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1642
|
-
return lowCheck && highCheck;
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
|
|
1646
2012
|
// src/data-structures/queue/queue.ts
|
|
1647
2013
|
var Queue = class _Queue extends LinearBase {
|
|
1648
2014
|
/**
|
|
@@ -1711,6 +2077,30 @@ var queueTyped = (() => {
|
|
|
1711
2077
|
|
|
1712
2078
|
|
|
1713
2079
|
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
|
|
2096
|
+
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
|
|
2101
|
+
|
|
2102
|
+
|
|
2103
|
+
|
|
1714
2104
|
* @example
|
|
1715
2105
|
* // Track queue length
|
|
1716
2106
|
* const q = new Queue<number>();
|
|
@@ -1737,6 +2127,30 @@ var queueTyped = (() => {
|
|
|
1737
2127
|
|
|
1738
2128
|
|
|
1739
2129
|
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
1740
2154
|
* @example
|
|
1741
2155
|
* // View the front element
|
|
1742
2156
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -1779,6 +2193,30 @@ var queueTyped = (() => {
|
|
|
1779
2193
|
|
|
1780
2194
|
|
|
1781
2195
|
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
2219
|
+
|
|
1782
2220
|
* @example
|
|
1783
2221
|
* // Queue for...of iteration and isEmpty check
|
|
1784
2222
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1817,6 +2255,30 @@ var queueTyped = (() => {
|
|
|
1817
2255
|
|
|
1818
2256
|
|
|
1819
2257
|
|
|
2258
|
+
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
|
|
2274
|
+
|
|
2275
|
+
|
|
2276
|
+
|
|
2277
|
+
|
|
2278
|
+
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
|
|
1820
2282
|
* @example
|
|
1821
2283
|
* // basic Queue creation and push operation
|
|
1822
2284
|
* // Create a simple Queue with initial values
|
|
@@ -1862,6 +2324,30 @@ var queueTyped = (() => {
|
|
|
1862
2324
|
|
|
1863
2325
|
|
|
1864
2326
|
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
|
|
1865
2351
|
* @example
|
|
1866
2352
|
* // Queue shift and peek operations
|
|
1867
2353
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -1897,6 +2383,30 @@ var queueTyped = (() => {
|
|
|
1897
2383
|
|
|
1898
2384
|
|
|
1899
2385
|
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
|
|
2406
|
+
|
|
2407
|
+
|
|
2408
|
+
|
|
2409
|
+
|
|
1900
2410
|
* @example
|
|
1901
2411
|
* // Remove specific element
|
|
1902
2412
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -1925,6 +2435,30 @@ var queueTyped = (() => {
|
|
|
1925
2435
|
|
|
1926
2436
|
|
|
1927
2437
|
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
|
|
1928
2462
|
* @example
|
|
1929
2463
|
* // Access element by index
|
|
1930
2464
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1994,6 +2528,30 @@ var queueTyped = (() => {
|
|
|
1994
2528
|
|
|
1995
2529
|
|
|
1996
2530
|
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
|
|
2548
|
+
|
|
2549
|
+
|
|
2550
|
+
|
|
2551
|
+
|
|
2552
|
+
|
|
2553
|
+
|
|
2554
|
+
|
|
1997
2555
|
* @example
|
|
1998
2556
|
* // Remove all elements
|
|
1999
2557
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2016,6 +2574,30 @@ var queueTyped = (() => {
|
|
|
2016
2574
|
|
|
2017
2575
|
|
|
2018
2576
|
|
|
2577
|
+
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
|
|
2599
|
+
|
|
2600
|
+
|
|
2019
2601
|
* @example
|
|
2020
2602
|
* // Reclaim unused memory
|
|
2021
2603
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -2061,6 +2643,30 @@ var queueTyped = (() => {
|
|
|
2061
2643
|
|
|
2062
2644
|
|
|
2063
2645
|
|
|
2646
|
+
|
|
2647
|
+
|
|
2648
|
+
|
|
2649
|
+
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
2064
2670
|
* @example
|
|
2065
2671
|
* // Create independent copy
|
|
2066
2672
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2090,6 +2696,30 @@ var queueTyped = (() => {
|
|
|
2090
2696
|
|
|
2091
2697
|
|
|
2092
2698
|
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2093
2723
|
* @example
|
|
2094
2724
|
* // Filter elements
|
|
2095
2725
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -2123,6 +2753,30 @@ var queueTyped = (() => {
|
|
|
2123
2753
|
|
|
2124
2754
|
|
|
2125
2755
|
|
|
2756
|
+
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
|
|
2770
|
+
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2126
2780
|
* @example
|
|
2127
2781
|
* // Transform elements
|
|
2128
2782
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2373,6 +3027,30 @@ var queueTyped = (() => {
|
|
|
2373
3027
|
|
|
2374
3028
|
|
|
2375
3029
|
|
|
3030
|
+
|
|
3031
|
+
|
|
3032
|
+
|
|
3033
|
+
|
|
3034
|
+
|
|
3035
|
+
|
|
3036
|
+
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
|
|
3040
|
+
|
|
3041
|
+
|
|
3042
|
+
|
|
3043
|
+
|
|
3044
|
+
|
|
3045
|
+
|
|
3046
|
+
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
|
|
3050
|
+
|
|
3051
|
+
|
|
3052
|
+
|
|
3053
|
+
|
|
2376
3054
|
* @example
|
|
2377
3055
|
* // Deque peek at both ends
|
|
2378
3056
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -2407,6 +3085,30 @@ var queueTyped = (() => {
|
|
|
2407
3085
|
|
|
2408
3086
|
|
|
2409
3087
|
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
|
|
3094
|
+
|
|
3095
|
+
|
|
3096
|
+
|
|
3097
|
+
|
|
3098
|
+
|
|
3099
|
+
|
|
3100
|
+
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
|
|
3104
|
+
|
|
3105
|
+
|
|
3106
|
+
|
|
3107
|
+
|
|
3108
|
+
|
|
3109
|
+
|
|
3110
|
+
|
|
3111
|
+
|
|
2410
3112
|
* @example
|
|
2411
3113
|
* // Peek at the back element
|
|
2412
3114
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -2446,6 +3148,30 @@ var queueTyped = (() => {
|
|
|
2446
3148
|
|
|
2447
3149
|
|
|
2448
3150
|
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
|
|
3154
|
+
|
|
3155
|
+
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
|
|
3161
|
+
|
|
3162
|
+
|
|
3163
|
+
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
|
|
3167
|
+
|
|
3168
|
+
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
|
|
3173
|
+
|
|
3174
|
+
|
|
2449
3175
|
* @example
|
|
2450
3176
|
* // basic Deque creation and push/pop operations
|
|
2451
3177
|
* // Create a simple Deque with initial values
|
|
@@ -2498,6 +3224,30 @@ var queueTyped = (() => {
|
|
|
2498
3224
|
|
|
2499
3225
|
|
|
2500
3226
|
|
|
3227
|
+
|
|
3228
|
+
|
|
3229
|
+
|
|
3230
|
+
|
|
3231
|
+
|
|
3232
|
+
|
|
3233
|
+
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
2501
3251
|
* @example
|
|
2502
3252
|
* // Remove from the back
|
|
2503
3253
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -2537,6 +3287,30 @@ var queueTyped = (() => {
|
|
|
2537
3287
|
|
|
2538
3288
|
|
|
2539
3289
|
|
|
3290
|
+
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
|
|
2540
3314
|
* @example
|
|
2541
3315
|
* // Remove from the front
|
|
2542
3316
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -2577,6 +3351,30 @@ var queueTyped = (() => {
|
|
|
2577
3351
|
|
|
2578
3352
|
|
|
2579
3353
|
|
|
3354
|
+
|
|
3355
|
+
|
|
3356
|
+
|
|
3357
|
+
|
|
3358
|
+
|
|
3359
|
+
|
|
3360
|
+
|
|
3361
|
+
|
|
3362
|
+
|
|
3363
|
+
|
|
3364
|
+
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
|
|
2580
3378
|
* @example
|
|
2581
3379
|
* // Deque shift and unshift operations
|
|
2582
3380
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -2658,6 +3456,30 @@ var queueTyped = (() => {
|
|
|
2658
3456
|
|
|
2659
3457
|
|
|
2660
3458
|
|
|
3459
|
+
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
|
|
3463
|
+
|
|
3464
|
+
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
|
|
3473
|
+
|
|
3474
|
+
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
|
|
3480
|
+
|
|
3481
|
+
|
|
3482
|
+
|
|
2661
3483
|
* @example
|
|
2662
3484
|
* // Check if empty
|
|
2663
3485
|
* const dq = new Deque();
|
|
@@ -2679,6 +3501,30 @@ var queueTyped = (() => {
|
|
|
2679
3501
|
|
|
2680
3502
|
|
|
2681
3503
|
|
|
3504
|
+
|
|
3505
|
+
|
|
3506
|
+
|
|
3507
|
+
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
|
|
3513
|
+
|
|
3514
|
+
|
|
3515
|
+
|
|
3516
|
+
|
|
3517
|
+
|
|
3518
|
+
|
|
3519
|
+
|
|
3520
|
+
|
|
3521
|
+
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
|
|
3525
|
+
|
|
3526
|
+
|
|
3527
|
+
|
|
2682
3528
|
* @example
|
|
2683
3529
|
* // Remove all elements
|
|
2684
3530
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -2704,6 +3550,30 @@ var queueTyped = (() => {
|
|
|
2704
3550
|
|
|
2705
3551
|
|
|
2706
3552
|
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
|
|
3559
|
+
|
|
3560
|
+
|
|
3561
|
+
|
|
3562
|
+
|
|
3563
|
+
|
|
3564
|
+
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
|
|
3568
|
+
|
|
3569
|
+
|
|
3570
|
+
|
|
3571
|
+
|
|
3572
|
+
|
|
3573
|
+
|
|
3574
|
+
|
|
3575
|
+
|
|
3576
|
+
|
|
2707
3577
|
* @example
|
|
2708
3578
|
* // Access by index
|
|
2709
3579
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -2880,6 +3750,30 @@ var queueTyped = (() => {
|
|
|
2880
3750
|
|
|
2881
3751
|
|
|
2882
3752
|
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
|
|
3758
|
+
|
|
3759
|
+
|
|
3760
|
+
|
|
3761
|
+
|
|
3762
|
+
|
|
3763
|
+
|
|
3764
|
+
|
|
3765
|
+
|
|
3766
|
+
|
|
3767
|
+
|
|
3768
|
+
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
|
|
3772
|
+
|
|
3773
|
+
|
|
3774
|
+
|
|
3775
|
+
|
|
3776
|
+
|
|
2883
3777
|
* @example
|
|
2884
3778
|
* // Remove element
|
|
2885
3779
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -2943,6 +3837,30 @@ var queueTyped = (() => {
|
|
|
2943
3837
|
|
|
2944
3838
|
|
|
2945
3839
|
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3844
|
+
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
|
|
3849
|
+
|
|
3850
|
+
|
|
3851
|
+
|
|
3852
|
+
|
|
3853
|
+
|
|
3854
|
+
|
|
3855
|
+
|
|
3856
|
+
|
|
3857
|
+
|
|
3858
|
+
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
2946
3864
|
* @example
|
|
2947
3865
|
* // Deque for...of iteration and reverse
|
|
2948
3866
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -3031,6 +3949,30 @@ var queueTyped = (() => {
|
|
|
3031
3949
|
|
|
3032
3950
|
|
|
3033
3951
|
|
|
3952
|
+
|
|
3953
|
+
|
|
3954
|
+
|
|
3955
|
+
|
|
3956
|
+
|
|
3957
|
+
|
|
3958
|
+
|
|
3959
|
+
|
|
3960
|
+
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
|
|
3973
|
+
|
|
3974
|
+
|
|
3975
|
+
|
|
3034
3976
|
* @example
|
|
3035
3977
|
* // Reclaim memory
|
|
3036
3978
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -3078,6 +4020,30 @@ var queueTyped = (() => {
|
|
|
3078
4020
|
|
|
3079
4021
|
|
|
3080
4022
|
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
3081
4047
|
* @example
|
|
3082
4048
|
* // Create independent copy
|
|
3083
4049
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -3108,6 +4074,30 @@ var queueTyped = (() => {
|
|
|
3108
4074
|
|
|
3109
4075
|
|
|
3110
4076
|
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
4100
|
+
|
|
3111
4101
|
* @example
|
|
3112
4102
|
* // Filter elements
|
|
3113
4103
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
@@ -3158,6 +4148,30 @@ var queueTyped = (() => {
|
|
|
3158
4148
|
|
|
3159
4149
|
|
|
3160
4150
|
|
|
4151
|
+
|
|
4152
|
+
|
|
4153
|
+
|
|
4154
|
+
|
|
4155
|
+
|
|
4156
|
+
|
|
4157
|
+
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
3161
4175
|
* @example
|
|
3162
4176
|
* // Transform elements
|
|
3163
4177
|
* const dq = new Deque<number>([1, 2, 3]);
|