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
@@ -3,6 +3,37 @@
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 {
8
39
  static {
@@ -21,7 +52,7 @@ var IterableElementBase = class {
21
52
  if (options) {
22
53
  const { toElementFn } = options;
23
54
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
24
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
55
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
25
56
  }
26
57
  }
27
58
  /**
@@ -184,7 +215,7 @@ var IterableElementBase = class {
184
215
  acc = initialValue;
185
216
  } else {
186
217
  const first = iter.next();
187
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
218
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
188
219
  acc = first.value;
189
220
  index = 1;
190
221
  }
@@ -751,6 +782,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
751
782
 
752
783
 
753
784
 
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
754
793
 
755
794
 
756
795
 
@@ -814,6 +853,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
814
853
 
815
854
 
816
855
 
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
817
864
 
818
865
 
819
866
 
@@ -882,6 +929,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
882
929
 
883
930
 
884
931
 
932
+
933
+
934
+
935
+
936
+
937
+
938
+
939
+
885
940
 
886
941
 
887
942
 
@@ -932,6 +987,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
932
987
 
933
988
 
934
989
 
990
+
991
+
992
+
993
+
994
+
995
+
996
+
997
+
935
998
 
936
999
 
937
1000
 
@@ -1043,6 +1106,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1043
1106
 
1044
1107
 
1045
1108
 
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1046
1117
 
1047
1118
 
1048
1119
 
@@ -1098,6 +1169,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1098
1169
 
1099
1170
 
1100
1171
 
1172
+
1173
+
1174
+
1175
+
1176
+
1177
+
1178
+
1179
+
1101
1180
 
1102
1181
 
1103
1182
 
@@ -1142,6 +1221,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1142
1221
 
1143
1222
 
1144
1223
 
1224
+
1225
+
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+
1145
1232
 
1146
1233
 
1147
1234
 
@@ -1192,6 +1279,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1192
1279
 
1193
1280
 
1194
1281
 
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1195
1290
 
1196
1291
 
1197
1292
 
@@ -1247,6 +1342,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1247
1342
 
1248
1343
 
1249
1344
 
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1250
1353
 
1251
1354
 
1252
1355
 
@@ -1310,6 +1413,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1310
1413
 
1311
1414
 
1312
1415
 
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1313
1424
 
1314
1425
 
1315
1426
 
@@ -1350,6 +1461,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1350
1461
 
1351
1462
 
1352
1463
 
1464
+
1465
+
1466
+
1467
+
1468
+
1469
+
1470
+
1471
+
1353
1472
 
1354
1473
 
1355
1474
 
@@ -1396,6 +1515,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1396
1515
 
1397
1516
 
1398
1517
 
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1399
1526
 
1400
1527
 
1401
1528
 
@@ -1608,6 +1735,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1608
1735
 
1609
1736
 
1610
1737
 
1738
+
1739
+
1740
+
1741
+
1742
+
1743
+
1744
+
1745
+
1611
1746
 
1612
1747
 
1613
1748
 
@@ -1658,6 +1793,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1658
1793
 
1659
1794
 
1660
1795
 
1796
+
1797
+
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+
1661
1804
 
1662
1805
 
1663
1806
 
@@ -1736,6 +1879,14 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1736
1879
 
1737
1880
 
1738
1881
 
1882
+
1883
+
1884
+
1885
+
1886
+
1887
+
1888
+
1889
+
1739
1890
 
1740
1891
 
1741
1892
 
@@ -2052,6 +2203,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2052
2203
 
2053
2204
 
2054
2205
 
2206
+
2207
+
2208
+
2209
+
2210
+
2211
+
2212
+
2213
+
2055
2214
 
2056
2215
 
2057
2216
 
@@ -2117,6 +2276,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2117
2276
 
2118
2277
 
2119
2278
 
2279
+
2280
+
2281
+
2282
+
2283
+
2284
+
2285
+
2286
+
2120
2287
 
2121
2288
 
2122
2289
 
@@ -2181,6 +2348,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2181
2348
 
2182
2349
 
2183
2350
 
2351
+
2352
+
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+
2184
2359
 
2185
2360
 
2186
2361
 
@@ -2236,6 +2411,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2236
2411
 
2237
2412
 
2238
2413
 
2414
+
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2239
2422
 
2240
2423
 
2241
2424
 
@@ -2320,6 +2503,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2320
2503
 
2321
2504
 
2322
2505
 
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2323
2514
 
2324
2515
 
2325
2516
 
@@ -2365,6 +2556,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2365
2556
 
2366
2557
 
2367
2558
 
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2368
2567
 
2369
2568
 
2370
2569
 
@@ -2441,6 +2640,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2441
2640
 
2442
2641
 
2443
2642
 
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2649
+
2650
+
2444
2651
 
2445
2652
 
2446
2653
 
@@ -2545,6 +2752,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2545
2752
 
2546
2753
 
2547
2754
 
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2548
2763
 
2549
2764
 
2550
2765
 
@@ -2596,6 +2811,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2596
2811
 
2597
2812
 
2598
2813
 
2814
+
2815
+
2816
+
2817
+
2818
+
2819
+
2820
+
2821
+
2599
2822
 
2600
2823
 
2601
2824
 
@@ -2649,6 +2872,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2649
2872
 
2650
2873
 
2651
2874
 
2875
+
2876
+
2877
+
2878
+
2879
+
2880
+
2881
+
2882
+
2652
2883
 
2653
2884
 
2654
2885
 
@@ -2689,6 +2920,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2689
2920
 
2690
2921
 
2691
2922
 
2923
+
2924
+
2925
+
2926
+
2927
+
2928
+
2929
+
2930
+
2692
2931
 
2693
2932
 
2694
2933
 
@@ -2733,6 +2972,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2733
2972
 
2734
2973
 
2735
2974
 
2975
+
2976
+
2977
+
2978
+
2979
+
2980
+
2981
+
2982
+
2736
2983
 
2737
2984
 
2738
2985
 
@@ -2781,6 +3028,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2781
3028
 
2782
3029
 
2783
3030
 
3031
+
3032
+
3033
+
3034
+
3035
+
3036
+
3037
+
3038
+
2784
3039
 
2785
3040
 
2786
3041
 
@@ -2832,6 +3087,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2832
3087
 
2833
3088
 
2834
3089
 
3090
+
3091
+
3092
+
3093
+
3094
+
3095
+
3096
+
3097
+
2835
3098
 
2836
3099
 
2837
3100
 
@@ -2857,6 +3120,25 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2857
3120
  }
2858
3121
  return this;
2859
3122
  }
3123
+ /**
3124
+ * Delete the first element that satisfies a predicate.
3125
+ * @remarks Time O(N), Space O(1)
3126
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3127
+ * @returns True if a match was removed.
3128
+ */
3129
+ deleteWhere(predicate) {
3130
+ let current = this.head;
3131
+ let index = 0;
3132
+ while (current) {
3133
+ if (predicate(current.value, index, this)) {
3134
+ this.delete(current);
3135
+ return true;
3136
+ }
3137
+ current = current.next;
3138
+ index++;
3139
+ }
3140
+ return false;
3141
+ }
2860
3142
  /**
2861
3143
  * Set the equality comparator used to compare values.
2862
3144
  * @remarks Time O(1), Space O(1)
@@ -2891,6 +3173,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2891
3173
 
2892
3174
 
2893
3175
 
3176
+
3177
+
3178
+
3179
+
3180
+
3181
+
3182
+
3183
+
2894
3184
 
2895
3185
 
2896
3186
 
@@ -2940,6 +3230,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2940
3230
 
2941
3231
 
2942
3232
 
3233
+
3234
+
3235
+
3236
+
3237
+
3238
+
3239
+
3240
+
2943
3241
 
2944
3242
 
2945
3243
 
@@ -3008,6 +3306,14 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3008
3306
 
3009
3307
 
3010
3308
 
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3011
3317
 
3012
3318
 
3013
3319
 
@@ -3120,31 +3426,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3120
3426
  }
3121
3427
  };
3122
3428
 
3123
- // src/common/error.ts
3124
- var ERR = {
3125
- // Range / index
3126
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
3127
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
3128
- // Type / argument
3129
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
3130
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
3131
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
3132
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
3133
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
3134
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
3135
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
3136
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
3137
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
3138
- // State / operation
3139
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
3140
- // Matrix
3141
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
3142
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
3143
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
3144
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
3145
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
3146
- };
3147
-
3148
3429
  // src/data-structures/base/iterable-entry-base.ts
3149
3430
  var IterableEntryBase = class {
3150
3431
  static {
@@ -3362,7 +3643,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
3362
3643
  [k, v] = toEntryFn(item);
3363
3644
  } else {
3364
3645
  if (!Array.isArray(item) || item.length < 2) {
3365
- throw new TypeError(ERR.invalidEntry("SkipList"));
3646
+ raise(TypeError, ERR.invalidEntry("SkipList"));
3366
3647
  }
3367
3648
  [k, v] = item;
3368
3649
  }
@@ -3375,7 +3656,7 @@ var SkipList = class _SkipList extends IterableEntryBase {
3375
3656
  static createDefaultComparator() {
3376
3657
  return (a, b) => {
3377
3658
  if (typeof a === "number" && typeof b === "number") {
3378
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("SkipList"));
3659
+ if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
3379
3660
  return a - b;
3380
3661
  }
3381
3662
  if (typeof a === "string" && typeof b === "string") {
@@ -3383,13 +3664,13 @@ var SkipList = class _SkipList extends IterableEntryBase {
3383
3664
  }
3384
3665
  if (a instanceof Date && b instanceof Date) {
3385
3666
  const ta = a.getTime(), tb = b.getTime();
3386
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("SkipList"));
3667
+ if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
3387
3668
  return ta - tb;
3388
3669
  }
3389
3670
  if (typeof a === "bigint" && typeof b === "bigint") {
3390
3671
  return a < b ? -1 : a > b ? 1 : 0;
3391
3672
  }
3392
- throw new TypeError(ERR.comparatorRequired("SkipList"));
3673
+ raise(TypeError, ERR.comparatorRequired("SkipList"));
3393
3674
  };
3394
3675
  }
3395
3676
  // ─── Internal state ──────────────────────────────────────────
@@ -3432,6 +3713,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3432
3713
 
3433
3714
 
3434
3715
 
3716
+
3717
+
3718
+
3719
+
3720
+
3721
+
3722
+
3723
+
3435
3724
 
3436
3725
 
3437
3726
 
@@ -3470,6 +3759,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3470
3759
 
3471
3760
 
3472
3761
 
3762
+
3763
+
3764
+
3765
+
3766
+
3767
+
3768
+
3769
+
3473
3770
 
3474
3771
 
3475
3772
 
@@ -3511,6 +3808,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3511
3808
 
3512
3809
 
3513
3810
 
3811
+
3812
+
3813
+
3814
+
3815
+
3816
+
3817
+
3818
+
3514
3819
 
3515
3820
 
3516
3821
 
@@ -3560,6 +3865,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3560
3865
 
3561
3866
 
3562
3867
 
3868
+
3869
+
3870
+
3871
+
3872
+
3873
+
3874
+
3875
+
3563
3876
 
3564
3877
 
3565
3878
 
@@ -3634,6 +3947,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3634
3947
 
3635
3948
 
3636
3949
 
3950
+
3951
+
3952
+
3953
+
3954
+
3955
+
3956
+
3957
+
3637
3958
 
3638
3959
 
3639
3960
 
@@ -3693,6 +4014,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3693
4014
 
3694
4015
 
3695
4016
 
4017
+
4018
+
4019
+
4020
+
4021
+
4022
+
4023
+
4024
+
3696
4025
 
3697
4026
 
3698
4027
 
@@ -3735,6 +4064,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3735
4064
 
3736
4065
 
3737
4066
 
4067
+
4068
+
4069
+
4070
+
4071
+
4072
+
4073
+
4074
+
3738
4075
 
3739
4076
 
3740
4077
 
@@ -3797,6 +4134,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3797
4134
 
3798
4135
 
3799
4136
 
4137
+
4138
+
4139
+
4140
+
4141
+
4142
+
4143
+
4144
+
3800
4145
 
3801
4146
 
3802
4147
 
@@ -3839,6 +4184,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3839
4184
 
3840
4185
 
3841
4186
 
4187
+
4188
+
4189
+
4190
+
4191
+
4192
+
4193
+
4194
+
3842
4195
 
3843
4196
 
3844
4197
 
@@ -3883,6 +4236,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3883
4236
 
3884
4237
 
3885
4238
 
4239
+
4240
+
4241
+
4242
+
4243
+
4244
+
4245
+
4246
+
3886
4247
 
3887
4248
 
3888
4249
 
@@ -3925,6 +4286,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3925
4286
 
3926
4287
 
3927
4288
 
4289
+
4290
+
4291
+
4292
+
4293
+
4294
+
4295
+
4296
+
3928
4297
 
3929
4298
 
3930
4299
 
@@ -3970,6 +4339,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
3970
4339
 
3971
4340
 
3972
4341
 
4342
+
4343
+
4344
+
4345
+
4346
+
4347
+
4348
+
4349
+
3973
4350
 
3974
4351
 
3975
4352
 
@@ -4020,6 +4397,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4020
4397
 
4021
4398
 
4022
4399
 
4400
+
4401
+
4402
+
4403
+
4404
+
4405
+
4406
+
4407
+
4023
4408
 
4024
4409
 
4025
4410
 
@@ -4068,6 +4453,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4068
4453
 
4069
4454
 
4070
4455
 
4456
+
4457
+
4458
+
4459
+
4460
+
4461
+
4462
+
4463
+
4071
4464
 
4072
4465
 
4073
4466
 
@@ -4115,6 +4508,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4115
4508
 
4116
4509
 
4117
4510
 
4511
+
4512
+
4513
+
4514
+
4515
+
4516
+
4517
+
4518
+
4118
4519
 
4119
4520
 
4120
4521
 
@@ -4168,6 +4569,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4168
4569
 
4169
4570
 
4170
4571
 
4572
+
4573
+
4574
+
4575
+
4576
+
4577
+
4578
+
4579
+
4171
4580
 
4172
4581
 
4173
4582
 
@@ -4229,6 +4638,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4229
4638
 
4230
4639
 
4231
4640
 
4641
+
4642
+
4643
+
4644
+
4645
+
4646
+
4647
+
4648
+
4232
4649
 
4233
4650
 
4234
4651
 
@@ -4274,6 +4691,14 @@ var SkipList = class _SkipList extends IterableEntryBase {
4274
4691
 
4275
4692
 
4276
4693
 
4694
+
4695
+
4696
+
4697
+
4698
+
4699
+
4700
+
4701
+
4277
4702
 
4278
4703
 
4279
4704