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