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
@@ -3,6 +3,37 @@ 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
+
6
37
  // src/data-structures/base/iterable-element-base.ts
7
38
  var _IterableElementBase = class _IterableElementBase {
8
39
  /**
@@ -25,7 +56,7 @@ var _IterableElementBase = class _IterableElementBase {
25
56
  if (options) {
26
57
  const { toElementFn } = options;
27
58
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
28
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
59
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
29
60
  }
30
61
  }
31
62
  /**
@@ -181,7 +212,7 @@ var _IterableElementBase = class _IterableElementBase {
181
212
  acc = initialValue;
182
213
  } else {
183
214
  const first = iter.next();
184
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
215
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
185
216
  acc = first.value;
186
217
  index = 1;
187
218
  }
@@ -225,31 +256,6 @@ var _IterableElementBase = class _IterableElementBase {
225
256
  __name(_IterableElementBase, "IterableElementBase");
226
257
  var IterableElementBase = _IterableElementBase;
227
258
 
228
- // src/common/error.ts
229
- var ERR = {
230
- // Range / index
231
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
232
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
233
- // Type / argument
234
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
235
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
236
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
237
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
238
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
239
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
240
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
241
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
242
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
243
- // State / operation
244
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
245
- // Matrix
246
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
247
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
248
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
249
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
250
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
251
- };
252
-
253
259
  // src/data-structures/trie/trie.ts
254
260
  var _TrieNode = class _TrieNode {
255
261
  /**
@@ -403,6 +409,10 @@ var _Trie = class _Trie extends IterableElementBase {
403
409
 
404
410
 
405
411
 
412
+
413
+
414
+
415
+
406
416
 
407
417
 
408
418
 
@@ -471,6 +481,10 @@ var _Trie = class _Trie extends IterableElementBase {
471
481
 
472
482
 
473
483
 
484
+
485
+
486
+
487
+
474
488
 
475
489
 
476
490
 
@@ -526,6 +540,10 @@ var _Trie = class _Trie extends IterableElementBase {
526
540
 
527
541
 
528
542
 
543
+
544
+
545
+
546
+
529
547
 
530
548
 
531
549
 
@@ -576,6 +594,10 @@ var _Trie = class _Trie extends IterableElementBase {
576
594
 
577
595
 
578
596
 
597
+
598
+
599
+
600
+
579
601
 
580
602
 
581
603
 
@@ -618,6 +640,10 @@ var _Trie = class _Trie extends IterableElementBase {
618
640
 
619
641
 
620
642
 
643
+
644
+
645
+
646
+
621
647
 
622
648
 
623
649
 
@@ -664,6 +690,10 @@ var _Trie = class _Trie extends IterableElementBase {
664
690
 
665
691
 
666
692
 
693
+
694
+
695
+
696
+
667
697
 
668
698
 
669
699
 
@@ -792,6 +822,10 @@ var _Trie = class _Trie extends IterableElementBase {
792
822
 
793
823
 
794
824
 
825
+
826
+
827
+
828
+
795
829
 
796
830
 
797
831
 
@@ -864,6 +898,10 @@ var _Trie = class _Trie extends IterableElementBase {
864
898
 
865
899
 
866
900
 
901
+
902
+
903
+
904
+
867
905
 
868
906
 
869
907
 
@@ -919,6 +957,10 @@ var _Trie = class _Trie extends IterableElementBase {
919
957
 
920
958
 
921
959
 
960
+
961
+
962
+
963
+
922
964
 
923
965
 
924
966
 
@@ -992,6 +1034,10 @@ var _Trie = class _Trie extends IterableElementBase {
992
1034
 
993
1035
 
994
1036
 
1037
+
1038
+
1039
+
1040
+
995
1041
 
996
1042
 
997
1043
 
@@ -1038,6 +1084,10 @@ var _Trie = class _Trie extends IterableElementBase {
1038
1084
 
1039
1085
 
1040
1086
 
1087
+
1088
+
1089
+
1090
+
1041
1091
 
1042
1092
 
1043
1093
 
@@ -1066,7 +1116,7 @@ var _Trie = class _Trie extends IterableElementBase {
1066
1116
  for (const x of this) {
1067
1117
  const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
1068
1118
  if (typeof v !== "string") {
1069
- throw new TypeError(ERR.callbackReturnType("string", typeof v, "Trie.map"));
1119
+ raise(TypeError, ERR.callbackReturnType("string", typeof v, "Trie.map"));
1070
1120
  }
1071
1121
  newTrie.add(v);
1072
1122
  }
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Centralized error dispatch.
3
+ * All library errors go through this function for consistent messaging and easy grep.
4
+ * @remarks Always throws — data structure errors are never recoverable.
5
+ * @param ErrorClass - The error constructor (Error, TypeError, RangeError, etc.)
6
+ * @param message - The error message.
7
+ */
8
+ export declare function raise(ErrorClass: new (msg: string) => Error, message: string): never;
1
9
  /**
2
10
  * Centralized error message templates.
3
11
  * Keep using native Error/TypeError/RangeError — this only standardizes messages.
@@ -20,4 +28,5 @@ export declare const ERR: {
20
28
  readonly matrixNotSquare: () => string;
21
29
  readonly matrixNotRectangular: () => string;
22
30
  readonly matrixRowMismatch: (expected: number, got: number) => string;
31
+ readonly orderStatisticNotEnabled: (method: string, ctx?: string) => string;
23
32
  };
@@ -1,4 +1,4 @@
1
- export { ERR } from './error';
1
+ export { ERR, raise } from './error';
2
2
  export declare enum DFSOperation {
3
3
  VISIT = 0,
4
4
  PROCESS = 1
@@ -366,6 +366,22 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
366
366
 
367
367
 
368
368
 
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
369
385
 
370
386
 
371
387
 
@@ -477,6 +493,18 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
477
493
 
478
494
 
479
495
 
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
480
508
 
481
509
 
482
510
 
@@ -548,6 +576,14 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
548
576
 
549
577
 
550
578
 
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
551
587
 
552
588
 
553
589
 
@@ -647,6 +683,18 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
647
683
 
648
684
 
649
685
 
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
650
698
 
651
699
 
652
700
 
@@ -74,6 +74,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
74
74
 
75
75
 
76
76
 
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
77
85
 
78
86
 
79
87
 
@@ -139,6 +147,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
139
147
 
140
148
 
141
149
 
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
142
158
 
143
159
 
144
160
 
@@ -203,6 +219,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
203
219
 
204
220
 
205
221
 
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
206
230
 
207
231
 
208
232
 
@@ -268,6 +292,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
268
292
 
269
293
 
270
294
 
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
271
303
 
272
304
 
273
305
 
@@ -331,6 +363,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
331
363
 
332
364
 
333
365
 
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
334
374
 
335
375
 
336
376
 
@@ -397,6 +437,14 @@ export declare class BinaryIndexedTree implements Iterable<number> {
397
437
 
398
438
 
399
439
 
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
400
448
 
401
449
 
402
450
 
@@ -435,6 +483,10 @@ export declare class BinaryIndexedTree implements Iterable<number> {
435
483
 
436
484
 
437
485
 
486
+
487
+
488
+
489
+
438
490
 
439
491
 
440
492
 
@@ -471,6 +523,10 @@ export declare class BinaryIndexedTree implements Iterable<number> {
471
523
 
472
524
 
473
525
 
526
+
527
+
528
+
529
+
474
530
 
475
531
 
476
532
 
@@ -136,7 +136,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
136
136
  * node?: BinaryTreeNode<string> | null,
137
137
  * conditions?: { [key: string]: boolean }
138
138
  * ): string {
139
- * if (!node) throw new Error('Invalid node');
139
+ * if (!node) raise(Error, 'Invalid node');
140
140
  *
141
141
  * // If it's a leaf node, return the decision result
142
142
  * if (!node.left && !node.right) return node.key;
@@ -181,7 +181,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
181
181
  * case '/':
182
182
  * return rightValue !== 0 ? leftValue / rightValue : 0; // Handle division by zero
183
183
  * default:
184
- * throw new Error(`Unsupported operator: ${node.key}`);
184
+ * raise(Error, `Unsupported operator: ${node.key}`);
185
185
  * }
186
186
  * }
187
187
  *
@@ -378,6 +378,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
378
378
 
379
379
 
380
380
 
381
+
382
+
383
+
384
+
381
385
 
382
386
 
383
387
 
@@ -426,6 +430,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
426
430
 
427
431
 
428
432
 
433
+
434
+
435
+
436
+
429
437
 
430
438
 
431
439
 
@@ -486,6 +494,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
486
494
 
487
495
 
488
496
 
497
+
498
+
499
+
500
+
489
501
 
490
502
 
491
503
 
@@ -522,6 +534,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
522
534
 
523
535
 
524
536
 
537
+
538
+
539
+
540
+
525
541
 
526
542
 
527
543
 
@@ -563,6 +579,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
563
579
 
564
580
 
565
581
 
582
+
583
+
584
+
585
+
566
586
 
567
587
 
568
588
 
@@ -616,6 +636,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
616
636
 
617
637
 
618
638
 
639
+
640
+
641
+
642
+
619
643
 
620
644
 
621
645
 
@@ -648,6 +672,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
648
672
 
649
673
 
650
674
 
675
+
676
+
677
+
678
+
651
679
 
652
680
 
653
681
 
@@ -693,6 +721,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
693
721
 
694
722
 
695
723
 
724
+
725
+
726
+
727
+
696
728
 
697
729
 
698
730
 
@@ -737,6 +769,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
737
769
 
738
770
 
739
771
 
772
+
773
+
774
+
775
+
740
776
 
741
777
 
742
778
 
@@ -782,6 +818,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
782
818
 
783
819
 
784
820
 
821
+
822
+
823
+
824
+
785
825
 
786
826
 
787
827
 
@@ -828,6 +868,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
828
868
 
829
869
 
830
870
 
871
+
872
+
873
+
874
+
831
875
 
832
876
 
833
877
 
@@ -890,6 +934,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
890
934
 
891
935
 
892
936
 
937
+
938
+
939
+
940
+
893
941
 
894
942
 
895
943
 
@@ -931,6 +979,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
931
979
 
932
980
 
933
981
 
982
+
983
+
984
+
985
+
934
986
 
935
987
 
936
988
 
@@ -980,6 +1032,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
980
1032
 
981
1033
 
982
1034
 
1035
+
1036
+
1037
+
1038
+
983
1039
 
984
1040
 
985
1041
 
@@ -1025,6 +1081,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1025
1081
 
1026
1082
 
1027
1083
 
1084
+
1085
+
1086
+
1087
+
1028
1088
 
1029
1089
 
1030
1090
 
@@ -1070,6 +1130,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1070
1130
 
1071
1131
 
1072
1132
 
1133
+
1134
+
1135
+
1136
+
1073
1137
 
1074
1138
 
1075
1139
 
@@ -1140,6 +1204,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1140
1204
 
1141
1205
 
1142
1206
 
1207
+
1208
+
1209
+
1210
+
1143
1211
 
1144
1212
 
1145
1213
 
@@ -1182,6 +1250,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1182
1250
 
1183
1251
 
1184
1252
 
1253
+
1254
+
1255
+
1256
+
1185
1257
 
1186
1258
 
1187
1259
 
@@ -1244,6 +1316,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1244
1316
 
1245
1317
 
1246
1318
 
1319
+
1320
+
1321
+
1322
+
1247
1323
 
1248
1324
 
1249
1325
 
@@ -1282,6 +1358,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1282
1358
 
1283
1359
 
1284
1360
 
1361
+
1362
+
1363
+
1364
+
1285
1365
 
1286
1366
 
1287
1367
 
@@ -1322,6 +1402,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1322
1402
 
1323
1403
 
1324
1404
 
1405
+
1406
+
1407
+
1408
+
1325
1409
 
1326
1410
 
1327
1411
 
@@ -1364,6 +1448,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1364
1448
 
1365
1449
 
1366
1450
 
1451
+
1452
+
1453
+
1454
+
1367
1455
 
1368
1456
 
1369
1457
 
@@ -1408,6 +1496,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1408
1496
 
1409
1497
 
1410
1498
 
1499
+
1500
+
1501
+
1502
+
1411
1503
 
1412
1504
 
1413
1505
 
@@ -1455,6 +1547,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1455
1547
 
1456
1548
 
1457
1549
 
1550
+
1551
+
1552
+
1553
+
1458
1554
 
1459
1555
 
1460
1556
 
@@ -1506,6 +1602,10 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1506
1602
 
1507
1603
 
1508
1604
 
1605
+
1606
+
1607
+
1608
+
1509
1609
 
1510
1610
 
1511
1611