queue-typed 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +399 -51
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +398 -50
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +399 -52
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +398 -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/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +127 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/queue-typed.js +396 -49
- 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/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
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
|
}
|
|
@@ -765,6 +817,13 @@ var queueTyped = (() => {
|
|
|
765
817
|
|
|
766
818
|
|
|
767
819
|
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
768
827
|
|
|
769
828
|
|
|
770
829
|
|
|
@@ -829,6 +888,13 @@ var queueTyped = (() => {
|
|
|
829
888
|
|
|
830
889
|
|
|
831
890
|
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
832
898
|
|
|
833
899
|
|
|
834
900
|
|
|
@@ -899,6 +965,13 @@ var queueTyped = (() => {
|
|
|
899
965
|
|
|
900
966
|
|
|
901
967
|
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
902
975
|
|
|
903
976
|
|
|
904
977
|
|
|
@@ -950,6 +1023,13 @@ var queueTyped = (() => {
|
|
|
950
1023
|
|
|
951
1024
|
|
|
952
1025
|
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
953
1033
|
|
|
954
1034
|
|
|
955
1035
|
|
|
@@ -1062,6 +1142,13 @@ var queueTyped = (() => {
|
|
|
1062
1142
|
|
|
1063
1143
|
|
|
1064
1144
|
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1065
1152
|
|
|
1066
1153
|
|
|
1067
1154
|
|
|
@@ -1118,6 +1205,13 @@ var queueTyped = (() => {
|
|
|
1118
1205
|
|
|
1119
1206
|
|
|
1120
1207
|
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1121
1215
|
|
|
1122
1216
|
|
|
1123
1217
|
|
|
@@ -1163,6 +1257,13 @@ var queueTyped = (() => {
|
|
|
1163
1257
|
|
|
1164
1258
|
|
|
1165
1259
|
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1166
1267
|
|
|
1167
1268
|
|
|
1168
1269
|
|
|
@@ -1214,6 +1315,13 @@ var queueTyped = (() => {
|
|
|
1214
1315
|
|
|
1215
1316
|
|
|
1216
1317
|
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1217
1325
|
|
|
1218
1326
|
|
|
1219
1327
|
|
|
@@ -1270,6 +1378,13 @@ var queueTyped = (() => {
|
|
|
1270
1378
|
|
|
1271
1379
|
|
|
1272
1380
|
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
|
|
1273
1388
|
|
|
1274
1389
|
|
|
1275
1390
|
|
|
@@ -1334,6 +1449,13 @@ var queueTyped = (() => {
|
|
|
1334
1449
|
|
|
1335
1450
|
|
|
1336
1451
|
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1337
1459
|
|
|
1338
1460
|
|
|
1339
1461
|
|
|
@@ -1375,6 +1497,13 @@ var queueTyped = (() => {
|
|
|
1375
1497
|
|
|
1376
1498
|
|
|
1377
1499
|
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1378
1507
|
|
|
1379
1508
|
|
|
1380
1509
|
|
|
@@ -1422,6 +1551,13 @@ var queueTyped = (() => {
|
|
|
1422
1551
|
|
|
1423
1552
|
|
|
1424
1553
|
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1425
1561
|
|
|
1426
1562
|
|
|
1427
1563
|
|
|
@@ -1635,6 +1771,13 @@ var queueTyped = (() => {
|
|
|
1635
1771
|
|
|
1636
1772
|
|
|
1637
1773
|
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1638
1781
|
|
|
1639
1782
|
|
|
1640
1783
|
|
|
@@ -1686,6 +1829,13 @@ var queueTyped = (() => {
|
|
|
1686
1829
|
|
|
1687
1830
|
|
|
1688
1831
|
|
|
1832
|
+
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
|
|
1689
1839
|
|
|
1690
1840
|
|
|
1691
1841
|
|
|
@@ -1765,6 +1915,13 @@ var queueTyped = (() => {
|
|
|
1765
1915
|
|
|
1766
1916
|
|
|
1767
1917
|
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1768
1925
|
|
|
1769
1926
|
|
|
1770
1927
|
|
|
@@ -1912,52 +2069,6 @@ var queueTyped = (() => {
|
|
|
1912
2069
|
return (node) => equals(node.value, value);
|
|
1913
2070
|
}
|
|
1914
2071
|
|
|
1915
|
-
// src/common/error.ts
|
|
1916
|
-
var ERR = {
|
|
1917
|
-
// Range / index
|
|
1918
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
1919
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
1920
|
-
// Type / argument
|
|
1921
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1922
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
1923
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1924
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
1925
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
1926
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
1927
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
1928
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
1929
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
1930
|
-
// State / operation
|
|
1931
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1932
|
-
// Matrix
|
|
1933
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
1934
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
1935
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
1936
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
1937
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
1938
|
-
};
|
|
1939
|
-
|
|
1940
|
-
// src/common/index.ts
|
|
1941
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1942
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1943
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1944
|
-
return DFSOperation2;
|
|
1945
|
-
})(DFSOperation || {});
|
|
1946
|
-
var Range = class {
|
|
1947
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1948
|
-
this.low = low;
|
|
1949
|
-
this.high = high;
|
|
1950
|
-
this.includeLow = includeLow;
|
|
1951
|
-
this.includeHigh = includeHigh;
|
|
1952
|
-
}
|
|
1953
|
-
// Determine whether a key is within the range
|
|
1954
|
-
isInRange(key, comparator) {
|
|
1955
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1956
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1957
|
-
return lowCheck && highCheck;
|
|
1958
|
-
}
|
|
1959
|
-
};
|
|
1960
|
-
|
|
1961
2072
|
// src/data-structures/queue/queue.ts
|
|
1962
2073
|
var Queue = class _Queue extends LinearBase {
|
|
1963
2074
|
/**
|
|
@@ -2039,6 +2150,13 @@ var queueTyped = (() => {
|
|
|
2039
2150
|
|
|
2040
2151
|
|
|
2041
2152
|
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
|
|
2042
2160
|
|
|
2043
2161
|
|
|
2044
2162
|
|
|
@@ -2086,6 +2204,13 @@ var queueTyped = (() => {
|
|
|
2086
2204
|
|
|
2087
2205
|
|
|
2088
2206
|
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
|
|
2089
2214
|
|
|
2090
2215
|
|
|
2091
2216
|
|
|
@@ -2103,6 +2228,14 @@ var queueTyped = (() => {
|
|
|
2103
2228
|
get first() {
|
|
2104
2229
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
2105
2230
|
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
2233
|
+
* @remarks Time O(1), Space O(1)
|
|
2234
|
+
* @returns Front element or undefined.
|
|
2235
|
+
*/
|
|
2236
|
+
peek() {
|
|
2237
|
+
return this.first;
|
|
2238
|
+
}
|
|
2106
2239
|
/**
|
|
2107
2240
|
* Get the last element (back) without removing it.
|
|
2108
2241
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2149,6 +2282,13 @@ var queueTyped = (() => {
|
|
|
2149
2282
|
|
|
2150
2283
|
|
|
2151
2284
|
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
|
|
2152
2292
|
|
|
2153
2293
|
|
|
2154
2294
|
|
|
@@ -2208,6 +2348,13 @@ var queueTyped = (() => {
|
|
|
2208
2348
|
|
|
2209
2349
|
|
|
2210
2350
|
|
|
2351
|
+
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
|
|
2211
2358
|
|
|
2212
2359
|
|
|
2213
2360
|
|
|
@@ -2274,6 +2421,13 @@ var queueTyped = (() => {
|
|
|
2274
2421
|
|
|
2275
2422
|
|
|
2276
2423
|
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2277
2431
|
|
|
2278
2432
|
|
|
2279
2433
|
|
|
@@ -2330,6 +2484,13 @@ var queueTyped = (() => {
|
|
|
2330
2484
|
|
|
2331
2485
|
|
|
2332
2486
|
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
|
|
2493
|
+
|
|
2333
2494
|
|
|
2334
2495
|
|
|
2335
2496
|
|
|
@@ -2379,6 +2540,13 @@ var queueTyped = (() => {
|
|
|
2379
2540
|
|
|
2380
2541
|
|
|
2381
2542
|
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
|
|
2548
|
+
|
|
2549
|
+
|
|
2382
2550
|
|
|
2383
2551
|
|
|
2384
2552
|
|
|
@@ -2433,6 +2601,21 @@ var queueTyped = (() => {
|
|
|
2433
2601
|
this._elements[this._offset + index] = newElement;
|
|
2434
2602
|
return true;
|
|
2435
2603
|
}
|
|
2604
|
+
/**
|
|
2605
|
+
* Delete the first element that satisfies a predicate.
|
|
2606
|
+
* @remarks Time O(N), Space O(N)
|
|
2607
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
2608
|
+
* @returns True if a match was removed.
|
|
2609
|
+
*/
|
|
2610
|
+
deleteWhere(predicate) {
|
|
2611
|
+
for (let i = 0; i < this.length; i++) {
|
|
2612
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
2613
|
+
this.deleteAt(i);
|
|
2614
|
+
return true;
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
return false;
|
|
2618
|
+
}
|
|
2436
2619
|
/**
|
|
2437
2620
|
* Reverse the queue in-place by compacting then reversing.
|
|
2438
2621
|
* @remarks Time O(N), Space O(N)
|
|
@@ -2469,6 +2652,13 @@ var queueTyped = (() => {
|
|
|
2469
2652
|
|
|
2470
2653
|
|
|
2471
2654
|
|
|
2655
|
+
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
|
|
2472
2662
|
|
|
2473
2663
|
|
|
2474
2664
|
|
|
@@ -2512,6 +2702,13 @@ var queueTyped = (() => {
|
|
|
2512
2702
|
|
|
2513
2703
|
|
|
2514
2704
|
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2515
2712
|
|
|
2516
2713
|
|
|
2517
2714
|
|
|
@@ -2578,6 +2775,13 @@ var queueTyped = (() => {
|
|
|
2578
2775
|
|
|
2579
2776
|
|
|
2580
2777
|
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2581
2785
|
|
|
2582
2786
|
|
|
2583
2787
|
|
|
@@ -2628,6 +2832,13 @@ var queueTyped = (() => {
|
|
|
2628
2832
|
|
|
2629
2833
|
|
|
2630
2834
|
|
|
2835
|
+
|
|
2836
|
+
|
|
2837
|
+
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
|
|
2841
|
+
|
|
2631
2842
|
|
|
2632
2843
|
|
|
2633
2844
|
|
|
@@ -2682,6 +2893,13 @@ var queueTyped = (() => {
|
|
|
2682
2893
|
|
|
2683
2894
|
|
|
2684
2895
|
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
|
|
2899
|
+
|
|
2900
|
+
|
|
2901
|
+
|
|
2902
|
+
|
|
2685
2903
|
|
|
2686
2904
|
|
|
2687
2905
|
|
|
@@ -2954,6 +3172,12 @@ var queueTyped = (() => {
|
|
|
2954
3172
|
|
|
2955
3173
|
|
|
2956
3174
|
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
|
|
3180
|
+
|
|
2957
3181
|
|
|
2958
3182
|
|
|
2959
3183
|
|
|
@@ -2974,6 +3198,31 @@ var queueTyped = (() => {
|
|
|
2974
3198
|
* console.log(last); // 50;
|
|
2975
3199
|
*
|
|
2976
3200
|
* // Length unchanged
|
|
3201
|
+
* console.log(deque.length); // 5;
|
|
3202
|
+
*/
|
|
3203
|
+
/**
|
|
3204
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
3205
|
+
* @remarks Time O(1), Space O(1)
|
|
3206
|
+
* @returns Front element or undefined.
|
|
3207
|
+
*/
|
|
3208
|
+
peek() {
|
|
3209
|
+
return this.first;
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Deque peek at both ends
|
|
3213
|
+
* @example
|
|
3214
|
+
* // Deque peek at both ends
|
|
3215
|
+
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
3216
|
+
*
|
|
3217
|
+
* // Get first element without removing
|
|
3218
|
+
* const first = deque.at(0);
|
|
3219
|
+
* console.log(first); // 10;
|
|
3220
|
+
*
|
|
3221
|
+
* // Get last element without removing
|
|
3222
|
+
* const last = deque.at(deque.length - 1);
|
|
3223
|
+
* console.log(last); // 50;
|
|
3224
|
+
*
|
|
3225
|
+
* // Length unchanged
|
|
2977
3226
|
* console.log(deque.length); // 5;
|
|
2978
3227
|
*/
|
|
2979
3228
|
get first() {
|
|
@@ -3008,6 +3257,13 @@ var queueTyped = (() => {
|
|
|
3008
3257
|
|
|
3009
3258
|
|
|
3010
3259
|
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
|
|
3011
3267
|
|
|
3012
3268
|
|
|
3013
3269
|
|
|
@@ -3068,6 +3324,13 @@ var queueTyped = (() => {
|
|
|
3068
3324
|
|
|
3069
3325
|
|
|
3070
3326
|
|
|
3327
|
+
|
|
3328
|
+
|
|
3329
|
+
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
|
|
3333
|
+
|
|
3071
3334
|
|
|
3072
3335
|
|
|
3073
3336
|
|
|
@@ -3141,6 +3404,13 @@ var queueTyped = (() => {
|
|
|
3141
3404
|
|
|
3142
3405
|
|
|
3143
3406
|
|
|
3407
|
+
|
|
3408
|
+
|
|
3409
|
+
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
|
|
3144
3414
|
|
|
3145
3415
|
|
|
3146
3416
|
|
|
@@ -3201,6 +3471,13 @@ var queueTyped = (() => {
|
|
|
3201
3471
|
|
|
3202
3472
|
|
|
3203
3473
|
|
|
3474
|
+
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
|
|
3480
|
+
|
|
3204
3481
|
|
|
3205
3482
|
|
|
3206
3483
|
|
|
@@ -3262,6 +3539,13 @@ var queueTyped = (() => {
|
|
|
3262
3539
|
|
|
3263
3540
|
|
|
3264
3541
|
|
|
3542
|
+
|
|
3543
|
+
|
|
3544
|
+
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
|
|
3548
|
+
|
|
3265
3549
|
|
|
3266
3550
|
|
|
3267
3551
|
|
|
@@ -3364,6 +3648,13 @@ var queueTyped = (() => {
|
|
|
3364
3648
|
|
|
3365
3649
|
|
|
3366
3650
|
|
|
3651
|
+
|
|
3652
|
+
|
|
3653
|
+
|
|
3654
|
+
|
|
3655
|
+
|
|
3656
|
+
|
|
3657
|
+
|
|
3367
3658
|
|
|
3368
3659
|
|
|
3369
3660
|
|
|
@@ -3406,6 +3697,13 @@ var queueTyped = (() => {
|
|
|
3406
3697
|
|
|
3407
3698
|
|
|
3408
3699
|
|
|
3700
|
+
|
|
3701
|
+
|
|
3702
|
+
|
|
3703
|
+
|
|
3704
|
+
|
|
3705
|
+
|
|
3706
|
+
|
|
3409
3707
|
|
|
3410
3708
|
|
|
3411
3709
|
|
|
@@ -3452,6 +3750,13 @@ var queueTyped = (() => {
|
|
|
3452
3750
|
|
|
3453
3751
|
|
|
3454
3752
|
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
|
|
3758
|
+
|
|
3759
|
+
|
|
3455
3760
|
|
|
3456
3761
|
|
|
3457
3762
|
|
|
@@ -3649,6 +3954,13 @@ var queueTyped = (() => {
|
|
|
3649
3954
|
|
|
3650
3955
|
|
|
3651
3956
|
|
|
3957
|
+
|
|
3958
|
+
|
|
3959
|
+
|
|
3960
|
+
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
|
|
3652
3964
|
|
|
3653
3965
|
|
|
3654
3966
|
|
|
@@ -3733,6 +4045,13 @@ var queueTyped = (() => {
|
|
|
3733
4045
|
|
|
3734
4046
|
|
|
3735
4047
|
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
3736
4055
|
|
|
3737
4056
|
|
|
3738
4057
|
|
|
@@ -3842,6 +4161,13 @@ var queueTyped = (() => {
|
|
|
3842
4161
|
|
|
3843
4162
|
|
|
3844
4163
|
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
3845
4171
|
|
|
3846
4172
|
|
|
3847
4173
|
|
|
@@ -3910,6 +4236,13 @@ var queueTyped = (() => {
|
|
|
3910
4236
|
|
|
3911
4237
|
|
|
3912
4238
|
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
|
|
4244
|
+
|
|
4245
|
+
|
|
3913
4246
|
|
|
3914
4247
|
|
|
3915
4248
|
|
|
@@ -3961,6 +4294,13 @@ var queueTyped = (() => {
|
|
|
3961
4294
|
|
|
3962
4295
|
|
|
3963
4296
|
|
|
4297
|
+
|
|
4298
|
+
|
|
4299
|
+
|
|
4300
|
+
|
|
4301
|
+
|
|
4302
|
+
|
|
4303
|
+
|
|
3964
4304
|
|
|
3965
4305
|
|
|
3966
4306
|
|
|
@@ -4032,6 +4372,13 @@ var queueTyped = (() => {
|
|
|
4032
4372
|
|
|
4033
4373
|
|
|
4034
4374
|
|
|
4375
|
+
|
|
4376
|
+
|
|
4377
|
+
|
|
4378
|
+
|
|
4379
|
+
|
|
4380
|
+
|
|
4381
|
+
|
|
4035
4382
|
|
|
4036
4383
|
|
|
4037
4384
|
|