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
|
@@ -11,6 +11,60 @@ 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 _Range {
|
|
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
|
+
// Determine whether a key is within the range
|
|
59
|
+
isInRange(key, comparator) {
|
|
60
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
61
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
62
|
+
return lowCheck && highCheck;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
__name(_Range, "Range");
|
|
66
|
+
var Range = _Range;
|
|
67
|
+
|
|
14
68
|
// src/data-structures/base/iterable-element-base.ts
|
|
15
69
|
var _IterableElementBase = class _IterableElementBase {
|
|
16
70
|
/**
|
|
@@ -33,7 +87,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
33
87
|
if (options) {
|
|
34
88
|
const { toElementFn } = options;
|
|
35
89
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
36
|
-
else if (toElementFn)
|
|
90
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
37
91
|
}
|
|
38
92
|
}
|
|
39
93
|
/**
|
|
@@ -189,7 +243,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
189
243
|
acc = initialValue;
|
|
190
244
|
} else {
|
|
191
245
|
const first = iter.next();
|
|
192
|
-
if (first.done)
|
|
246
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
193
247
|
acc = first.value;
|
|
194
248
|
index = 1;
|
|
195
249
|
}
|
|
@@ -561,6 +615,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
561
615
|
|
|
562
616
|
|
|
563
617
|
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
564
642
|
* @example
|
|
565
643
|
* // Deque peek at both ends
|
|
566
644
|
* const deque = new Deque<number>([10, 20, 30, 40, 50]);
|
|
@@ -595,6 +673,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
595
673
|
|
|
596
674
|
|
|
597
675
|
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
598
700
|
* @example
|
|
599
701
|
* // Peek at the back element
|
|
600
702
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -634,6 +736,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
634
736
|
|
|
635
737
|
|
|
636
738
|
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
637
763
|
* @example
|
|
638
764
|
* // basic Deque creation and push/pop operations
|
|
639
765
|
* // Create a simple Deque with initial values
|
|
@@ -686,6 +812,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
686
812
|
|
|
687
813
|
|
|
688
814
|
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
689
839
|
* @example
|
|
690
840
|
* // Remove from the back
|
|
691
841
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -725,6 +875,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
725
875
|
|
|
726
876
|
|
|
727
877
|
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
728
902
|
* @example
|
|
729
903
|
* // Remove from the front
|
|
730
904
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -765,6 +939,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
765
939
|
|
|
766
940
|
|
|
767
941
|
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
768
966
|
* @example
|
|
769
967
|
* // Deque shift and unshift operations
|
|
770
968
|
* const deque = new Deque<number>([20, 30, 40]);
|
|
@@ -846,6 +1044,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
846
1044
|
|
|
847
1045
|
|
|
848
1046
|
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
849
1071
|
* @example
|
|
850
1072
|
* // Check if empty
|
|
851
1073
|
* const dq = new Deque();
|
|
@@ -867,6 +1089,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
867
1089
|
|
|
868
1090
|
|
|
869
1091
|
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
870
1116
|
* @example
|
|
871
1117
|
* // Remove all elements
|
|
872
1118
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -892,6 +1138,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
892
1138
|
|
|
893
1139
|
|
|
894
1140
|
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
895
1165
|
* @example
|
|
896
1166
|
* // Access by index
|
|
897
1167
|
* const dq = new Deque<string>(['a', 'b', 'c']);
|
|
@@ -1068,6 +1338,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1068
1338
|
|
|
1069
1339
|
|
|
1070
1340
|
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1071
1365
|
* @example
|
|
1072
1366
|
* // Remove element
|
|
1073
1367
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1131,6 +1425,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1131
1425
|
|
|
1132
1426
|
|
|
1133
1427
|
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1134
1452
|
* @example
|
|
1135
1453
|
* // Deque for...of iteration and reverse
|
|
1136
1454
|
* const deque = new Deque<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1219,6 +1537,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1219
1537
|
|
|
1220
1538
|
|
|
1221
1539
|
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1222
1564
|
* @example
|
|
1223
1565
|
* // Reclaim memory
|
|
1224
1566
|
* const dq = new Deque<number>([1, 2, 3, 4, 5]);
|
|
@@ -1266,6 +1608,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1266
1608
|
|
|
1267
1609
|
|
|
1268
1610
|
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1269
1635
|
* @example
|
|
1270
1636
|
* // Create independent copy
|
|
1271
1637
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1296,6 +1662,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1296
1662
|
|
|
1297
1663
|
|
|
1298
1664
|
|
|
1665
|
+
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1299
1689
|
* @example
|
|
1300
1690
|
* // Filter elements
|
|
1301
1691
|
* const dq = new Deque<number>([1, 2, 3, 4]);
|
|
@@ -1346,6 +1736,30 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1346
1736
|
|
|
1347
1737
|
|
|
1348
1738
|
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
|
|
1749
|
+
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
|
|
1349
1763
|
* @example
|
|
1350
1764
|
* // Transform elements
|
|
1351
1765
|
* const dq = new Deque<number>([1, 2, 3]);
|
|
@@ -1476,54 +1890,6 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1476
1890
|
};
|
|
1477
1891
|
__name(_Deque, "Deque");
|
|
1478
1892
|
var Deque = _Deque;
|
|
1479
|
-
|
|
1480
|
-
// src/common/error.ts
|
|
1481
|
-
var ERR = {
|
|
1482
|
-
// Range / index
|
|
1483
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
1484
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
1485
|
-
// Type / argument
|
|
1486
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
1487
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
1488
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
1489
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
1490
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
1491
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
1492
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
1493
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
1494
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
1495
|
-
// State / operation
|
|
1496
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
1497
|
-
// Matrix
|
|
1498
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
1499
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
1500
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
1501
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
1502
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
1503
|
-
};
|
|
1504
|
-
|
|
1505
|
-
// src/common/index.ts
|
|
1506
|
-
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
1507
|
-
DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
|
|
1508
|
-
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
1509
|
-
return DFSOperation2;
|
|
1510
|
-
})(DFSOperation || {});
|
|
1511
|
-
var _Range = class _Range {
|
|
1512
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
1513
|
-
this.low = low;
|
|
1514
|
-
this.high = high;
|
|
1515
|
-
this.includeLow = includeLow;
|
|
1516
|
-
this.includeHigh = includeHigh;
|
|
1517
|
-
}
|
|
1518
|
-
// Determine whether a key is within the range
|
|
1519
|
-
isInRange(key, comparator) {
|
|
1520
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
1521
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
1522
|
-
return lowCheck && highCheck;
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1525
|
-
__name(_Range, "Range");
|
|
1526
|
-
var Range = _Range;
|
|
1527
1893
|
/**
|
|
1528
1894
|
* data-structure-typed
|
|
1529
1895
|
*
|
|
@@ -1532,6 +1898,6 @@ var Range = _Range;
|
|
|
1532
1898
|
* @license MIT License
|
|
1533
1899
|
*/
|
|
1534
1900
|
|
|
1535
|
-
export { DFSOperation, Deque, ERR, Range };
|
|
1901
|
+
export { DFSOperation, Deque, ERR, Range, raise };
|
|
1536
1902
|
//# sourceMappingURL=index.mjs.map
|
|
1537
1903
|
//# sourceMappingURL=index.mjs.map
|