deque-typed 2.5.1 → 2.5.3

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 (75) hide show
  1. package/dist/cjs/index.cjs +187 -51
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +186 -50
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +187 -52
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +186 -51
  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/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/deque-typed.js +184 -49
  39. package/dist/umd/deque-typed.js.map +1 -1
  40. package/dist/umd/deque-typed.min.js +1 -1
  41. package/dist/umd/deque-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -242,6 +242,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
242
242
 
243
243
 
244
244
 
245
+
246
+
247
+
248
+
249
+
250
+
251
+
245
252
 
246
253
 
247
254
 
@@ -293,6 +300,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
293
300
 
294
301
 
295
302
 
303
+
304
+
305
+
306
+
307
+
308
+
309
+
296
310
 
297
311
 
298
312
 
@@ -339,6 +353,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
339
353
 
340
354
 
341
355
 
356
+
357
+
358
+
359
+
360
+
361
+
362
+
342
363
 
343
364
 
344
365
 
@@ -381,6 +402,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
381
402
 
382
403
 
383
404
 
405
+
406
+
407
+
408
+
409
+
410
+
411
+
384
412
 
385
413
 
386
414
 
@@ -422,6 +450,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
422
450
 
423
451
 
424
452
 
453
+
454
+
455
+
456
+
457
+
458
+
459
+
425
460
 
426
461
 
427
462
 
@@ -466,6 +501,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
466
501
 
467
502
 
468
503
 
504
+
505
+
506
+
507
+
508
+
509
+
510
+
469
511
 
470
512
 
471
513
 
@@ -535,6 +577,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
535
577
 
536
578
 
537
579
 
580
+
581
+
582
+
583
+
584
+
585
+
586
+
538
587
 
539
588
 
540
589
 
@@ -587,6 +636,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
587
636
 
588
637
 
589
638
 
639
+
640
+
641
+
642
+
643
+
644
+
645
+
590
646
 
591
647
 
592
648
 
@@ -633,6 +689,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
633
689
 
634
690
 
635
691
 
692
+
693
+
694
+
695
+
696
+
697
+
698
+
636
699
 
637
700
 
638
701
 
@@ -679,6 +742,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
679
742
 
680
743
 
681
744
 
745
+
746
+
747
+
748
+
749
+
750
+
751
+
682
752
 
683
753
 
684
754
 
@@ -722,6 +792,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
722
792
 
723
793
 
724
794
 
795
+
796
+
797
+
798
+
799
+
800
+
801
+
725
802
 
726
803
 
727
804
 
@@ -760,6 +837,13 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
760
837
 
761
838
 
762
839
 
840
+
841
+
842
+
843
+
844
+
845
+
846
+
763
847
 
764
848
 
765
849
 
@@ -1,5 +1,5 @@
1
1
  import { BinaryTreeNode } from '../data-structures';
2
- import type { BinaryTreeDeleteResult, BinaryTreeOptions, BTNRep, DFSOrderPattern, EntryCallback, IterationType, NodeCallback, NodePredicate, OptNodeOrNull, ReduceEntryCallback, ToEntryFn } from '../types';
2
+ import type { BinaryTreeOptions, BTNRep, DFSOrderPattern, EntryCallback, IterationType, NodeCallback, NodePredicate, OptNodeOrNull, ReduceEntryCallback, ToEntryFn } from '../types';
3
3
  /**
4
4
  * Public, implementation-agnostic binary tree API.
5
5
  * K = key, V = value, R = raw/record used with toEntryFn (optional).
@@ -19,7 +19,7 @@ export interface IBinaryTree<K = any, V = any, R = any> {
19
19
  add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V, count?: number): boolean;
20
20
  set(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V, count?: number): boolean;
21
21
  addMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): boolean[];
22
- delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
22
+ delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>): boolean;
23
23
  clear(): void;
24
24
  isEmpty(): boolean;
25
25
  get(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): V | undefined;
@@ -56,5 +56,4 @@ export interface IBinaryTree<K = any, V = any, R = any> {
56
56
  filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: unknown): this;
57
57
  map<MK = K, MV = V, MR = any>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: Partial<BinaryTreeOptions<MK, MV, MR>>, thisArg?: unknown): IBinaryTree<MK, MV, MR>;
58
58
  merge(anotherTree: IBinaryTree<K, V, R>): void;
59
- refill(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): void;
60
59
  }
@@ -3,6 +3,7 @@ import type { Comparator, OptValue } from '../../common';
3
3
  type BSTBaseOptions<K, V, R> = Omit<BinaryTreeOptions<K, V, R>, 'isDuplicate'>;
4
4
  export type BSTOptions<K, V, R> = BSTBaseOptions<K, V, R> & {
5
5
  comparator?: Comparator<K>;
6
+ enableOrderStatistic?: boolean;
6
7
  };
7
8
  export type BSTNOptKey<K> = K | undefined;
8
9
  export type OptNode<NODE> = NODE | undefined;
@@ -8,6 +8,11 @@ export interface TreeMapOptions<K, V, R = [K, V]> {
8
8
  * - `false`: store values on tree nodes (Node Mode).
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ * When true, subtree counts are maintained on every node.
14
+ */
15
+ enableOrderStatistic?: boolean;
11
16
  /**
12
17
  * Transform raw elements into `[key, value]` entries.
13
18
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<[K, V]>`.
@@ -8,6 +8,10 @@ export interface TreeMultiSetOptions<K, R = K> {
8
8
  * - `false`: Node Mode.
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ */
14
+ enableOrderStatistic?: boolean;
11
15
  /**
12
16
  * Transform raw elements into keys.
13
17
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
@@ -8,6 +8,10 @@ export interface TreeSetOptions<K, R = K> {
8
8
  * - `false`: store values on tree nodes (Node Mode).
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ */
14
+ enableOrderStatistic?: boolean;
11
15
  /**
12
16
  * Transform raw elements into keys.
13
17
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
@@ -26,7 +26,8 @@ var dequeTyped = (() => {
26
26
  DFSOperation: () => DFSOperation,
27
27
  Deque: () => Deque,
28
28
  ERR: () => ERR,
29
- Range: () => Range
29
+ Range: () => Range,
30
+ raise: () => raise
30
31
  });
31
32
 
32
33
  // src/utils/utils.ts
@@ -37,6 +38,57 @@ var dequeTyped = (() => {
37
38
  };
38
39
  var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
39
40
 
41
+ // src/common/error.ts
42
+ function raise(ErrorClass, message) {
43
+ throw new ErrorClass(message);
44
+ }
45
+ var ERR = {
46
+ // Range / index
47
+ indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
48
+ invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
49
+ // Type / argument
50
+ invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
51
+ comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
52
+ invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
53
+ notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
54
+ invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
55
+ invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
56
+ invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
57
+ reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
58
+ callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
59
+ // State / operation
60
+ invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
61
+ // Matrix
62
+ matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
63
+ matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
64
+ matrixNotSquare: () => "Matrix: Must be square for inversion.",
65
+ matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
66
+ matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
67
+ // Order statistic
68
+ orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
69
+ };
70
+
71
+ // src/common/index.ts
72
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
73
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
74
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
75
+ return DFSOperation2;
76
+ })(DFSOperation || {});
77
+ var Range = class {
78
+ constructor(low, high, includeLow = true, includeHigh = true) {
79
+ this.low = low;
80
+ this.high = high;
81
+ this.includeLow = includeLow;
82
+ this.includeHigh = includeHigh;
83
+ }
84
+ // Determine whether a key is within the range
85
+ isInRange(key, comparator) {
86
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
87
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
88
+ return lowCheck && highCheck;
89
+ }
90
+ };
91
+
40
92
  // src/data-structures/base/iterable-element-base.ts
41
93
  var IterableElementBase = class {
42
94
  /**
@@ -59,7 +111,7 @@ var dequeTyped = (() => {
59
111
  if (options) {
60
112
  const { toElementFn } = options;
61
113
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
62
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
114
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
63
115
  }
64
116
  }
65
117
  /**
@@ -215,7 +267,7 @@ var dequeTyped = (() => {
215
267
  acc = initialValue;
216
268
  } else {
217
269
  const first = iter.next();
218
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
270
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
219
271
  acc = first.value;
220
272
  index = 1;
221
273
  }
@@ -597,6 +649,12 @@ var dequeTyped = (() => {
597
649
 
598
650
 
599
651
 
652
+
653
+
654
+
655
+
656
+
657
+
600
658
 
601
659
 
602
660
 
@@ -617,6 +675,31 @@ var dequeTyped = (() => {
617
675
  * console.log(last); // 50;
618
676
  *
619
677
  * // Length unchanged
678
+ * console.log(deque.length); // 5;
679
+ */
680
+ /**
681
+ * Peek at the front element without removing it (alias for `first`).
682
+ * @remarks Time O(1), Space O(1)
683
+ * @returns Front element or undefined.
684
+ */
685
+ peek() {
686
+ return this.first;
687
+ }
688
+ /**
689
+ * Deque peek at both ends
690
+ * @example
691
+ * // Deque peek at both ends
692
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
693
+ *
694
+ * // Get first element without removing
695
+ * const first = deque.at(0);
696
+ * console.log(first); // 10;
697
+ *
698
+ * // Get last element without removing
699
+ * const last = deque.at(deque.length - 1);
700
+ * console.log(last); // 50;
701
+ *
702
+ * // Length unchanged
620
703
  * console.log(deque.length); // 5;
621
704
  */
622
705
  get first() {
@@ -651,6 +734,13 @@ var dequeTyped = (() => {
651
734
 
652
735
 
653
736
 
737
+
738
+
739
+
740
+
741
+
742
+
743
+
654
744
 
655
745
 
656
746
 
@@ -711,6 +801,13 @@ var dequeTyped = (() => {
711
801
 
712
802
 
713
803
 
804
+
805
+
806
+
807
+
808
+
809
+
810
+
714
811
 
715
812
 
716
813
 
@@ -784,6 +881,13 @@ var dequeTyped = (() => {
784
881
 
785
882
 
786
883
 
884
+
885
+
886
+
887
+
888
+
889
+
890
+
787
891
 
788
892
 
789
893
 
@@ -844,6 +948,13 @@ var dequeTyped = (() => {
844
948
 
845
949
 
846
950
 
951
+
952
+
953
+
954
+
955
+
956
+
957
+
847
958
 
848
959
 
849
960
 
@@ -905,6 +1016,13 @@ var dequeTyped = (() => {
905
1016
 
906
1017
 
907
1018
 
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
908
1026
 
909
1027
 
910
1028
 
@@ -1007,6 +1125,13 @@ var dequeTyped = (() => {
1007
1125
 
1008
1126
 
1009
1127
 
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1010
1135
 
1011
1136
 
1012
1137
 
@@ -1049,6 +1174,13 @@ var dequeTyped = (() => {
1049
1174
 
1050
1175
 
1051
1176
 
1177
+
1178
+
1179
+
1180
+
1181
+
1182
+
1183
+
1052
1184
 
1053
1185
 
1054
1186
 
@@ -1095,6 +1227,13 @@ var dequeTyped = (() => {
1095
1227
 
1096
1228
 
1097
1229
 
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1098
1237
 
1099
1238
 
1100
1239
 
@@ -1292,6 +1431,13 @@ var dequeTyped = (() => {
1292
1431
 
1293
1432
 
1294
1433
 
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1295
1441
 
1296
1442
 
1297
1443
 
@@ -1376,6 +1522,13 @@ var dequeTyped = (() => {
1376
1522
 
1377
1523
 
1378
1524
 
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+
1531
+
1379
1532
 
1380
1533
 
1381
1534
 
@@ -1485,6 +1638,13 @@ var dequeTyped = (() => {
1485
1638
 
1486
1639
 
1487
1640
 
1641
+
1642
+
1643
+
1644
+
1645
+
1646
+
1647
+
1488
1648
 
1489
1649
 
1490
1650
 
@@ -1553,6 +1713,13 @@ var dequeTyped = (() => {
1553
1713
 
1554
1714
 
1555
1715
 
1716
+
1717
+
1718
+
1719
+
1720
+
1721
+
1722
+
1556
1723
 
1557
1724
 
1558
1725
 
@@ -1604,6 +1771,13 @@ var dequeTyped = (() => {
1604
1771
 
1605
1772
 
1606
1773
 
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1607
1781
 
1608
1782
 
1609
1783
 
@@ -1675,6 +1849,13 @@ var dequeTyped = (() => {
1675
1849
 
1676
1850
 
1677
1851
 
1852
+
1853
+
1854
+
1855
+
1856
+
1857
+
1858
+
1678
1859
 
1679
1860
 
1680
1861
 
@@ -1811,52 +1992,6 @@ var dequeTyped = (() => {
1811
1992
  }
1812
1993
  }
1813
1994
  };
1814
-
1815
- // src/common/error.ts
1816
- var ERR = {
1817
- // Range / index
1818
- indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
1819
- invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
1820
- // Type / argument
1821
- invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1822
- comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
1823
- invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1824
- notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
1825
- invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
1826
- invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
1827
- invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
1828
- reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
1829
- callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
1830
- // State / operation
1831
- invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1832
- // Matrix
1833
- matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
1834
- matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
1835
- matrixNotSquare: () => "Matrix: Must be square for inversion.",
1836
- matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
1837
- matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
1838
- };
1839
-
1840
- // src/common/index.ts
1841
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
1842
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
1843
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
1844
- return DFSOperation2;
1845
- })(DFSOperation || {});
1846
- var Range = class {
1847
- constructor(low, high, includeLow = true, includeHigh = true) {
1848
- this.low = low;
1849
- this.high = high;
1850
- this.includeLow = includeLow;
1851
- this.includeHigh = includeHigh;
1852
- }
1853
- // Determine whether a key is within the range
1854
- isInRange(key, comparator) {
1855
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
1856
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
1857
- return lowCheck && highCheck;
1858
- }
1859
- };
1860
1995
  return __toCommonJS(src_exports);
1861
1996
  })();
1862
1997
  /**