data-structure-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 (184) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/MIGRATION.md +169 -0
  3. package/README.md +135 -23
  4. package/README_CN.md +551 -143
  5. package/SPECIFICATION.md +20 -14
  6. package/SPECIFICATION.zh-CN.md +20 -14
  7. package/dist/cjs/binary-tree.cjs +6460 -1591
  8. package/dist/cjs/graph.cjs +440 -20
  9. package/dist/cjs/hash.cjs +125 -22
  10. package/dist/cjs/heap.cjs +196 -47
  11. package/dist/cjs/index.cjs +8486 -2429
  12. package/dist/cjs/linked-list.cjs +456 -31
  13. package/dist/cjs/matrix.cjs +79 -9
  14. package/dist/cjs/priority-queue.cjs +193 -44
  15. package/dist/cjs/queue.cjs +391 -2
  16. package/dist/cjs/stack.cjs +92 -6
  17. package/dist/cjs/trie.cjs +122 -28
  18. package/dist/cjs-legacy/binary-tree.cjs +6484 -1612
  19. package/dist/cjs-legacy/graph.cjs +440 -20
  20. package/dist/cjs-legacy/hash.cjs +125 -22
  21. package/dist/cjs-legacy/heap.cjs +196 -47
  22. package/dist/cjs-legacy/index.cjs +8654 -2594
  23. package/dist/cjs-legacy/linked-list.cjs +456 -31
  24. package/dist/cjs-legacy/matrix.cjs +79 -9
  25. package/dist/cjs-legacy/priority-queue.cjs +193 -44
  26. package/dist/cjs-legacy/queue.cjs +391 -2
  27. package/dist/cjs-legacy/stack.cjs +92 -6
  28. package/dist/cjs-legacy/trie.cjs +122 -28
  29. package/dist/esm/binary-tree.mjs +6460 -1591
  30. package/dist/esm/graph.mjs +440 -20
  31. package/dist/esm/hash.mjs +125 -22
  32. package/dist/esm/heap.mjs +196 -47
  33. package/dist/esm/index.mjs +8486 -2430
  34. package/dist/esm/linked-list.mjs +456 -31
  35. package/dist/esm/matrix.mjs +79 -9
  36. package/dist/esm/priority-queue.mjs +193 -44
  37. package/dist/esm/queue.mjs +391 -2
  38. package/dist/esm/stack.mjs +92 -6
  39. package/dist/esm/trie.mjs +122 -28
  40. package/dist/esm-legacy/binary-tree.mjs +6484 -1612
  41. package/dist/esm-legacy/graph.mjs +440 -20
  42. package/dist/esm-legacy/hash.mjs +125 -22
  43. package/dist/esm-legacy/heap.mjs +196 -47
  44. package/dist/esm-legacy/index.mjs +8654 -2595
  45. package/dist/esm-legacy/linked-list.mjs +456 -31
  46. package/dist/esm-legacy/matrix.mjs +79 -9
  47. package/dist/esm-legacy/priority-queue.mjs +193 -44
  48. package/dist/esm-legacy/queue.mjs +391 -2
  49. package/dist/esm-legacy/stack.mjs +92 -6
  50. package/dist/esm-legacy/trie.mjs +122 -28
  51. package/dist/types/common/error.d.ts +9 -0
  52. package/dist/types/common/index.d.ts +1 -1
  53. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -2
  54. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +112 -0
  55. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +214 -13
  56. package/dist/types/data-structures/binary-tree/bst.d.ts +294 -3
  57. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +155 -8
  58. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +48 -0
  59. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1370 -323
  60. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1329 -316
  61. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +1116 -295
  62. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1330 -326
  63. package/dist/types/data-structures/graph/directed-graph.d.ts +80 -0
  64. package/dist/types/data-structures/graph/undirected-graph.d.ts +72 -0
  65. package/dist/types/data-structures/hash/hash-map.d.ts +95 -6
  66. package/dist/types/data-structures/heap/heap.d.ts +154 -12
  67. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +143 -0
  68. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -1
  69. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +144 -0
  70. package/dist/types/data-structures/matrix/matrix.d.ts +64 -0
  71. package/dist/types/data-structures/queue/deque.d.ts +142 -0
  72. package/dist/types/data-structures/queue/queue.d.ts +109 -0
  73. package/dist/types/data-structures/stack/stack.d.ts +82 -2
  74. package/dist/types/data-structures/trie/trie.d.ts +96 -0
  75. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  76. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  77. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  78. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  79. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  80. package/dist/umd/data-structure-typed.js +8623 -2564
  81. package/dist/umd/data-structure-typed.min.js +5 -5
  82. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +696 -194
  83. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  84. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
  85. package/docs-site-docusaurus/docs/api/classes/BST.md +639 -189
  86. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  87. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  88. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +148 -160
  89. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  90. package/docs-site-docusaurus/docs/api/classes/Deque.md +105 -91
  91. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
  92. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +104 -74
  93. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  94. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  95. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  96. package/docs-site-docusaurus/docs/api/classes/HashMap.md +51 -51
  97. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  98. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  99. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
  100. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
  101. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
  102. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +55 -55
  103. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  104. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
  105. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
  106. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  107. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  108. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  109. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  110. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  111. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  112. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  113. package/docs-site-docusaurus/docs/api/classes/Queue.md +112 -60
  114. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +708 -206
  115. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  116. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +79 -79
  117. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  118. package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
  119. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  120. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +236 -33
  121. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
  122. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +232 -32
  123. package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
  124. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  125. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
  126. package/docs-site-docusaurus/docs/guide/architecture.md +75 -5
  127. package/docs-site-docusaurus/docs/guide/concepts.md +53 -3
  128. package/docs-site-docusaurus/docs/guide/faq.md +233 -0
  129. package/docs-site-docusaurus/docs/guide/guides.md +43 -58
  130. package/docs-site-docusaurus/docs/guide/installation.md +2 -0
  131. package/docs-site-docusaurus/docs/guide/integrations.md +75 -176
  132. package/docs-site-docusaurus/docs/guide/overview.md +132 -11
  133. package/docs-site-docusaurus/docs/guide/performance.md +2 -0
  134. package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
  135. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  136. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  137. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  138. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  139. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  140. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  141. package/docs-site-docusaurus/docusaurus.config.ts +1 -1
  142. package/docs-site-docusaurus/src/pages/index.tsx +55 -2
  143. package/docs-site-docusaurus/static/llms.txt +37 -0
  144. package/docs-site-docusaurus/typedoc.json +1 -0
  145. package/llms.txt +37 -0
  146. package/package.json +65 -56
  147. package/src/common/error.ts +19 -1
  148. package/src/common/index.ts +1 -1
  149. package/src/data-structures/base/iterable-element-base.ts +3 -2
  150. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  151. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  152. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  153. package/src/data-structures/binary-tree/bst.ts +542 -13
  154. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  155. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  156. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  157. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  158. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  159. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  160. package/src/data-structures/graph/abstract-graph.ts +2 -2
  161. package/src/data-structures/graph/directed-graph.ts +71 -1
  162. package/src/data-structures/graph/undirected-graph.ts +64 -1
  163. package/src/data-structures/hash/hash-map.ts +102 -16
  164. package/src/data-structures/heap/heap.ts +153 -23
  165. package/src/data-structures/heap/max-heap.ts +2 -2
  166. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  167. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  168. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  169. package/src/data-structures/matrix/matrix.ts +65 -9
  170. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  171. package/src/data-structures/queue/deque.ts +130 -0
  172. package/src/data-structures/queue/queue.ts +109 -0
  173. package/src/data-structures/stack/stack.ts +75 -5
  174. package/src/data-structures/trie/trie.ts +86 -2
  175. package/src/interfaces/binary-tree.ts +1 -9
  176. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  177. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  178. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  179. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  180. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  181. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  182. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  183. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  184. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -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
  }
@@ -749,6 +780,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
749
780
 
750
781
 
751
782
 
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
752
791
 
753
792
 
754
793
 
@@ -812,6 +851,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
812
851
 
813
852
 
814
853
 
854
+
855
+
856
+
857
+
858
+
859
+
860
+
861
+
815
862
 
816
863
 
817
864
 
@@ -880,6 +927,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
880
927
 
881
928
 
882
929
 
930
+
931
+
932
+
933
+
934
+
935
+
936
+
937
+
883
938
 
884
939
 
885
940
 
@@ -930,6 +985,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
930
985
 
931
986
 
932
987
 
988
+
989
+
990
+
991
+
992
+
993
+
994
+
995
+
933
996
 
934
997
 
935
998
 
@@ -1041,6 +1104,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1041
1104
 
1042
1105
 
1043
1106
 
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1044
1115
 
1045
1116
 
1046
1117
 
@@ -1096,6 +1167,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1096
1167
 
1097
1168
 
1098
1169
 
1170
+
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+
1177
+
1099
1178
 
1100
1179
 
1101
1180
 
@@ -1140,6 +1219,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1140
1219
 
1141
1220
 
1142
1221
 
1222
+
1223
+
1224
+
1225
+
1226
+
1227
+
1228
+
1229
+
1143
1230
 
1144
1231
 
1145
1232
 
@@ -1190,6 +1277,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1190
1277
 
1191
1278
 
1192
1279
 
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1193
1288
 
1194
1289
 
1195
1290
 
@@ -1245,6 +1340,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1245
1340
 
1246
1341
 
1247
1342
 
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+
1248
1351
 
1249
1352
 
1250
1353
 
@@ -1308,6 +1411,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1308
1411
 
1309
1412
 
1310
1413
 
1414
+
1415
+
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1311
1422
 
1312
1423
 
1313
1424
 
@@ -1348,6 +1459,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1348
1459
 
1349
1460
 
1350
1461
 
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+
1468
+
1469
+
1351
1470
 
1352
1471
 
1353
1472
 
@@ -1394,6 +1513,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1394
1513
 
1395
1514
 
1396
1515
 
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+
1397
1524
 
1398
1525
 
1399
1526
 
@@ -1606,6 +1733,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1606
1733
 
1607
1734
 
1608
1735
 
1736
+
1737
+
1738
+
1739
+
1740
+
1741
+
1742
+
1743
+
1609
1744
 
1610
1745
 
1611
1746
 
@@ -1656,6 +1791,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1656
1791
 
1657
1792
 
1658
1793
 
1794
+
1795
+
1796
+
1797
+
1798
+
1799
+
1800
+
1801
+
1659
1802
 
1660
1803
 
1661
1804
 
@@ -1734,6 +1877,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1734
1877
 
1735
1878
 
1736
1879
 
1880
+
1881
+
1882
+
1883
+
1884
+
1885
+
1886
+
1887
+
1737
1888
 
1738
1889
 
1739
1890
 
@@ -2050,6 +2201,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2050
2201
 
2051
2202
 
2052
2203
 
2204
+
2205
+
2206
+
2207
+
2208
+
2209
+
2210
+
2211
+
2053
2212
 
2054
2213
 
2055
2214
 
@@ -2115,6 +2274,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2115
2274
 
2116
2275
 
2117
2276
 
2277
+
2278
+
2279
+
2280
+
2281
+
2282
+
2283
+
2284
+
2118
2285
 
2119
2286
 
2120
2287
 
@@ -2179,6 +2346,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2179
2346
 
2180
2347
 
2181
2348
 
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2355
+
2356
+
2182
2357
 
2183
2358
 
2184
2359
 
@@ -2234,6 +2409,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2234
2409
 
2235
2410
 
2236
2411
 
2412
+
2413
+
2414
+
2415
+
2416
+
2417
+
2418
+
2419
+
2237
2420
 
2238
2421
 
2239
2422
 
@@ -2318,6 +2501,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2318
2501
 
2319
2502
 
2320
2503
 
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2321
2512
 
2322
2513
 
2323
2514
 
@@ -2363,6 +2554,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2363
2554
 
2364
2555
 
2365
2556
 
2557
+
2558
+
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2366
2565
 
2367
2566
 
2368
2567
 
@@ -2439,6 +2638,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2439
2638
 
2440
2639
 
2441
2640
 
2641
+
2642
+
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2442
2649
 
2443
2650
 
2444
2651
 
@@ -2543,6 +2750,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2543
2750
 
2544
2751
 
2545
2752
 
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2546
2761
 
2547
2762
 
2548
2763
 
@@ -2594,6 +2809,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2594
2809
 
2595
2810
 
2596
2811
 
2812
+
2813
+
2814
+
2815
+
2816
+
2817
+
2818
+
2819
+
2597
2820
 
2598
2821
 
2599
2822
 
@@ -2647,6 +2870,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2647
2870
 
2648
2871
 
2649
2872
 
2873
+
2874
+
2875
+
2876
+
2877
+
2878
+
2879
+
2880
+
2650
2881
 
2651
2882
 
2652
2883
 
@@ -2687,6 +2918,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2687
2918
 
2688
2919
 
2689
2920
 
2921
+
2922
+
2923
+
2924
+
2925
+
2926
+
2927
+
2928
+
2690
2929
 
2691
2930
 
2692
2931
 
@@ -2731,6 +2970,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2731
2970
 
2732
2971
 
2733
2972
 
2973
+
2974
+
2975
+
2976
+
2977
+
2978
+
2979
+
2980
+
2734
2981
 
2735
2982
 
2736
2983
 
@@ -2779,6 +3026,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2779
3026
 
2780
3027
 
2781
3028
 
3029
+
3030
+
3031
+
3032
+
3033
+
3034
+
3035
+
3036
+
2782
3037
 
2783
3038
 
2784
3039
 
@@ -2830,6 +3085,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2830
3085
 
2831
3086
 
2832
3087
 
3088
+
3089
+
3090
+
3091
+
3092
+
3093
+
3094
+
3095
+
2833
3096
 
2834
3097
 
2835
3098
 
@@ -2855,6 +3118,25 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2855
3118
  }
2856
3119
  return this;
2857
3120
  }
3121
+ /**
3122
+ * Delete the first element that satisfies a predicate.
3123
+ * @remarks Time O(N), Space O(1)
3124
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3125
+ * @returns True if a match was removed.
3126
+ */
3127
+ deleteWhere(predicate) {
3128
+ let current = this.head;
3129
+ let index = 0;
3130
+ while (current) {
3131
+ if (predicate(current.value, index, this)) {
3132
+ this.delete(current);
3133
+ return true;
3134
+ }
3135
+ current = current.next;
3136
+ index++;
3137
+ }
3138
+ return false;
3139
+ }
2858
3140
  /**
2859
3141
  * Set the equality comparator used to compare values.
2860
3142
  * @remarks Time O(1), Space O(1)
@@ -2889,6 +3171,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2889
3171
 
2890
3172
 
2891
3173
 
3174
+
3175
+
3176
+
3177
+
3178
+
3179
+
3180
+
3181
+
2892
3182
 
2893
3183
 
2894
3184
 
@@ -2938,6 +3228,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2938
3228
 
2939
3229
 
2940
3230
 
3231
+
3232
+
3233
+
3234
+
3235
+
3236
+
3237
+
3238
+
2941
3239
 
2942
3240
 
2943
3241
 
@@ -3006,6 +3304,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3006
3304
 
3007
3305
 
3008
3306
 
3307
+
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3009
3315
 
3010
3316
 
3011
3317
 
@@ -3118,31 +3424,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3118
3424
  }
3119
3425
  };
3120
3426
 
3121
- // src/common/error.ts
3122
- var ERR = {
3123
- // Range / index
3124
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
3125
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
3126
- // Type / argument
3127
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
3128
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
3129
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
3130
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
3131
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
3132
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
3133
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
3134
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
3135
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
3136
- // State / operation
3137
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
3138
- // Matrix
3139
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
3140
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
3141
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
3142
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
3143
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
3144
- };
3145
-
3146
3427
  // src/data-structures/base/iterable-entry-base.ts
3147
3428
  var IterableEntryBase = class {
3148
3429
  static {
@@ -3360,7 +3641,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
3360
3641
  [k, v] = toEntryFn(item);
3361
3642
  } else {
3362
3643
  if (!Array.isArray(item) || item.length < 2) {
3363
- throw new TypeError(ERR.invalidEntry("SkipList"));
3644
+ raise(TypeError, ERR.invalidEntry("SkipList"));
3364
3645
  }
3365
3646
  [k, v] = item;
3366
3647
  }
@@ -3373,7 +3654,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
3373
3654
  static createDefaultComparator() {
3374
3655
  return (a, b) => {
3375
3656
  if (typeof a === "number" && typeof b === "number") {
3376
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("SkipList"));
3657
+ if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
3377
3658
  return a - b;
3378
3659
  }
3379
3660
  if (typeof a === "string" && typeof b === "string") {
@@ -3381,13 +3662,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
3381
3662
  }
3382
3663
  if (a instanceof Date && b instanceof Date) {
3383
3664
  const ta = a.getTime(), tb = b.getTime();
3384
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("SkipList"));
3665
+ if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
3385
3666
  return ta - tb;
3386
3667
  }
3387
3668
  if (typeof a === "bigint" && typeof b === "bigint") {
3388
3669
  return a < b ? -1 : a > b ? 1 : 0;
3389
3670
  }
3390
- throw new TypeError(ERR.comparatorRequired("SkipList"));
3671
+ raise(TypeError, ERR.comparatorRequired("SkipList"));
3391
3672
  };
3392
3673
  }
3393
3674
  // ─── Internal state ──────────────────────────────────────────
@@ -3430,6 +3711,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3430
3711
 
3431
3712
 
3432
3713
 
3714
+
3715
+
3716
+
3717
+
3718
+
3719
+
3720
+
3721
+
3433
3722
 
3434
3723
 
3435
3724
 
@@ -3468,6 +3757,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3468
3757
 
3469
3758
 
3470
3759
 
3760
+
3761
+
3762
+
3763
+
3764
+
3765
+
3766
+
3767
+
3471
3768
 
3472
3769
 
3473
3770
 
@@ -3509,6 +3806,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3509
3806
 
3510
3807
 
3511
3808
 
3809
+
3810
+
3811
+
3812
+
3813
+
3814
+
3815
+
3816
+
3512
3817
 
3513
3818
 
3514
3819
 
@@ -3558,6 +3863,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3558
3863
 
3559
3864
 
3560
3865
 
3866
+
3867
+
3868
+
3869
+
3870
+
3871
+
3872
+
3873
+
3561
3874
 
3562
3875
 
3563
3876
 
@@ -3632,6 +3945,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3632
3945
 
3633
3946
 
3634
3947
 
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+
3955
+
3635
3956
 
3636
3957
 
3637
3958
 
@@ -3691,6 +4012,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3691
4012
 
3692
4013
 
3693
4014
 
4015
+
4016
+
4017
+
4018
+
4019
+
4020
+
4021
+
4022
+
3694
4023
 
3695
4024
 
3696
4025
 
@@ -3733,6 +4062,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3733
4062
 
3734
4063
 
3735
4064
 
4065
+
4066
+
4067
+
4068
+
4069
+
4070
+
4071
+
4072
+
3736
4073
 
3737
4074
 
3738
4075
 
@@ -3795,6 +4132,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3795
4132
 
3796
4133
 
3797
4134
 
4135
+
4136
+
4137
+
4138
+
4139
+
4140
+
4141
+
4142
+
3798
4143
 
3799
4144
 
3800
4145
 
@@ -3837,6 +4182,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3837
4182
 
3838
4183
 
3839
4184
 
4185
+
4186
+
4187
+
4188
+
4189
+
4190
+
4191
+
4192
+
3840
4193
 
3841
4194
 
3842
4195
 
@@ -3881,6 +4234,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3881
4234
 
3882
4235
 
3883
4236
 
4237
+
4238
+
4239
+
4240
+
4241
+
4242
+
4243
+
4244
+
3884
4245
 
3885
4246
 
3886
4247
 
@@ -3923,6 +4284,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3923
4284
 
3924
4285
 
3925
4286
 
4287
+
4288
+
4289
+
4290
+
4291
+
4292
+
4293
+
4294
+
3926
4295
 
3927
4296
 
3928
4297
 
@@ -3968,6 +4337,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3968
4337
 
3969
4338
 
3970
4339
 
4340
+
4341
+
4342
+
4343
+
4344
+
4345
+
4346
+
4347
+
3971
4348
 
3972
4349
 
3973
4350
 
@@ -4018,6 +4395,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4018
4395
 
4019
4396
 
4020
4397
 
4398
+
4399
+
4400
+
4401
+
4402
+
4403
+
4404
+
4405
+
4021
4406
 
4022
4407
 
4023
4408
 
@@ -4066,6 +4451,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4066
4451
 
4067
4452
 
4068
4453
 
4454
+
4455
+
4456
+
4457
+
4458
+
4459
+
4460
+
4461
+
4069
4462
 
4070
4463
 
4071
4464
 
@@ -4113,6 +4506,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4113
4506
 
4114
4507
 
4115
4508
 
4509
+
4510
+
4511
+
4512
+
4513
+
4514
+
4515
+
4516
+
4116
4517
 
4117
4518
 
4118
4519
 
@@ -4166,6 +4567,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4166
4567
 
4167
4568
 
4168
4569
 
4570
+
4571
+
4572
+
4573
+
4574
+
4575
+
4576
+
4577
+
4169
4578
 
4170
4579
 
4171
4580
 
@@ -4227,6 +4636,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4227
4636
 
4228
4637
 
4229
4638
 
4639
+
4640
+
4641
+
4642
+
4643
+
4644
+
4645
+
4646
+
4230
4647
 
4231
4648
 
4232
4649
 
@@ -4272,6 +4689,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4272
4689
 
4273
4690
 
4274
4691
 
4692
+
4693
+
4694
+
4695
+
4696
+
4697
+
4698
+
4699
+
4275
4700
 
4276
4701
 
4277
4702