deque-typed 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +418 -51
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +417 -50
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +418 -52
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +417 -51
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
- package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
- package/dist/types/data-structures/heap/heap.d.ts +336 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
- package/dist/types/data-structures/queue/deque.d.ts +364 -4
- package/dist/types/data-structures/queue/queue.d.ts +288 -0
- package/dist/types/data-structures/stack/stack.d.ts +240 -0
- package/dist/types/data-structures/trie/trie.d.ts +292 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/deque-typed.js +415 -49
- package/dist/umd/deque-typed.js.map +1 -1
- package/dist/umd/deque-typed.min.js +1 -1
- package/dist/umd/deque-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/deque-typed.js
CHANGED
|
@@ -26,7 +26,8 @@ var dequeTyped = (() => {
|
|
|
26
26
|
DFSOperation: () => DFSOperation,
|
|
27
27
|
Deque: () => Deque,
|
|
28
28
|
ERR: () => ERR,
|
|
29
|
-
Range: () => Range
|
|
29
|
+
Range: () => Range,
|
|
30
|
+
raise: () => raise
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
// src/utils/utils.ts
|
|
@@ -37,6 +38,57 @@ var dequeTyped = (() => {
|
|
|
37
38
|
};
|
|
38
39
|
var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
|
|
39
40
|
|
|
41
|
+
// src/common/error.ts
|
|
42
|
+
function raise(ErrorClass, message) {
|
|
43
|
+
throw new ErrorClass(message);
|
|
44
|
+
}
|
|
45
|
+
var ERR = {
|
|
46
|
+
// Range / index
|
|
47
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
48
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
49
|
+
// Type / argument
|
|
50
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
51
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
52
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
53
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
54
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
55
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
56
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
57
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
58
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
59
|
+
// State / operation
|
|
60
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
61
|
+
// Matrix
|
|
62
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
63
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
64
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
65
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
66
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
67
|
+
// Order statistic
|
|
68
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/common/index.ts
|
|
72
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
73
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
74
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
75
|
+
return DFSOperation2;
|
|
76
|
+
})(DFSOperation || {});
|
|
77
|
+
var Range = class {
|
|
78
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
79
|
+
this.low = low;
|
|
80
|
+
this.high = high;
|
|
81
|
+
this.includeLow = includeLow;
|
|
82
|
+
this.includeHigh = includeHigh;
|
|
83
|
+
}
|
|
84
|
+
// Determine whether a key is within the range
|
|
85
|
+
isInRange(key, comparator) {
|
|
86
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
87
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
88
|
+
return lowCheck && highCheck;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
40
92
|
// src/data-structures/base/iterable-element-base.ts
|
|
41
93
|
var IterableElementBase = class {
|
|
42
94
|
/**
|
|
@@ -59,7 +111,7 @@ var dequeTyped = (() => {
|
|
|
59
111
|
if (options) {
|
|
60
112
|
const { toElementFn } = options;
|
|
61
113
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
62
|
-
else if (toElementFn)
|
|
114
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
63
115
|
}
|
|
64
116
|
}
|
|
65
117
|
/**
|
|
@@ -215,7 +267,7 @@ var dequeTyped = (() => {
|
|
|
215
267
|
acc = initialValue;
|
|
216
268
|
} else {
|
|
217
269
|
const first = iter.next();
|
|
218
|
-
if (first.done)
|
|
270
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
219
271
|
acc = first.value;
|
|
220
272
|
index = 1;
|
|
221
273
|
}
|
|
@@ -583,6 +635,30 @@ var dequeTyped = (() => {
|
|
|
583
635
|
|
|
584
636
|
|
|
585
637
|
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
586
662
|
* @example
|
|
587
663
|
* // Deque peek at both ends
|
|
588
664
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -617,6 +693,30 @@ var dequeTyped = (() => {
|
|
|
617
693
|
|
|
618
694
|
|
|
619
695
|
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
620
720
|
* @example
|
|
621
721
|
* // Peek at the back element
|
|
622
722
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -656,6 +756,30 @@ var dequeTyped = (() => {
|
|
|
656
756
|
|
|
657
757
|
|
|
658
758
|
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
659
783
|
* @example
|
|
660
784
|
* // basic Deque creation and push/pop operations
|
|
661
785
|
* // Create a simple Deque with initial values
|
|
@@ -708,6 +832,30 @@ var dequeTyped = (() => {
|
|
|
708
832
|
|
|
709
833
|
|
|
710
834
|
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
711
859
|
* @example
|
|
712
860
|
* // Remove from the back
|
|
713
861
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -747,6 +895,30 @@ var dequeTyped = (() => {
|
|
|
747
895
|
|
|
748
896
|
|
|
749
897
|
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
750
922
|
* @example
|
|
751
923
|
* // Remove from the front
|
|
752
924
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -787,6 +959,30 @@ var dequeTyped = (() => {
|
|
|
787
959
|
|
|
788
960
|
|
|
789
961
|
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
790
986
|
* @example
|
|
791
987
|
* // Deque shift and unshift operations
|
|
792
988
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -868,6 +1064,30 @@ var dequeTyped = (() => {
|
|
|
868
1064
|
|
|
869
1065
|
|
|
870
1066
|
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
871
1091
|
* @example
|
|
872
1092
|
* // Check if empty
|
|
873
1093
|
* const dq = new Deque();
|
|
@@ -889,6 +1109,30 @@ var dequeTyped = (() => {
|
|
|
889
1109
|
|
|
890
1110
|
|
|
891
1111
|
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
892
1136
|
* @example
|
|
893
1137
|
* // Remove all elements
|
|
894
1138
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -914,6 +1158,30 @@ var dequeTyped = (() => {
|
|
|
914
1158
|
|
|
915
1159
|
|
|
916
1160
|
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
917
1185
|
* @example
|
|
918
1186
|
* // Access by index
|
|
919
1187
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -1090,6 +1358,30 @@ var dequeTyped = (() => {
|
|
|
1090
1358
|
|
|
1091
1359
|
|
|
1092
1360
|
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1093
1385
|
* @example
|
|
1094
1386
|
* // Remove element
|
|
1095
1387
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1153,6 +1445,30 @@ var dequeTyped = (() => {
|
|
|
1153
1445
|
|
|
1154
1446
|
|
|
1155
1447
|
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1156
1472
|
* @example
|
|
1157
1473
|
* // Deque for...of iteration and reverse
|
|
1158
1474
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1241,6 +1557,30 @@ var dequeTyped = (() => {
|
|
|
1241
1557
|
|
|
1242
1558
|
|
|
1243
1559
|
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
|
|
1244
1584
|
* @example
|
|
1245
1585
|
* // Reclaim memory
|
|
1246
1586
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -1288,6 +1628,30 @@ var dequeTyped = (() => {
|
|
|
1288
1628
|
|
|
1289
1629
|
|
|
1290
1630
|
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
|
|
1291
1655
|
* @example
|
|
1292
1656
|
* // Create independent copy
|
|
1293
1657
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1318,6 +1682,30 @@ var dequeTyped = (() => {
|
|
|
1318
1682
|
|
|
1319
1683
|
|
|
1320
1684
|
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
|
|
1321
1709
|
* @example
|
|
1322
1710
|
* // Filter elements
|
|
1323
1711
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
@@ -1368,6 +1756,30 @@ var dequeTyped = (() => {
|
|
|
1368
1756
|
|
|
1369
1757
|
|
|
1370
1758
|
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1371
1783
|
* @example
|
|
1372
1784
|
* // Transform elements
|
|
1373
1785
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1496,52 +1908,6 @@ var dequeTyped = (() => {
|
|
|
1496
1908
|
}
|
|
1497
1909
|
}
|
|
1498
1910
|
};
|
|
1499
|
-
|
|
1500
|
-
// src/common/error.ts
|
|
1501
|
-
var ERR = {
|
|
1502
|
-
// Range / index
|
|
1503
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
1504
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
1505
|
-
// Type / argument
|
|
1506
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1507
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
1508
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1509
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
1510
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
1511
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
1512
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
1513
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
1514
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
1515
|
-
// State / operation
|
|
1516
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
1517
|
-
// Matrix
|
|
1518
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
1519
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
1520
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
1521
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
1522
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
1523
|
-
};
|
|
1524
|
-
|
|
1525
|
-
// src/common/index.ts
|
|
1526
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1527
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1528
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1529
|
-
return DFSOperation2;
|
|
1530
|
-
})(DFSOperation || {});
|
|
1531
|
-
var Range = class {
|
|
1532
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1533
|
-
this.low = low;
|
|
1534
|
-
this.high = high;
|
|
1535
|
-
this.includeLow = includeLow;
|
|
1536
|
-
this.includeHigh = includeHigh;
|
|
1537
|
-
}
|
|
1538
|
-
// Determine whether a key is within the range
|
|
1539
|
-
isInRange(key, comparator) {
|
|
1540
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1541
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1542
|
-
return lowCheck && highCheck;
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
1911
|
return __toCommonJS(src_exports);
|
|
1546
1912
|
})();
|
|
1547
1913
|
/**
|