data-structure-typed 2.5.1 → 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 (172) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +75 -17
  3. package/dist/cjs/binary-tree.cjs +2723 -139
  4. package/dist/cjs/graph.cjs +192 -6
  5. package/dist/cjs/hash.cjs +63 -15
  6. package/dist/cjs/heap.cjs +93 -31
  7. package/dist/cjs/index.cjs +3514 -379
  8. package/dist/cjs/linked-list.cjs +237 -31
  9. package/dist/cjs/matrix.cjs +47 -9
  10. package/dist/cjs/priority-queue.cjs +92 -30
  11. package/dist/cjs/queue.cjs +176 -2
  12. package/dist/cjs/stack.cjs +48 -2
  13. package/dist/cjs/trie.cjs +78 -28
  14. package/dist/cjs-legacy/binary-tree.cjs +2725 -136
  15. package/dist/cjs-legacy/graph.cjs +192 -6
  16. package/dist/cjs-legacy/hash.cjs +63 -15
  17. package/dist/cjs-legacy/heap.cjs +93 -31
  18. package/dist/cjs-legacy/index.cjs +3389 -249
  19. package/dist/cjs-legacy/linked-list.cjs +237 -31
  20. package/dist/cjs-legacy/matrix.cjs +47 -9
  21. package/dist/cjs-legacy/priority-queue.cjs +92 -30
  22. package/dist/cjs-legacy/queue.cjs +176 -2
  23. package/dist/cjs-legacy/stack.cjs +48 -2
  24. package/dist/cjs-legacy/trie.cjs +78 -28
  25. package/dist/esm/binary-tree.mjs +2723 -139
  26. package/dist/esm/graph.mjs +192 -6
  27. package/dist/esm/hash.mjs +63 -15
  28. package/dist/esm/heap.mjs +93 -31
  29. package/dist/esm/index.mjs +3514 -380
  30. package/dist/esm/linked-list.mjs +237 -31
  31. package/dist/esm/matrix.mjs +47 -9
  32. package/dist/esm/priority-queue.mjs +92 -30
  33. package/dist/esm/queue.mjs +176 -2
  34. package/dist/esm/stack.mjs +48 -2
  35. package/dist/esm/trie.mjs +78 -28
  36. package/dist/esm-legacy/binary-tree.mjs +2725 -136
  37. package/dist/esm-legacy/graph.mjs +192 -6
  38. package/dist/esm-legacy/hash.mjs +63 -15
  39. package/dist/esm-legacy/heap.mjs +93 -31
  40. package/dist/esm-legacy/index.mjs +3389 -250
  41. package/dist/esm-legacy/linked-list.mjs +237 -31
  42. package/dist/esm-legacy/matrix.mjs +47 -9
  43. package/dist/esm-legacy/priority-queue.mjs +92 -30
  44. package/dist/esm-legacy/queue.mjs +176 -2
  45. package/dist/esm-legacy/stack.mjs +48 -2
  46. package/dist/esm-legacy/trie.mjs +78 -28
  47. package/dist/types/common/error.d.ts +9 -0
  48. package/dist/types/common/index.d.ts +1 -1
  49. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +48 -0
  50. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  51. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +102 -2
  52. package/dist/types/data-structures/binary-tree/bst.d.ts +195 -0
  53. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +76 -0
  54. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  55. package/dist/types/data-structures/binary-tree/tree-map.d.ts +528 -0
  56. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +531 -6
  57. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +435 -6
  58. package/dist/types/data-structures/binary-tree/tree-set.d.ts +505 -0
  59. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  60. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  61. package/dist/types/data-structures/hash/hash-map.d.ts +44 -0
  62. package/dist/types/data-structures/heap/heap.d.ts +56 -0
  63. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +68 -0
  64. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +60 -0
  65. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  66. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  67. package/dist/types/data-structures/queue/deque.d.ts +60 -0
  68. package/dist/types/data-structures/queue/queue.d.ts +48 -0
  69. package/dist/types/data-structures/stack/stack.d.ts +40 -0
  70. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  71. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  72. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  73. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  74. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  75. package/dist/umd/data-structure-typed.js +3404 -265
  76. package/dist/umd/data-structure-typed.min.js +5 -5
  77. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +650 -136
  78. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  79. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
  80. package/docs-site-docusaurus/docs/api/classes/BST.md +591 -129
  81. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  82. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +107 -107
  84. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  85. package/docs-site-docusaurus/docs/api/classes/Deque.md +82 -82
  86. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +74 -74
  88. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  90. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  91. package/docs-site-docusaurus/docs/api/classes/HashMap.md +47 -47
  92. package/docs-site-docusaurus/docs/api/classes/Heap.md +45 -45
  93. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  94. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
  95. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
  96. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
  97. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +49 -49
  98. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  99. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
  100. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
  101. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  102. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +45 -45
  103. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +45 -45
  104. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +45 -45
  105. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +45 -45
  106. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  107. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +44 -44
  108. package/docs-site-docusaurus/docs/api/classes/Queue.md +60 -60
  109. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +660 -146
  110. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  111. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +78 -78
  112. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  113. package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
  114. package/docs-site-docusaurus/docs/api/classes/Stack.md +39 -39
  115. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +165 -33
  116. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
  117. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +161 -32
  118. package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
  119. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  120. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
  121. package/docs-site-docusaurus/docs/guide/architecture.md +2 -0
  122. package/docs-site-docusaurus/docs/guide/concepts.md +32 -1
  123. package/docs-site-docusaurus/docs/guide/faq.md +180 -0
  124. package/docs-site-docusaurus/docs/guide/guides.md +40 -54
  125. package/docs-site-docusaurus/docs/guide/installation.md +2 -0
  126. package/docs-site-docusaurus/docs/guide/integrations.md +2 -0
  127. package/docs-site-docusaurus/docs/guide/overview.md +7 -0
  128. package/docs-site-docusaurus/docs/guide/performance.md +2 -0
  129. package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
  130. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  131. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  132. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  133. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  134. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  135. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  136. package/docs-site-docusaurus/docusaurus.config.ts +1 -1
  137. package/docs-site-docusaurus/src/pages/index.tsx +51 -2
  138. package/docs-site-docusaurus/static/llms.txt +37 -0
  139. package/llms.txt +37 -0
  140. package/package.json +64 -56
  141. package/src/common/error.ts +19 -1
  142. package/src/common/index.ts +1 -1
  143. package/src/data-structures/base/iterable-element-base.ts +3 -2
  144. package/src/data-structures/binary-tree/avl-tree.ts +47 -0
  145. package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
  146. package/src/data-structures/binary-tree/binary-tree.ts +79 -4
  147. package/src/data-structures/binary-tree/bst.ts +441 -6
  148. package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
  149. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  150. package/src/data-structures/binary-tree/tree-map.ts +434 -9
  151. package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
  152. package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
  153. package/src/data-structures/binary-tree/tree-set.ts +410 -8
  154. package/src/data-structures/graph/abstract-graph.ts +2 -2
  155. package/src/data-structures/graph/directed-graph.ts +30 -0
  156. package/src/data-structures/graph/undirected-graph.ts +27 -0
  157. package/src/data-structures/hash/hash-map.ts +35 -4
  158. package/src/data-structures/heap/heap.ts +46 -4
  159. package/src/data-structures/heap/max-heap.ts +2 -2
  160. package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
  161. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  162. package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
  163. package/src/data-structures/matrix/matrix.ts +33 -9
  164. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  165. package/src/data-structures/queue/deque.ts +45 -0
  166. package/src/data-structures/queue/queue.ts +36 -0
  167. package/src/data-structures/stack/stack.ts +30 -0
  168. package/src/data-structures/trie/trie.ts +38 -2
  169. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  170. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  171. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  172. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/common/error.ts
5
+ function raise(ErrorClass, message) {
6
+ throw new ErrorClass(message);
7
+ }
8
+ __name(raise, "raise");
5
9
  var ERR = {
6
10
  // Range / index
7
11
  indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
@@ -23,7 +27,9 @@ var ERR = {
23
27
  matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
24
28
  matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
25
29
  matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
26
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
30
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
31
+ // Order statistic
32
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
27
33
  };
28
34
 
29
35
  // src/data-structures/matrix/matrix.ts
@@ -140,6 +146,10 @@ var Matrix = class _Matrix {
140
146
 
141
147
 
142
148
 
149
+
150
+
151
+
152
+
143
153
 
144
154
 
145
155
 
@@ -204,6 +214,10 @@ var Matrix = class _Matrix {
204
214
 
205
215
 
206
216
 
217
+
218
+
219
+
220
+
207
221
 
208
222
 
209
223
 
@@ -264,6 +278,10 @@ var Matrix = class _Matrix {
264
278
 
265
279
 
266
280
 
281
+
282
+
283
+
284
+
267
285
 
268
286
 
269
287
 
@@ -294,7 +312,7 @@ var Matrix = class _Matrix {
294
312
  */
295
313
  add(matrix) {
296
314
  if (!this.isMatchForCalculate(matrix)) {
297
- throw new Error(ERR.matrixDimensionMismatch("addition"));
315
+ raise(Error, ERR.matrixDimensionMismatch("addition"));
298
316
  }
299
317
  const resultData = [];
300
318
  for (let i = 0; i < this.rows; i++) {
@@ -346,6 +364,10 @@ var Matrix = class _Matrix {
346
364
 
347
365
 
348
366
 
367
+
368
+
369
+
370
+
349
371
 
350
372
 
351
373
 
@@ -360,7 +382,7 @@ var Matrix = class _Matrix {
360
382
  */
361
383
  subtract(matrix) {
362
384
  if (!this.isMatchForCalculate(matrix)) {
363
- throw new Error(ERR.matrixDimensionMismatch("subtraction"));
385
+ raise(Error, ERR.matrixDimensionMismatch("subtraction"));
364
386
  }
365
387
  const resultData = [];
366
388
  for (let i = 0; i < this.rows; i++) {
@@ -411,6 +433,10 @@ var Matrix = class _Matrix {
411
433
 
412
434
 
413
435
 
436
+
437
+
438
+
439
+
414
440
 
415
441
 
416
442
 
@@ -441,7 +467,7 @@ var Matrix = class _Matrix {
441
467
  */
442
468
  multiply(matrix) {
443
469
  if (this.cols !== matrix.rows) {
444
- throw new Error(ERR.matrixDimensionMismatch("multiplication (A.cols must equal B.rows)"));
470
+ raise(Error, ERR.matrixDimensionMismatch("multiplication (A.cols must equal B.rows)"));
445
471
  }
446
472
  const resultData = [];
447
473
  for (let i = 0; i < this.rows; i++) {
@@ -498,6 +524,10 @@ var Matrix = class _Matrix {
498
524
 
499
525
 
500
526
 
527
+
528
+
529
+
530
+
501
531
 
502
532
 
503
533
 
@@ -525,7 +555,7 @@ var Matrix = class _Matrix {
525
555
  */
526
556
  transpose() {
527
557
  if (this.data.some((row) => row.length !== this.cols)) {
528
- throw new Error(ERR.matrixNotRectangular());
558
+ raise(Error, ERR.matrixNotRectangular());
529
559
  }
530
560
  const resultData = [];
531
561
  for (let j = 0; j < this.cols; j++) {
@@ -572,6 +602,10 @@ var Matrix = class _Matrix {
572
602
 
573
603
 
574
604
 
605
+
606
+
607
+
608
+
575
609
 
576
610
 
577
611
 
@@ -591,7 +625,7 @@ var Matrix = class _Matrix {
591
625
  */
592
626
  inverse() {
593
627
  if (this.rows !== this.cols) {
594
- throw new Error(ERR.matrixNotSquare());
628
+ raise(Error, ERR.matrixNotSquare());
595
629
  }
596
630
  const augmentedMatrixData = [];
597
631
  for (let i = 0; i < this.rows; i++) {
@@ -613,12 +647,12 @@ var Matrix = class _Matrix {
613
647
  pivotRow++;
614
648
  }
615
649
  if (pivotRow === this.rows) {
616
- throw new Error(ERR.matrixSingular());
650
+ raise(Error, ERR.matrixSingular());
617
651
  }
618
652
  augmentedMatrix._swapRows(i, pivotRow);
619
653
  const pivotElement = augmentedMatrix.get(i, i) ?? 1;
620
654
  if (pivotElement === 0) {
621
- throw new Error(ERR.matrixSingular());
655
+ raise(Error, ERR.matrixSingular());
622
656
  }
623
657
  augmentedMatrix._scaleRow(i, 1 / pivotElement);
624
658
  for (let j = 0; j < this.rows; j++) {
@@ -671,6 +705,10 @@ var Matrix = class _Matrix {
671
705
 
672
706
 
673
707
 
708
+
709
+
710
+
711
+
674
712
 
675
713
 
676
714
 
@@ -685,7 +723,7 @@ var Matrix = class _Matrix {
685
723
  */
686
724
  dot(matrix) {
687
725
  if (this.cols !== matrix.rows) {
688
- throw new Error(ERR.matrixDimensionMismatch("dot product (A.cols must equal B.rows)"));
726
+ raise(Error, ERR.matrixDimensionMismatch("dot product (A.cols must equal B.rows)"));
689
727
  }
690
728
  const resultData = [];
691
729
  for (let i = 0; i < this.rows; i++) {
@@ -1,6 +1,37 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/common/error.ts
5
+ function raise(ErrorClass, message) {
6
+ throw new ErrorClass(message);
7
+ }
8
+ __name(raise, "raise");
9
+ var ERR = {
10
+ // Range / index
11
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
12
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
13
+ // Type / argument
14
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
15
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
16
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
17
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
18
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
19
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
20
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
21
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
22
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
23
+ // State / operation
24
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
25
+ // Matrix
26
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
27
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
28
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
29
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
30
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
31
+ // Order statistic
32
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
33
+ };
34
+
4
35
  // src/data-structures/base/iterable-element-base.ts
5
36
  var IterableElementBase = class {
6
37
  static {
@@ -19,7 +50,7 @@ var IterableElementBase = class {
19
50
  if (options) {
20
51
  const { toElementFn } = options;
21
52
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
22
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
53
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
23
54
  }
24
55
  }
25
56
  /**
@@ -182,7 +213,7 @@ var IterableElementBase = class {
182
213
  acc = initialValue;
183
214
  } else {
184
215
  const first = iter.next();
185
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
216
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
186
217
  acc = first.value;
187
218
  index = 1;
188
219
  }
@@ -224,31 +255,6 @@ var IterableElementBase = class {
224
255
  }
225
256
  };
226
257
 
227
- // src/common/error.ts
228
- var ERR = {
229
- // Range / index
230
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
231
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
232
- // Type / argument
233
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
234
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
235
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
236
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
237
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
238
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
239
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
240
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
241
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
242
- // State / operation
243
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
244
- // Matrix
245
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
246
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
247
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
248
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
249
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
250
- };
251
-
252
258
  // src/data-structures/heap/heap.ts
253
259
  var Heap = class _Heap extends IterableElementBase {
254
260
  static {
@@ -309,6 +315,10 @@ var Heap = class _Heap extends IterableElementBase {
309
315
 
310
316
 
311
317
 
318
+
319
+
320
+
321
+
312
322
 
313
323
 
314
324
 
@@ -391,6 +401,10 @@ var Heap = class _Heap extends IterableElementBase {
391
401
 
392
402
 
393
403
 
404
+
405
+
406
+
407
+
394
408
 
395
409
 
396
410
 
@@ -444,6 +458,10 @@ var Heap = class _Heap extends IterableElementBase {
444
458
 
445
459
 
446
460
 
461
+
462
+
463
+
464
+
447
465
 
448
466
 
449
467
 
@@ -499,6 +517,10 @@ var Heap = class _Heap extends IterableElementBase {
499
517
 
500
518
 
501
519
 
520
+
521
+
522
+
523
+
502
524
 
503
525
 
504
526
 
@@ -570,6 +592,10 @@ var Heap = class _Heap extends IterableElementBase {
570
592
 
571
593
 
572
594
 
595
+
596
+
597
+
598
+
573
599
 
574
600
 
575
601
 
@@ -666,6 +692,10 @@ var Heap = class _Heap extends IterableElementBase {
666
692
 
667
693
 
668
694
 
695
+
696
+
697
+
698
+
669
699
 
670
700
 
671
701
 
@@ -709,6 +739,10 @@ var Heap = class _Heap extends IterableElementBase {
709
739
 
710
740
 
711
741
 
742
+
743
+
744
+
745
+
712
746
 
713
747
 
714
748
 
@@ -755,6 +789,10 @@ var Heap = class _Heap extends IterableElementBase {
755
789
 
756
790
 
757
791
 
792
+
793
+
794
+
795
+
758
796
 
759
797
 
760
798
 
@@ -798,6 +836,10 @@ var Heap = class _Heap extends IterableElementBase {
798
836
 
799
837
 
800
838
 
839
+
840
+
841
+
842
+
801
843
 
802
844
 
803
845
 
@@ -887,6 +929,10 @@ var Heap = class _Heap extends IterableElementBase {
887
929
 
888
930
 
889
931
 
932
+
933
+
934
+
935
+
890
936
 
891
937
 
892
938
 
@@ -963,6 +1009,10 @@ var Heap = class _Heap extends IterableElementBase {
963
1009
 
964
1010
 
965
1011
 
1012
+
1013
+
1014
+
1015
+
966
1016
 
967
1017
 
968
1018
 
@@ -1012,6 +1062,10 @@ var Heap = class _Heap extends IterableElementBase {
1012
1062
 
1013
1063
 
1014
1064
 
1065
+
1066
+
1067
+
1068
+
1015
1069
 
1016
1070
 
1017
1071
 
@@ -1060,6 +1114,10 @@ var Heap = class _Heap extends IterableElementBase {
1060
1114
 
1061
1115
 
1062
1116
 
1117
+
1118
+
1119
+
1120
+
1063
1121
 
1064
1122
 
1065
1123
 
@@ -1115,6 +1173,10 @@ var Heap = class _Heap extends IterableElementBase {
1115
1173
 
1116
1174
 
1117
1175
 
1176
+
1177
+
1178
+
1179
+
1118
1180
 
1119
1181
 
1120
1182
 
@@ -1128,7 +1190,7 @@ var Heap = class _Heap extends IterableElementBase {
1128
1190
  */
1129
1191
  map(callback, options, thisArg) {
1130
1192
  const { comparator, toElementFn, ...rest } = options ?? {};
1131
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1193
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1132
1194
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1133
1195
  let i = 0;
1134
1196
  for (const x of this) {
@@ -1155,7 +1217,7 @@ var Heap = class _Heap extends IterableElementBase {
1155
1217
  }
1156
1218
  _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
1157
1219
  if (typeof a === "object" || typeof b === "object") {
1158
- throw new TypeError(ERR.comparatorRequired("Heap"));
1220
+ raise(TypeError, ERR.comparatorRequired("Heap"));
1159
1221
  }
1160
1222
  if (a > b) return 1;
1161
1223
  if (a < b) return -1;
@@ -1280,7 +1342,7 @@ var MaxPriorityQueue = class extends PriorityQueue {
1280
1342
  super(elements, {
1281
1343
  comparator: /* @__PURE__ */ __name((a, b) => {
1282
1344
  if (typeof a === "object" || typeof b === "object") {
1283
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1345
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1284
1346
  }
1285
1347
  if (a < b) return 1;
1286
1348
  if (a > b) return -1;