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
@@ -10,6 +10,37 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
10
10
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
11
11
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
12
12
 
13
+ // src/common/error.ts
14
+ function raise(ErrorClass, message) {
15
+ throw new ErrorClass(message);
16
+ }
17
+ __name(raise, "raise");
18
+ var ERR = {
19
+ // Range / index
20
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
21
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
22
+ // Type / argument
23
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
24
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
25
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
26
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
27
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
28
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
29
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
30
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
31
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
32
+ // State / operation
33
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
34
+ // Matrix
35
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
36
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
37
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
38
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
39
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
40
+ // Order statistic
41
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
42
+ };
43
+
13
44
  // src/data-structures/base/iterable-element-base.ts
14
45
  var _IterableElementBase = class _IterableElementBase {
15
46
  /**
@@ -32,7 +63,7 @@ var _IterableElementBase = class _IterableElementBase {
32
63
  if (options) {
33
64
  const { toElementFn } = options;
34
65
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
35
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
66
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
36
67
  }
37
68
  }
38
69
  /**
@@ -188,7 +219,7 @@ var _IterableElementBase = class _IterableElementBase {
188
219
  acc = initialValue;
189
220
  } else {
190
221
  const first = iter.next();
191
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
222
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
192
223
  acc = first.value;
193
224
  index = 1;
194
225
  }
@@ -752,6 +783,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
752
783
 
753
784
 
754
785
 
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
755
794
 
756
795
 
757
796
 
@@ -815,6 +854,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
815
854
 
816
855
 
817
856
 
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
818
865
 
819
866
 
820
867
 
@@ -884,6 +931,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
884
931
 
885
932
 
886
933
 
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
887
942
 
888
943
 
889
944
 
@@ -934,6 +989,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
934
989
 
935
990
 
936
991
 
992
+
993
+
994
+
995
+
996
+
997
+
998
+
999
+
937
1000
 
938
1001
 
939
1002
 
@@ -1045,6 +1108,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1045
1108
 
1046
1109
 
1047
1110
 
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1048
1119
 
1049
1120
 
1050
1121
 
@@ -1100,6 +1171,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1100
1171
 
1101
1172
 
1102
1173
 
1174
+
1175
+
1176
+
1177
+
1178
+
1179
+
1180
+
1181
+
1103
1182
 
1104
1183
 
1105
1184
 
@@ -1144,6 +1223,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1144
1223
 
1145
1224
 
1146
1225
 
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1147
1234
 
1148
1235
 
1149
1236
 
@@ -1194,6 +1281,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1194
1281
 
1195
1282
 
1196
1283
 
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1197
1292
 
1198
1293
 
1199
1294
 
@@ -1249,6 +1344,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1249
1344
 
1250
1345
 
1251
1346
 
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+
1252
1355
 
1253
1356
 
1254
1357
 
@@ -1312,6 +1415,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1312
1415
 
1313
1416
 
1314
1417
 
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+
1315
1426
 
1316
1427
 
1317
1428
 
@@ -1352,6 +1463,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1352
1463
 
1353
1464
 
1354
1465
 
1466
+
1467
+
1468
+
1469
+
1470
+
1471
+
1472
+
1473
+
1355
1474
 
1356
1475
 
1357
1476
 
@@ -1398,6 +1517,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1398
1517
 
1399
1518
 
1400
1519
 
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1401
1528
 
1402
1529
 
1403
1530
 
@@ -1610,6 +1737,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1610
1737
 
1611
1738
 
1612
1739
 
1740
+
1741
+
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1613
1748
 
1614
1749
 
1615
1750
 
@@ -1660,6 +1795,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1660
1795
 
1661
1796
 
1662
1797
 
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1663
1806
 
1664
1807
 
1665
1808
 
@@ -1738,6 +1881,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1738
1881
 
1739
1882
 
1740
1883
 
1884
+
1885
+
1886
+
1887
+
1888
+
1889
+
1890
+
1891
+
1741
1892
 
1742
1893
 
1743
1894
 
@@ -2054,6 +2205,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2054
2205
 
2055
2206
 
2056
2207
 
2208
+
2209
+
2210
+
2211
+
2212
+
2213
+
2214
+
2215
+
2057
2216
 
2058
2217
 
2059
2218
 
@@ -2119,6 +2278,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2119
2278
 
2120
2279
 
2121
2280
 
2281
+
2282
+
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+
2122
2289
 
2123
2290
 
2124
2291
 
@@ -2183,6 +2350,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2183
2350
 
2184
2351
 
2185
2352
 
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+
2359
+
2360
+
2186
2361
 
2187
2362
 
2188
2363
 
@@ -2238,6 +2413,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2238
2413
 
2239
2414
 
2240
2415
 
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+
2423
+
2241
2424
 
2242
2425
 
2243
2426
 
@@ -2322,6 +2505,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2322
2505
 
2323
2506
 
2324
2507
 
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2325
2516
 
2326
2517
 
2327
2518
 
@@ -2367,6 +2558,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2367
2558
 
2368
2559
 
2369
2560
 
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+
2370
2569
 
2371
2570
 
2372
2571
 
@@ -2443,6 +2642,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2443
2642
 
2444
2643
 
2445
2644
 
2645
+
2646
+
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2446
2653
 
2447
2654
 
2448
2655
 
@@ -2547,6 +2754,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2547
2754
 
2548
2755
 
2549
2756
 
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2550
2765
 
2551
2766
 
2552
2767
 
@@ -2598,6 +2813,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2598
2813
 
2599
2814
 
2600
2815
 
2816
+
2817
+
2818
+
2819
+
2820
+
2821
+
2822
+
2823
+
2601
2824
 
2602
2825
 
2603
2826
 
@@ -2651,6 +2874,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2651
2874
 
2652
2875
 
2653
2876
 
2877
+
2878
+
2879
+
2880
+
2881
+
2882
+
2883
+
2884
+
2654
2885
 
2655
2886
 
2656
2887
 
@@ -2691,6 +2922,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2691
2922
 
2692
2923
 
2693
2924
 
2925
+
2926
+
2927
+
2928
+
2929
+
2930
+
2931
+
2932
+
2694
2933
 
2695
2934
 
2696
2935
 
@@ -2735,6 +2974,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2735
2974
 
2736
2975
 
2737
2976
 
2977
+
2978
+
2979
+
2980
+
2981
+
2982
+
2983
+
2984
+
2738
2985
 
2739
2986
 
2740
2987
 
@@ -2783,6 +3030,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2783
3030
 
2784
3031
 
2785
3032
 
3033
+
3034
+
3035
+
3036
+
3037
+
3038
+
3039
+
3040
+
2786
3041
 
2787
3042
 
2788
3043
 
@@ -2834,6 +3089,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2834
3089
 
2835
3090
 
2836
3091
 
3092
+
3093
+
3094
+
3095
+
3096
+
3097
+
3098
+
3099
+
2837
3100
 
2838
3101
 
2839
3102
 
@@ -2859,6 +3122,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2859
3122
  }
2860
3123
  return this;
2861
3124
  }
3125
+ /**
3126
+ * Delete the first element that satisfies a predicate.
3127
+ * @remarks Time O(N), Space O(1)
3128
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3129
+ * @returns True if a match was removed.
3130
+ */
3131
+ deleteWhere(predicate) {
3132
+ let current = this.head;
3133
+ let index = 0;
3134
+ while (current) {
3135
+ if (predicate(current.value, index, this)) {
3136
+ this.delete(current);
3137
+ return true;
3138
+ }
3139
+ current = current.next;
3140
+ index++;
3141
+ }
3142
+ return false;
3143
+ }
2862
3144
  /**
2863
3145
  * Set the equality comparator used to compare values.
2864
3146
  * @remarks Time O(1), Space O(1)
@@ -2893,6 +3175,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2893
3175
 
2894
3176
 
2895
3177
 
3178
+
3179
+
3180
+
3181
+
3182
+
3183
+
3184
+
3185
+
2896
3186
 
2897
3187
 
2898
3188
 
@@ -2942,6 +3232,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2942
3232
 
2943
3233
 
2944
3234
 
3235
+
3236
+
3237
+
3238
+
3239
+
3240
+
3241
+
3242
+
2945
3243
 
2946
3244
 
2947
3245
 
@@ -3010,6 +3308,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3010
3308
 
3011
3309
 
3012
3310
 
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3013
3319
 
3014
3320
 
3015
3321
 
@@ -3124,31 +3430,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3124
3430
  __name(_DoublyLinkedList, "DoublyLinkedList");
3125
3431
  var DoublyLinkedList = _DoublyLinkedList;
3126
3432
 
3127
- // src/common/error.ts
3128
- var ERR = {
3129
- // Range / index
3130
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
3131
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
3132
- // Type / argument
3133
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
3134
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
3135
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
3136
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
3137
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
3138
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
3139
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
3140
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
3141
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
3142
- // State / operation
3143
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
3144
- // Matrix
3145
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
3146
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
3147
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
3148
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
3149
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
3150
- };
3151
-
3152
3433
  // src/data-structures/base/iterable-entry-base.ts
3153
3434
  var _IterableEntryBase = class _IterableEntryBase {
3154
3435
  /**
@@ -3368,7 +3649,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3368
3649
  [k, v] = toEntryFn(item);
3369
3650
  } else {
3370
3651
  if (!Array.isArray(item) || item.length < 2) {
3371
- throw new TypeError(ERR.invalidEntry("SkipList"));
3652
+ raise(TypeError, ERR.invalidEntry("SkipList"));
3372
3653
  }
3373
3654
  [k, v] = item;
3374
3655
  }
@@ -3381,7 +3662,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3381
3662
  static createDefaultComparator() {
3382
3663
  return (a, b) => {
3383
3664
  if (typeof a === "number" && typeof b === "number") {
3384
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("SkipList"));
3665
+ if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
3385
3666
  return a - b;
3386
3667
  }
3387
3668
  if (typeof a === "string" && typeof b === "string") {
@@ -3389,13 +3670,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3389
3670
  }
3390
3671
  if (a instanceof Date && b instanceof Date) {
3391
3672
  const ta = a.getTime(), tb = b.getTime();
3392
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("SkipList"));
3673
+ if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
3393
3674
  return ta - tb;
3394
3675
  }
3395
3676
  if (typeof a === "bigint" && typeof b === "bigint") {
3396
3677
  return a < b ? -1 : a > b ? 1 : 0;
3397
3678
  }
3398
- throw new TypeError(ERR.comparatorRequired("SkipList"));
3679
+ raise(TypeError, ERR.comparatorRequired("SkipList"));
3399
3680
  };
3400
3681
  }
3401
3682
  // ─── Size & lifecycle ────────────────────────────────────────
@@ -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