queue-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.
Files changed (90) hide show
  1. package/dist/cjs/index.cjs +1081 -66
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +1081 -66
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +1081 -67
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +1081 -67
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/base/index.d.ts +1 -0
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/queue-typed.js +1081 -67
  47. package/dist/umd/queue-typed.js.map +1 -1
  48. package/dist/umd/queue-typed.min.js +1 -1
  49. package/dist/umd/queue-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -3,6 +3,60 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
 
6
+ // src/common/error.ts
7
+ function raise(ErrorClass, message) {
8
+ throw new ErrorClass(message);
9
+ }
10
+ __name(raise, "raise");
11
+ var ERR = {
12
+ // Range / index
13
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
14
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
15
+ // Type / argument
16
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
17
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
18
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
19
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
20
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
21
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
22
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
23
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
24
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
25
+ // State / operation
26
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
27
+ // Matrix
28
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
29
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
30
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
31
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
32
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
33
+ // Order statistic
34
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
35
+ };
36
+
37
+ // src/common/index.ts
38
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
39
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
40
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
41
+ return DFSOperation2;
42
+ })(DFSOperation || {});
43
+ var _Range = class _Range {
44
+ constructor(low, high, includeLow = true, includeHigh = true) {
45
+ this.low = low;
46
+ this.high = high;
47
+ this.includeLow = includeLow;
48
+ this.includeHigh = includeHigh;
49
+ }
50
+ // Determine whether a key is within the range
51
+ isInRange(key, comparator) {
52
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
53
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
54
+ return lowCheck && highCheck;
55
+ }
56
+ };
57
+ __name(_Range, "Range");
58
+ var Range = _Range;
59
+
6
60
  // src/data-structures/base/iterable-element-base.ts
7
61
  var _IterableElementBase = class _IterableElementBase {
8
62
  /**
@@ -25,7 +79,7 @@ var _IterableElementBase = class _IterableElementBase {
25
79
  if (options) {
26
80
  const { toElementFn } = options;
27
81
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
28
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
82
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
29
83
  }
30
84
  }
31
85
  /**
@@ -181,7 +235,7 @@ var _IterableElementBase = class _IterableElementBase {
181
235
  acc = initialValue;
182
236
  } else {
183
237
  const first = iter.next();
184
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
238
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
185
239
  acc = first.value;
186
240
  index = 1;
187
241
  }
@@ -734,6 +788,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
734
788
 
735
789
 
736
790
 
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
737
815
  * @example
738
816
  * // basic SinglyLinkedList creation and push operation
739
817
  * // Create a simple SinglyLinkedList with initial values
@@ -777,6 +855,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
777
855
 
778
856
 
779
857
 
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+
873
+
874
+
875
+
876
+
877
+
878
+
879
+
880
+
881
+
780
882
  * @example
781
883
  * // SinglyLinkedList pop and shift operations
782
884
  * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
@@ -826,6 +928,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
826
928
 
827
929
 
828
930
 
931
+
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
829
955
  * @example
830
956
  * // Remove from the front
831
957
  * const list = new SinglyLinkedList<number>([10, 20, 30]);
@@ -856,6 +982,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
856
982
 
857
983
 
858
984
 
985
+
986
+
987
+
988
+
989
+
990
+
991
+
992
+
993
+
994
+
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
859
1009
  * @example
860
1010
  * // SinglyLinkedList unshift and forward traversal
861
1011
  * const list = new SinglyLinkedList<number>([20, 30, 40]);
@@ -947,6 +1097,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
947
1097
 
948
1098
 
949
1099
 
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
950
1124
  * @example
951
1125
  * // Access element by index
952
1126
  * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
@@ -982,6 +1156,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
982
1156
 
983
1157
 
984
1158
 
1159
+
1160
+
1161
+
1162
+
1163
+
1164
+
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+
1177
+
1178
+
1179
+
1180
+
1181
+
1182
+
985
1183
  * @example
986
1184
  * // Get node at index
987
1185
  * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
@@ -1006,6 +1204,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1006
1204
 
1007
1205
 
1008
1206
 
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+
1225
+
1226
+
1227
+
1228
+
1229
+
1230
+
1009
1231
  * @example
1010
1232
  * // Remove by index
1011
1233
  * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
@@ -1036,6 +1258,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1036
1258
 
1037
1259
 
1038
1260
 
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+
1267
+
1268
+
1269
+
1270
+
1271
+
1272
+
1273
+
1274
+
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+
1281
+
1282
+
1283
+
1284
+
1039
1285
  * @example
1040
1286
  * // Remove first occurrence
1041
1287
  * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
@@ -1071,22 +1317,46 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1071
1317
 
1072
1318
 
1073
1319
 
1074
- * @example
1075
- * // Insert at index
1076
- * const list = new SinglyLinkedList<number>([1, 3]);
1077
- * list.addAt(1, 2);
1078
- * console.log(list.toArray()); // [1, 2, 3];
1079
- */
1080
- addAt(index, newElementOrNode) {
1081
- if (index < 0 || index > this._length) return false;
1082
- if (index === 0) return this.unshift(newElementOrNode);
1083
- if (index === this._length) return this.push(newElementOrNode);
1084
- const newNode = this._ensureNode(newElementOrNode);
1085
- const prevNode = this.getNodeAt(index - 1);
1086
- newNode.next = prevNode.next;
1087
- prevNode.next = newNode;
1088
- this._length++;
1089
- return true;
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+
1334
+
1335
+
1336
+
1337
+
1338
+
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+ * @example
1345
+ * // Insert at index
1346
+ * const list = new SinglyLinkedList<number>([1, 3]);
1347
+ * list.addAt(1, 2);
1348
+ * console.log(list.toArray()); // [1, 2, 3];
1349
+ */
1350
+ addAt(index, newElementOrNode) {
1351
+ if (index < 0 || index > this._length) return false;
1352
+ if (index === 0) return this.unshift(newElementOrNode);
1353
+ if (index === this._length) return this.push(newElementOrNode);
1354
+ const newNode = this._ensureNode(newElementOrNode);
1355
+ const prevNode = this.getNodeAt(index - 1);
1356
+ newNode.next = prevNode.next;
1357
+ prevNode.next = newNode;
1358
+ this._length++;
1359
+ return true;
1090
1360
  }
1091
1361
  /**
1092
1362
  * Set the element value at an index.
@@ -1114,6 +1384,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1114
1384
 
1115
1385
 
1116
1386
 
1387
+
1388
+
1389
+
1390
+
1391
+
1392
+
1393
+
1394
+
1395
+
1396
+
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+
1117
1411
  * @example
1118
1412
  * // Check empty
1119
1413
  * console.log(new SinglyLinkedList().isEmpty()); // true;
@@ -1134,6 +1428,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1134
1428
 
1135
1429
 
1136
1430
 
1431
+
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1442
+
1443
+
1444
+
1445
+
1446
+
1447
+
1448
+
1449
+
1450
+
1451
+
1452
+
1453
+
1454
+
1137
1455
  * @example
1138
1456
  * // Remove all
1139
1457
  * const list = new SinglyLinkedList<number>([1, 2, 3]);
@@ -1160,6 +1478,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1160
1478
 
1161
1479
 
1162
1480
 
1481
+
1482
+
1483
+
1484
+
1485
+
1486
+
1487
+
1488
+
1489
+
1490
+
1491
+
1492
+
1493
+
1494
+
1495
+
1496
+
1497
+
1498
+
1499
+
1500
+
1501
+
1502
+
1503
+
1504
+
1163
1505
  * @example
1164
1506
  * // Reverse the list in-place
1165
1507
  * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
@@ -1352,6 +1694,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1352
1694
 
1353
1695
 
1354
1696
 
1697
+
1698
+
1699
+
1700
+
1701
+
1702
+
1703
+
1704
+
1705
+
1706
+
1707
+
1708
+
1709
+
1710
+
1711
+
1712
+
1713
+
1714
+
1715
+
1716
+
1717
+
1718
+
1719
+
1720
+
1355
1721
  * @example
1356
1722
  * // Deep copy
1357
1723
  * const list = new SinglyLinkedList<number>([1, 2, 3]);
@@ -1382,6 +1748,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1382
1748
 
1383
1749
 
1384
1750
 
1751
+
1752
+
1753
+
1754
+
1755
+
1756
+
1757
+
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1385
1775
  * @example
1386
1776
  * // SinglyLinkedList filter and map operations
1387
1777
  * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
@@ -1440,6 +1830,30 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1440
1830
 
1441
1831
 
1442
1832
 
1833
+
1834
+
1835
+
1836
+
1837
+
1838
+
1839
+
1840
+
1841
+
1842
+
1843
+
1844
+
1845
+
1846
+
1847
+
1848
+
1849
+
1850
+
1851
+
1852
+
1853
+
1854
+
1855
+
1856
+
1443
1857
  * @example
1444
1858
  * // Transform elements
1445
1859
  * const list = new SinglyLinkedList<number>([1, 2, 3]);
@@ -1582,54 +1996,6 @@ function elementOrPredicate(input, equals) {
1582
1996
  }
1583
1997
  __name(elementOrPredicate, "elementOrPredicate");
1584
1998
 
1585
- // src/common/error.ts
1586
- var ERR = {
1587
- // Range / index
1588
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
1589
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
1590
- // Type / argument
1591
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
1592
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
1593
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
1594
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
1595
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
1596
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
1597
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
1598
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
1599
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
1600
- // State / operation
1601
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
1602
- // Matrix
1603
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
1604
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
1605
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
1606
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
1607
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
1608
- };
1609
-
1610
- // src/common/index.ts
1611
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
1612
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
1613
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
1614
- return DFSOperation2;
1615
- })(DFSOperation || {});
1616
- var _Range = class _Range {
1617
- constructor(low, high, includeLow = true, includeHigh = true) {
1618
- this.low = low;
1619
- this.high = high;
1620
- this.includeLow = includeLow;
1621
- this.includeHigh = includeHigh;
1622
- }
1623
- // Determine whether a key is within the range
1624
- isInRange(key, comparator) {
1625
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
1626
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
1627
- return lowCheck && highCheck;
1628
- }
1629
- };
1630
- __name(_Range, "Range");
1631
- var Range = _Range;
1632
-
1633
1999
  // src/data-structures/queue/queue.ts
1634
2000
  var _Queue = class _Queue extends LinearBase {
1635
2001
  /**
@@ -1698,6 +2064,30 @@ var _Queue = class _Queue extends LinearBase {
1698
2064
 
1699
2065
 
1700
2066
 
2067
+
2068
+
2069
+
2070
+
2071
+
2072
+
2073
+
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+
2080
+
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+
1701
2091
  * @example
1702
2092
  * // Track queue length
1703
2093
  * const q = new Queue<number>();
@@ -1724,6 +2114,30 @@ var _Queue = class _Queue extends LinearBase {
1724
2114
 
1725
2115
 
1726
2116
 
2117
+
2118
+
2119
+
2120
+
2121
+
2122
+
2123
+
2124
+
2125
+
2126
+
2127
+
2128
+
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+
2140
+
1727
2141
  * @example
1728
2142
  * // View the front element
1729
2143
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -1766,6 +2180,30 @@ var _Queue = class _Queue extends LinearBase {
1766
2180
 
1767
2181
 
1768
2182
 
2183
+
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
2195
+
2196
+
2197
+
2198
+
2199
+
2200
+
2201
+
2202
+
2203
+
2204
+
2205
+
2206
+
1769
2207
  * @example
1770
2208
  * // Queue for...of iteration and isEmpty check
1771
2209
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -1804,6 +2242,30 @@ var _Queue = class _Queue extends LinearBase {
1804
2242
 
1805
2243
 
1806
2244
 
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
2253
+
2254
+
2255
+
2256
+
2257
+
2258
+
2259
+
2260
+
2261
+
2262
+
2263
+
2264
+
2265
+
2266
+
2267
+
2268
+
1807
2269
  * @example
1808
2270
  * // basic Queue creation and push operation
1809
2271
  * // Create a simple Queue with initial values
@@ -1849,6 +2311,30 @@ var _Queue = class _Queue extends LinearBase {
1849
2311
 
1850
2312
 
1851
2313
 
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+
2324
+
2325
+
2326
+
2327
+
2328
+
2329
+
2330
+
2331
+
2332
+
2333
+
2334
+
2335
+
2336
+
2337
+
1852
2338
  * @example
1853
2339
  * // Queue shift and peek operations
1854
2340
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -1884,6 +2370,30 @@ var _Queue = class _Queue extends LinearBase {
1884
2370
 
1885
2371
 
1886
2372
 
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
1887
2397
  * @example
1888
2398
  * // Remove specific element
1889
2399
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -1912,6 +2422,30 @@ var _Queue = class _Queue extends LinearBase {
1912
2422
 
1913
2423
 
1914
2424
 
2425
+
2426
+
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+
1915
2449
  * @example
1916
2450
  * // Access element by index
1917
2451
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -1981,6 +2515,30 @@ var _Queue = class _Queue extends LinearBase {
1981
2515
 
1982
2516
 
1983
2517
 
2518
+
2519
+
2520
+
2521
+
2522
+
2523
+
2524
+
2525
+
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2541
+
1984
2542
  * @example
1985
2543
  * // Remove all elements
1986
2544
  * const q = new Queue<number>([1, 2, 3]);
@@ -2003,6 +2561,30 @@ var _Queue = class _Queue extends LinearBase {
2003
2561
 
2004
2562
 
2005
2563
 
2564
+
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2585
+
2586
+
2587
+
2006
2588
  * @example
2007
2589
  * // Reclaim unused memory
2008
2590
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -2048,6 +2630,30 @@ var _Queue = class _Queue extends LinearBase {
2048
2630
 
2049
2631
 
2050
2632
 
2633
+
2634
+
2635
+
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+
2656
+
2051
2657
  * @example
2052
2658
  * // Create independent copy
2053
2659
  * const q = new Queue<number>([1, 2, 3]);
@@ -2077,6 +2683,30 @@ var _Queue = class _Queue extends LinearBase {
2077
2683
 
2078
2684
 
2079
2685
 
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2080
2710
  * @example
2081
2711
  * // Filter elements
2082
2712
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -2110,6 +2740,30 @@ var _Queue = class _Queue extends LinearBase {
2110
2740
 
2111
2741
 
2112
2742
 
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2113
2767
  * @example
2114
2768
  * // Transform elements
2115
2769
  * const q = new Queue<number>([1, 2, 3]);
@@ -2364,6 +3018,30 @@ var _Deque = class _Deque extends LinearBase {
2364
3018
 
2365
3019
 
2366
3020
 
3021
+
3022
+
3023
+
3024
+
3025
+
3026
+
3027
+
3028
+
3029
+
3030
+
3031
+
3032
+
3033
+
3034
+
3035
+
3036
+
3037
+
3038
+
3039
+
3040
+
3041
+
3042
+
3043
+
3044
+
2367
3045
  * @example
2368
3046
  * // Deque peek at both ends
2369
3047
  * const deque = new Deque<number>([10, 20, 30, 40, 50]);
@@ -2398,6 +3076,30 @@ var _Deque = class _Deque extends LinearBase {
2398
3076
 
2399
3077
 
2400
3078
 
3079
+
3080
+
3081
+
3082
+
3083
+
3084
+
3085
+
3086
+
3087
+
3088
+
3089
+
3090
+
3091
+
3092
+
3093
+
3094
+
3095
+
3096
+
3097
+
3098
+
3099
+
3100
+
3101
+
3102
+
2401
3103
  * @example
2402
3104
  * // Peek at the back element
2403
3105
  * const dq = new Deque<string>(['a', 'b', 'c']);
@@ -2437,6 +3139,30 @@ var _Deque = class _Deque extends LinearBase {
2437
3139
 
2438
3140
 
2439
3141
 
3142
+
3143
+
3144
+
3145
+
3146
+
3147
+
3148
+
3149
+
3150
+
3151
+
3152
+
3153
+
3154
+
3155
+
3156
+
3157
+
3158
+
3159
+
3160
+
3161
+
3162
+
3163
+
3164
+
3165
+
2440
3166
  * @example
2441
3167
  * // basic Deque creation and push/pop operations
2442
3168
  * // Create a simple Deque with initial values
@@ -2489,6 +3215,30 @@ var _Deque = class _Deque extends LinearBase {
2489
3215
 
2490
3216
 
2491
3217
 
3218
+
3219
+
3220
+
3221
+
3222
+
3223
+
3224
+
3225
+
3226
+
3227
+
3228
+
3229
+
3230
+
3231
+
3232
+
3233
+
3234
+
3235
+
3236
+
3237
+
3238
+
3239
+
3240
+
3241
+
2492
3242
  * @example
2493
3243
  * // Remove from the back
2494
3244
  * const dq = new Deque<number>([1, 2, 3]);
@@ -2528,6 +3278,30 @@ var _Deque = class _Deque extends LinearBase {
2528
3278
 
2529
3279
 
2530
3280
 
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+
3288
+
3289
+
3290
+
3291
+
3292
+
3293
+
3294
+
3295
+
3296
+
3297
+
3298
+
3299
+
3300
+
3301
+
3302
+
3303
+
3304
+
2531
3305
  * @example
2532
3306
  * // Remove from the front
2533
3307
  * const dq = new Deque<number>([1, 2, 3]);
@@ -2568,6 +3342,30 @@ var _Deque = class _Deque extends LinearBase {
2568
3342
 
2569
3343
 
2570
3344
 
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+
3354
+
3355
+
3356
+
3357
+
3358
+
3359
+
3360
+
3361
+
3362
+
3363
+
3364
+
3365
+
3366
+
3367
+
3368
+
2571
3369
  * @example
2572
3370
  * // Deque shift and unshift operations
2573
3371
  * const deque = new Deque<number>([20, 30, 40]);
@@ -2649,6 +3447,30 @@ var _Deque = class _Deque extends LinearBase {
2649
3447
 
2650
3448
 
2651
3449
 
3450
+
3451
+
3452
+
3453
+
3454
+
3455
+
3456
+
3457
+
3458
+
3459
+
3460
+
3461
+
3462
+
3463
+
3464
+
3465
+
3466
+
3467
+
3468
+
3469
+
3470
+
3471
+
3472
+
3473
+
2652
3474
  * @example
2653
3475
  * // Check if empty
2654
3476
  * const dq = new Deque();
@@ -2670,6 +3492,30 @@ var _Deque = class _Deque extends LinearBase {
2670
3492
 
2671
3493
 
2672
3494
 
3495
+
3496
+
3497
+
3498
+
3499
+
3500
+
3501
+
3502
+
3503
+
3504
+
3505
+
3506
+
3507
+
3508
+
3509
+
3510
+
3511
+
3512
+
3513
+
3514
+
3515
+
3516
+
3517
+
3518
+
2673
3519
  * @example
2674
3520
  * // Remove all elements
2675
3521
  * const dq = new Deque<number>([1, 2, 3]);
@@ -2695,6 +3541,30 @@ var _Deque = class _Deque extends LinearBase {
2695
3541
 
2696
3542
 
2697
3543
 
3544
+
3545
+
3546
+
3547
+
3548
+
3549
+
3550
+
3551
+
3552
+
3553
+
3554
+
3555
+
3556
+
3557
+
3558
+
3559
+
3560
+
3561
+
3562
+
3563
+
3564
+
3565
+
3566
+
3567
+
2698
3568
  * @example
2699
3569
  * // Access by index
2700
3570
  * const dq = new Deque<string>(['a', 'b', 'c']);
@@ -2871,6 +3741,30 @@ var _Deque = class _Deque extends LinearBase {
2871
3741
 
2872
3742
 
2873
3743
 
3744
+
3745
+
3746
+
3747
+
3748
+
3749
+
3750
+
3751
+
3752
+
3753
+
3754
+
3755
+
3756
+
3757
+
3758
+
3759
+
3760
+
3761
+
3762
+
3763
+
3764
+
3765
+
3766
+
3767
+
2874
3768
  * @example
2875
3769
  * // Remove element
2876
3770
  * const dq = new Deque<number>([1, 2, 3]);
@@ -2934,6 +3828,30 @@ var _Deque = class _Deque extends LinearBase {
2934
3828
 
2935
3829
 
2936
3830
 
3831
+
3832
+
3833
+
3834
+
3835
+
3836
+
3837
+
3838
+
3839
+
3840
+
3841
+
3842
+
3843
+
3844
+
3845
+
3846
+
3847
+
3848
+
3849
+
3850
+
3851
+
3852
+
3853
+
3854
+
2937
3855
  * @example
2938
3856
  * // Deque for...of iteration and reverse
2939
3857
  * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
@@ -3022,6 +3940,30 @@ var _Deque = class _Deque extends LinearBase {
3022
3940
 
3023
3941
 
3024
3942
 
3943
+
3944
+
3945
+
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3960
+
3961
+
3962
+
3963
+
3964
+
3965
+
3966
+
3025
3967
  * @example
3026
3968
  * // Reclaim memory
3027
3969
  * const dq = new Deque<number>([1, 2, 3, 4, 5]);
@@ -3069,6 +4011,30 @@ var _Deque = class _Deque extends LinearBase {
3069
4011
 
3070
4012
 
3071
4013
 
4014
+
4015
+
4016
+
4017
+
4018
+
4019
+
4020
+
4021
+
4022
+
4023
+
4024
+
4025
+
4026
+
4027
+
4028
+
4029
+
4030
+
4031
+
4032
+
4033
+
4034
+
4035
+
4036
+
4037
+
3072
4038
  * @example
3073
4039
  * // Create independent copy
3074
4040
  * const dq = new Deque<number>([1, 2, 3]);
@@ -3099,6 +4065,30 @@ var _Deque = class _Deque extends LinearBase {
3099
4065
 
3100
4066
 
3101
4067
 
4068
+
4069
+
4070
+
4071
+
4072
+
4073
+
4074
+
4075
+
4076
+
4077
+
4078
+
4079
+
4080
+
4081
+
4082
+
4083
+
4084
+
4085
+
4086
+
4087
+
4088
+
4089
+
4090
+
4091
+
3102
4092
  * @example
3103
4093
  * // Filter elements
3104
4094
  * const dq = new Deque<number>([1, 2, 3, 4]);
@@ -3149,6 +4139,30 @@ var _Deque = class _Deque extends LinearBase {
3149
4139
 
3150
4140
 
3151
4141
 
4142
+
4143
+
4144
+
4145
+
4146
+
4147
+
4148
+
4149
+
4150
+
4151
+
4152
+
4153
+
4154
+
4155
+
4156
+
4157
+
4158
+
4159
+
4160
+
4161
+
4162
+
4163
+
4164
+
4165
+
3152
4166
  * @example
3153
4167
  * // Transform elements
3154
4168
  * const dq = new Deque<number>([1, 2, 3]);
@@ -3287,6 +4301,6 @@ var Deque = _Deque;
3287
4301
  * @license MIT License
3288
4302
  */
3289
4303
 
3290
- export { DFSOperation, Deque, ERR, LinkedListQueue, Queue, Range };
4304
+ export { DFSOperation, Deque, ERR, LinkedListQueue, Queue, Range, raise };
3291
4305
  //# sourceMappingURL=index.mjs.map
3292
4306
  //# sourceMappingURL=index.mjs.map