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