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/cjs/index.cjs
CHANGED
|
@@ -11,6 +11,61 @@ var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
|
|
|
11
11
|
}, "rangeCheck");
|
|
12
12
|
var calcMinUnitsRequired = /* @__PURE__ */ __name((totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize), "calcMinUnitsRequired");
|
|
13
13
|
|
|
14
|
+
// src/common/error.ts
|
|
15
|
+
function raise(ErrorClass, message) {
|
|
16
|
+
throw new ErrorClass(message);
|
|
17
|
+
}
|
|
18
|
+
__name(raise, "raise");
|
|
19
|
+
var ERR = {
|
|
20
|
+
// Range / index
|
|
21
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
22
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
23
|
+
// Type / argument
|
|
24
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
25
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
26
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
27
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
28
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
29
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
30
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
31
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
32
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
33
|
+
// State / operation
|
|
34
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
35
|
+
// Matrix
|
|
36
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
37
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
38
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
39
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
40
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
41
|
+
// Order statistic
|
|
42
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/common/index.ts
|
|
46
|
+
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
47
|
+
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
48
|
+
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
49
|
+
return DFSOperation2;
|
|
50
|
+
})(DFSOperation || {});
|
|
51
|
+
var Range = class {
|
|
52
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
53
|
+
this.low = low;
|
|
54
|
+
this.high = high;
|
|
55
|
+
this.includeLow = includeLow;
|
|
56
|
+
this.includeHigh = includeHigh;
|
|
57
|
+
}
|
|
58
|
+
static {
|
|
59
|
+
__name(this, "Range");
|
|
60
|
+
}
|
|
61
|
+
// Determine whether a key is within the range
|
|
62
|
+
isInRange(key, comparator) {
|
|
63
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
64
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
65
|
+
return lowCheck && highCheck;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
14
69
|
// src/data-structures/base/iterable-element-base.ts
|
|
15
70
|
var IterableElementBase = class {
|
|
16
71
|
static {
|
|
@@ -29,7 +84,7 @@ var IterableElementBase = class {
|
|
|
29
84
|
if (options) {
|
|
30
85
|
const { toElementFn } = options;
|
|
31
86
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
32
|
-
else if (toElementFn)
|
|
87
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
33
88
|
}
|
|
34
89
|
}
|
|
35
90
|
/**
|
|
@@ -192,7 +247,7 @@ var IterableElementBase = class {
|
|
|
192
247
|
acc = initialValue;
|
|
193
248
|
} else {
|
|
194
249
|
const first = iter.next();
|
|
195
|
-
if (first.done)
|
|
250
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
196
251
|
acc = first.value;
|
|
197
252
|
index = 1;
|
|
198
253
|
}
|
|
@@ -566,6 +621,30 @@ var Deque = class extends LinearBase {
|
|
|
566
621
|
|
|
567
622
|
|
|
568
623
|
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
569
648
|
* @example
|
|
570
649
|
* // Deque peek at both ends
|
|
571
650
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -600,6 +679,30 @@ var Deque = class extends LinearBase {
|
|
|
600
679
|
|
|
601
680
|
|
|
602
681
|
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
603
706
|
* @example
|
|
604
707
|
* // Peek at the back element
|
|
605
708
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -639,6 +742,30 @@ var Deque = class extends LinearBase {
|
|
|
639
742
|
|
|
640
743
|
|
|
641
744
|
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
642
769
|
* @example
|
|
643
770
|
* // basic Deque creation and push/pop operations
|
|
644
771
|
* // Create a simple Deque with initial values
|
|
@@ -691,6 +818,30 @@ var Deque = class extends LinearBase {
|
|
|
691
818
|
|
|
692
819
|
|
|
693
820
|
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
694
845
|
* @example
|
|
695
846
|
* // Remove from the back
|
|
696
847
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -730,6 +881,30 @@ var Deque = class extends LinearBase {
|
|
|
730
881
|
|
|
731
882
|
|
|
732
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
|
+
|
|
733
908
|
* @example
|
|
734
909
|
* // Remove from the front
|
|
735
910
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -770,6 +945,30 @@ var Deque = class extends LinearBase {
|
|
|
770
945
|
|
|
771
946
|
|
|
772
947
|
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
773
972
|
* @example
|
|
774
973
|
* // Deque shift and unshift operations
|
|
775
974
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -851,6 +1050,30 @@ var Deque = class extends LinearBase {
|
|
|
851
1050
|
|
|
852
1051
|
|
|
853
1052
|
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
854
1077
|
* @example
|
|
855
1078
|
* // Check if empty
|
|
856
1079
|
* const dq = new Deque();
|
|
@@ -872,6 +1095,30 @@ var Deque = class extends LinearBase {
|
|
|
872
1095
|
|
|
873
1096
|
|
|
874
1097
|
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
875
1122
|
* @example
|
|
876
1123
|
* // Remove all elements
|
|
877
1124
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -897,6 +1144,30 @@ var Deque = class extends LinearBase {
|
|
|
897
1144
|
|
|
898
1145
|
|
|
899
1146
|
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
900
1171
|
* @example
|
|
901
1172
|
* // Access by index
|
|
902
1173
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -1073,6 +1344,30 @@ var Deque = class extends LinearBase {
|
|
|
1073
1344
|
|
|
1074
1345
|
|
|
1075
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
|
+
|
|
1076
1371
|
* @example
|
|
1077
1372
|
* // Remove element
|
|
1078
1373
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1136,6 +1431,30 @@ var Deque = class extends LinearBase {
|
|
|
1136
1431
|
|
|
1137
1432
|
|
|
1138
1433
|
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1139
1458
|
* @example
|
|
1140
1459
|
* // Deque for...of iteration and reverse
|
|
1141
1460
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1224,6 +1543,30 @@ var Deque = class extends LinearBase {
|
|
|
1224
1543
|
|
|
1225
1544
|
|
|
1226
1545
|
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1227
1570
|
* @example
|
|
1228
1571
|
* // Reclaim memory
|
|
1229
1572
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -1271,6 +1614,30 @@ var Deque = class extends LinearBase {
|
|
|
1271
1614
|
|
|
1272
1615
|
|
|
1273
1616
|
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
|
|
1274
1641
|
* @example
|
|
1275
1642
|
* // Create independent copy
|
|
1276
1643
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1301,6 +1668,30 @@ var Deque = class extends LinearBase {
|
|
|
1301
1668
|
|
|
1302
1669
|
|
|
1303
1670
|
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
|
|
1304
1695
|
* @example
|
|
1305
1696
|
* // Filter elements
|
|
1306
1697
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
@@ -1351,6 +1742,30 @@ var Deque = class extends LinearBase {
|
|
|
1351
1742
|
|
|
1352
1743
|
|
|
1353
1744
|
|
|
1745
|
+
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
|
|
1749
|
+
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
|
|
1354
1769
|
* @example
|
|
1355
1770
|
* // Transform elements
|
|
1356
1771
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1479,55 +1894,6 @@ var Deque = class extends LinearBase {
|
|
|
1479
1894
|
}
|
|
1480
1895
|
}
|
|
1481
1896
|
};
|
|
1482
|
-
|
|
1483
|
-
// src/common/error.ts
|
|
1484
|
-
var ERR = {
|
|
1485
|
-
// Range / index
|
|
1486
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
1487
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
1488
|
-
// Type / argument
|
|
1489
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
1490
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
1491
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
1492
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
1493
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
1494
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
1495
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
1496
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
1497
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
1498
|
-
// State / operation
|
|
1499
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
1500
|
-
// Matrix
|
|
1501
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
1502
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
1503
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
1504
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
1505
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
1506
|
-
};
|
|
1507
|
-
|
|
1508
|
-
// src/common/index.ts
|
|
1509
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1510
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1511
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1512
|
-
return DFSOperation2;
|
|
1513
|
-
})(DFSOperation || {});
|
|
1514
|
-
var Range = class {
|
|
1515
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1516
|
-
this.low = low;
|
|
1517
|
-
this.high = high;
|
|
1518
|
-
this.includeLow = includeLow;
|
|
1519
|
-
this.includeHigh = includeHigh;
|
|
1520
|
-
}
|
|
1521
|
-
static {
|
|
1522
|
-
__name(this, "Range");
|
|
1523
|
-
}
|
|
1524
|
-
// Determine whether a key is within the range
|
|
1525
|
-
isInRange(key, comparator) {
|
|
1526
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1527
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1528
|
-
return lowCheck && highCheck;
|
|
1529
|
-
}
|
|
1530
|
-
};
|
|
1531
1897
|
/**
|
|
1532
1898
|
* data-structure-typed
|
|
1533
1899
|
*
|
|
@@ -1540,5 +1906,6 @@ exports.DFSOperation = DFSOperation;
|
|
|
1540
1906
|
exports.Deque = Deque;
|
|
1541
1907
|
exports.ERR = ERR;
|
|
1542
1908
|
exports.Range = Range;
|
|
1909
|
+
exports.raise = raise;
|
|
1543
1910
|
//# sourceMappingURL=index.cjs.map
|
|
1544
1911
|
//# sourceMappingURL=index.cjs.map
|