singly-linked-list-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 +163 -51
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +162 -50
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +163 -52
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +162 -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/singly-linked-list-typed.js +160 -49
  39. package/dist/umd/singly-linked-list-typed.js.map +1 -1
  40. package/dist/umd/singly-linked-list-typed.min.js +1 -1
  41. package/dist/umd/singly-linked-list-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>`.
@@ -27,9 +27,61 @@ var singlyLinkedListTyped = (() => {
27
27
  ERR: () => ERR,
28
28
  Range: () => Range,
29
29
  SinglyLinkedList: () => SinglyLinkedList,
30
- SinglyLinkedListNode: () => SinglyLinkedListNode
30
+ SinglyLinkedListNode: () => SinglyLinkedListNode,
31
+ raise: () => raise
31
32
  });
32
33
 
34
+ // src/common/error.ts
35
+ function raise(ErrorClass, message) {
36
+ throw new ErrorClass(message);
37
+ }
38
+ var ERR = {
39
+ // Range / index
40
+ indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
41
+ invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
42
+ // Type / argument
43
+ invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
44
+ comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
45
+ invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
46
+ notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
47
+ invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
48
+ invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
49
+ invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
50
+ reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
51
+ callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
52
+ // State / operation
53
+ invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
54
+ // Matrix
55
+ matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
56
+ matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
57
+ matrixNotSquare: () => "Matrix: Must be square for inversion.",
58
+ matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
59
+ matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
60
+ // Order statistic
61
+ orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
62
+ };
63
+
64
+ // src/common/index.ts
65
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
66
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
67
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
68
+ return DFSOperation2;
69
+ })(DFSOperation || {});
70
+ var Range = class {
71
+ constructor(low, high, includeLow = true, includeHigh = true) {
72
+ this.low = low;
73
+ this.high = high;
74
+ this.includeLow = includeLow;
75
+ this.includeHigh = includeHigh;
76
+ }
77
+ // Determine whether a key is within the range
78
+ isInRange(key, comparator) {
79
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
80
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
81
+ return lowCheck && highCheck;
82
+ }
83
+ };
84
+
33
85
  // src/data-structures/base/iterable-element-base.ts
34
86
  var IterableElementBase = class {
35
87
  /**
@@ -52,7 +104,7 @@ var singlyLinkedListTyped = (() => {
52
104
  if (options) {
53
105
  const { toElementFn } = options;
54
106
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
55
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
107
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
56
108
  }
57
109
  }
58
110
  /**
@@ -208,7 +260,7 @@ var singlyLinkedListTyped = (() => {
208
260
  acc = initialValue;
209
261
  } else {
210
262
  const first = iter.next();
211
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
263
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
212
264
  acc = first.value;
213
265
  index = 1;
214
266
  }
@@ -764,6 +816,13 @@ var singlyLinkedListTyped = (() => {
764
816
 
765
817
 
766
818
 
819
+
820
+
821
+
822
+
823
+
824
+
825
+
767
826
 
768
827
 
769
828
 
@@ -828,6 +887,13 @@ var singlyLinkedListTyped = (() => {
828
887
 
829
888
 
830
889
 
890
+
891
+
892
+
893
+
894
+
895
+
896
+
831
897
 
832
898
 
833
899
 
@@ -898,6 +964,13 @@ var singlyLinkedListTyped = (() => {
898
964
 
899
965
 
900
966
 
967
+
968
+
969
+
970
+
971
+
972
+
973
+
901
974
 
902
975
 
903
976
 
@@ -949,6 +1022,13 @@ var singlyLinkedListTyped = (() => {
949
1022
 
950
1023
 
951
1024
 
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
952
1032
 
953
1033
 
954
1034
 
@@ -1061,6 +1141,13 @@ var singlyLinkedListTyped = (() => {
1061
1141
 
1062
1142
 
1063
1143
 
1144
+
1145
+
1146
+
1147
+
1148
+
1149
+
1150
+
1064
1151
 
1065
1152
 
1066
1153
 
@@ -1117,6 +1204,13 @@ var singlyLinkedListTyped = (() => {
1117
1204
 
1118
1205
 
1119
1206
 
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1120
1214
 
1121
1215
 
1122
1216
 
@@ -1162,6 +1256,13 @@ var singlyLinkedListTyped = (() => {
1162
1256
 
1163
1257
 
1164
1258
 
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1165
1266
 
1166
1267
 
1167
1268
 
@@ -1213,6 +1314,13 @@ var singlyLinkedListTyped = (() => {
1213
1314
 
1214
1315
 
1215
1316
 
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1216
1324
 
1217
1325
 
1218
1326
 
@@ -1269,6 +1377,13 @@ var singlyLinkedListTyped = (() => {
1269
1377
 
1270
1378
 
1271
1379
 
1380
+
1381
+
1382
+
1383
+
1384
+
1385
+
1386
+
1272
1387
 
1273
1388
 
1274
1389
 
@@ -1333,6 +1448,13 @@ var singlyLinkedListTyped = (() => {
1333
1448
 
1334
1449
 
1335
1450
 
1451
+
1452
+
1453
+
1454
+
1455
+
1456
+
1457
+
1336
1458
 
1337
1459
 
1338
1460
 
@@ -1374,6 +1496,13 @@ var singlyLinkedListTyped = (() => {
1374
1496
 
1375
1497
 
1376
1498
 
1499
+
1500
+
1501
+
1502
+
1503
+
1504
+
1505
+
1377
1506
 
1378
1507
 
1379
1508
 
@@ -1421,6 +1550,13 @@ var singlyLinkedListTyped = (() => {
1421
1550
 
1422
1551
 
1423
1552
 
1553
+
1554
+
1555
+
1556
+
1557
+
1558
+
1559
+
1424
1560
 
1425
1561
 
1426
1562
 
@@ -1634,6 +1770,13 @@ var singlyLinkedListTyped = (() => {
1634
1770
 
1635
1771
 
1636
1772
 
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1637
1780
 
1638
1781
 
1639
1782
 
@@ -1685,6 +1828,13 @@ var singlyLinkedListTyped = (() => {
1685
1828
 
1686
1829
 
1687
1830
 
1831
+
1832
+
1833
+
1834
+
1835
+
1836
+
1837
+
1688
1838
 
1689
1839
 
1690
1840
 
@@ -1764,6 +1914,13 @@ var singlyLinkedListTyped = (() => {
1764
1914
 
1765
1915
 
1766
1916
 
1917
+
1918
+
1919
+
1920
+
1921
+
1922
+
1923
+
1767
1924
 
1768
1925
 
1769
1926
 
@@ -1910,52 +2067,6 @@ var singlyLinkedListTyped = (() => {
1910
2067
  const value = input;
1911
2068
  return (node) => equals(node.value, value);
1912
2069
  }
1913
-
1914
- // src/common/error.ts
1915
- var ERR = {
1916
- // Range / index
1917
- indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
1918
- invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
1919
- // Type / argument
1920
- invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1921
- comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
1922
- invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1923
- notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
1924
- invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
1925
- invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
1926
- invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
1927
- reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
1928
- callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
1929
- // State / operation
1930
- invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
1931
- // Matrix
1932
- matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
1933
- matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
1934
- matrixNotSquare: () => "Matrix: Must be square for inversion.",
1935
- matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
1936
- matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
1937
- };
1938
-
1939
- // src/common/index.ts
1940
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
1941
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
1942
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
1943
- return DFSOperation2;
1944
- })(DFSOperation || {});
1945
- var Range = class {
1946
- constructor(low, high, includeLow = true, includeHigh = true) {
1947
- this.low = low;
1948
- this.high = high;
1949
- this.includeLow = includeLow;
1950
- this.includeHigh = includeHigh;
1951
- }
1952
- // Determine whether a key is within the range
1953
- isInRange(key, comparator) {
1954
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
1955
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
1956
- return lowCheck && highCheck;
1957
- }
1958
- };
1959
2070
  return __toCommonJS(src_exports);
1960
2071
  })();
1961
2072
  /**