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
@@ -12,6 +12,37 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
12
12
  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);
13
13
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
14
14
 
15
+ // src/common/error.ts
16
+ function raise(ErrorClass, message) {
17
+ throw new ErrorClass(message);
18
+ }
19
+ __name(raise, "raise");
20
+ var ERR = {
21
+ // Range / index
22
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
23
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
24
+ // Type / argument
25
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
26
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
27
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
28
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
29
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
30
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
31
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
32
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
33
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
34
+ // State / operation
35
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
36
+ // Matrix
37
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
38
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
39
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
40
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
41
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
42
+ // Order statistic
43
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
44
+ };
45
+
15
46
  // src/data-structures/base/iterable-element-base.ts
16
47
  var _IterableElementBase = class _IterableElementBase {
17
48
  /**
@@ -34,7 +65,7 @@ var _IterableElementBase = class _IterableElementBase {
34
65
  if (options) {
35
66
  const { toElementFn } = options;
36
67
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
37
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
68
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
38
69
  }
39
70
  }
40
71
  /**
@@ -190,7 +221,7 @@ var _IterableElementBase = class _IterableElementBase {
190
221
  acc = initialValue;
191
222
  } else {
192
223
  const first = iter.next();
193
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
224
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
194
225
  acc = first.value;
195
226
  index = 1;
196
227
  }
@@ -754,6 +785,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
754
785
 
755
786
 
756
787
 
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
757
796
 
758
797
 
759
798
 
@@ -817,6 +856,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
817
856
 
818
857
 
819
858
 
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
820
867
 
821
868
 
822
869
 
@@ -886,6 +933,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
886
933
 
887
934
 
888
935
 
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
889
944
 
890
945
 
891
946
 
@@ -936,6 +991,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
936
991
 
937
992
 
938
993
 
994
+
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+
939
1002
 
940
1003
 
941
1004
 
@@ -1047,6 +1110,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1047
1110
 
1048
1111
 
1049
1112
 
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1050
1121
 
1051
1122
 
1052
1123
 
@@ -1102,6 +1173,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1102
1173
 
1103
1174
 
1104
1175
 
1176
+
1177
+
1178
+
1179
+
1180
+
1181
+
1182
+
1183
+
1105
1184
 
1106
1185
 
1107
1186
 
@@ -1146,6 +1225,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1146
1225
 
1147
1226
 
1148
1227
 
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1149
1236
 
1150
1237
 
1151
1238
 
@@ -1196,6 +1283,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1196
1283
 
1197
1284
 
1198
1285
 
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1199
1294
 
1200
1295
 
1201
1296
 
@@ -1251,6 +1346,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1251
1346
 
1252
1347
 
1253
1348
 
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1254
1357
 
1255
1358
 
1256
1359
 
@@ -1314,6 +1417,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1314
1417
 
1315
1418
 
1316
1419
 
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+
1426
+
1427
+
1317
1428
 
1318
1429
 
1319
1430
 
@@ -1354,6 +1465,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1354
1465
 
1355
1466
 
1356
1467
 
1468
+
1469
+
1470
+
1471
+
1472
+
1473
+
1474
+
1475
+
1357
1476
 
1358
1477
 
1359
1478
 
@@ -1400,6 +1519,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1400
1519
 
1401
1520
 
1402
1521
 
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+
1403
1530
 
1404
1531
 
1405
1532
 
@@ -1612,6 +1739,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1612
1739
 
1613
1740
 
1614
1741
 
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1748
+
1749
+
1615
1750
 
1616
1751
 
1617
1752
 
@@ -1662,6 +1797,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1662
1797
 
1663
1798
 
1664
1799
 
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+
1807
+
1665
1808
 
1666
1809
 
1667
1810
 
@@ -1740,6 +1883,14 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1740
1883
 
1741
1884
 
1742
1885
 
1886
+
1887
+
1888
+
1889
+
1890
+
1891
+
1892
+
1893
+
1743
1894
 
1744
1895
 
1745
1896
 
@@ -2056,6 +2207,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2056
2207
 
2057
2208
 
2058
2209
 
2210
+
2211
+
2212
+
2213
+
2214
+
2215
+
2216
+
2217
+
2059
2218
 
2060
2219
 
2061
2220
 
@@ -2121,6 +2280,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2121
2280
 
2122
2281
 
2123
2282
 
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+
2289
+
2290
+
2124
2291
 
2125
2292
 
2126
2293
 
@@ -2185,6 +2352,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2185
2352
 
2186
2353
 
2187
2354
 
2355
+
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+
2188
2363
 
2189
2364
 
2190
2365
 
@@ -2240,6 +2415,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2240
2415
 
2241
2416
 
2242
2417
 
2418
+
2419
+
2420
+
2421
+
2422
+
2423
+
2424
+
2425
+
2243
2426
 
2244
2427
 
2245
2428
 
@@ -2324,6 +2507,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2324
2507
 
2325
2508
 
2326
2509
 
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2516
+
2517
+
2327
2518
 
2328
2519
 
2329
2520
 
@@ -2369,6 +2560,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2369
2560
 
2370
2561
 
2371
2562
 
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2372
2571
 
2373
2572
 
2374
2573
 
@@ -2445,6 +2644,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2445
2644
 
2446
2645
 
2447
2646
 
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2448
2655
 
2449
2656
 
2450
2657
 
@@ -2549,6 +2756,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2549
2756
 
2550
2757
 
2551
2758
 
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2552
2767
 
2553
2768
 
2554
2769
 
@@ -2600,6 +2815,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2600
2815
 
2601
2816
 
2602
2817
 
2818
+
2819
+
2820
+
2821
+
2822
+
2823
+
2824
+
2825
+
2603
2826
 
2604
2827
 
2605
2828
 
@@ -2653,6 +2876,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2653
2876
 
2654
2877
 
2655
2878
 
2879
+
2880
+
2881
+
2882
+
2883
+
2884
+
2885
+
2886
+
2656
2887
 
2657
2888
 
2658
2889
 
@@ -2693,6 +2924,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2693
2924
 
2694
2925
 
2695
2926
 
2927
+
2928
+
2929
+
2930
+
2931
+
2932
+
2933
+
2934
+
2696
2935
 
2697
2936
 
2698
2937
 
@@ -2737,6 +2976,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2737
2976
 
2738
2977
 
2739
2978
 
2979
+
2980
+
2981
+
2982
+
2983
+
2984
+
2985
+
2986
+
2740
2987
 
2741
2988
 
2742
2989
 
@@ -2785,6 +3032,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2785
3032
 
2786
3033
 
2787
3034
 
3035
+
3036
+
3037
+
3038
+
3039
+
3040
+
3041
+
3042
+
2788
3043
 
2789
3044
 
2790
3045
 
@@ -2836,6 +3091,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2836
3091
 
2837
3092
 
2838
3093
 
3094
+
3095
+
3096
+
3097
+
3098
+
3099
+
3100
+
3101
+
2839
3102
 
2840
3103
 
2841
3104
 
@@ -2861,6 +3124,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2861
3124
  }
2862
3125
  return this;
2863
3126
  }
3127
+ /**
3128
+ * Delete the first element that satisfies a predicate.
3129
+ * @remarks Time O(N), Space O(1)
3130
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3131
+ * @returns True if a match was removed.
3132
+ */
3133
+ deleteWhere(predicate) {
3134
+ let current = this.head;
3135
+ let index = 0;
3136
+ while (current) {
3137
+ if (predicate(current.value, index, this)) {
3138
+ this.delete(current);
3139
+ return true;
3140
+ }
3141
+ current = current.next;
3142
+ index++;
3143
+ }
3144
+ return false;
3145
+ }
2864
3146
  /**
2865
3147
  * Set the equality comparator used to compare values.
2866
3148
  * @remarks Time O(1), Space O(1)
@@ -2895,6 +3177,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2895
3177
 
2896
3178
 
2897
3179
 
3180
+
3181
+
3182
+
3183
+
3184
+
3185
+
3186
+
3187
+
2898
3188
 
2899
3189
 
2900
3190
 
@@ -2944,6 +3234,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2944
3234
 
2945
3235
 
2946
3236
 
3237
+
3238
+
3239
+
3240
+
3241
+
3242
+
3243
+
3244
+
2947
3245
 
2948
3246
 
2949
3247
 
@@ -3012,6 +3310,14 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3012
3310
 
3013
3311
 
3014
3312
 
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3319
+
3320
+
3015
3321
 
3016
3322
 
3017
3323
 
@@ -3126,31 +3432,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3126
3432
  __name(_DoublyLinkedList, "DoublyLinkedList");
3127
3433
  var DoublyLinkedList = _DoublyLinkedList;
3128
3434
 
3129
- // src/common/error.ts
3130
- var ERR = {
3131
- // Range / index
3132
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
3133
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
3134
- // Type / argument
3135
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
3136
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
3137
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
3138
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
3139
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
3140
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
3141
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
3142
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
3143
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
3144
- // State / operation
3145
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
3146
- // Matrix
3147
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
3148
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
3149
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
3150
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
3151
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
3152
- };
3153
-
3154
3435
  // src/data-structures/base/iterable-entry-base.ts
3155
3436
  var _IterableEntryBase = class _IterableEntryBase {
3156
3437
  /**
@@ -3370,7 +3651,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3370
3651
  [k, v] = toEntryFn(item);
3371
3652
  } else {
3372
3653
  if (!Array.isArray(item) || item.length < 2) {
3373
- throw new TypeError(ERR.invalidEntry("SkipList"));
3654
+ raise(TypeError, ERR.invalidEntry("SkipList"));
3374
3655
  }
3375
3656
  [k, v] = item;
3376
3657
  }
@@ -3383,7 +3664,7 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3383
3664
  static createDefaultComparator() {
3384
3665
  return (a, b) => {
3385
3666
  if (typeof a === "number" && typeof b === "number") {
3386
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("SkipList"));
3667
+ if (Number.isNaN(a) || Number.isNaN(b)) raise(TypeError, ERR.invalidNaN("SkipList"));
3387
3668
  return a - b;
3388
3669
  }
3389
3670
  if (typeof a === "string" && typeof b === "string") {
@@ -3391,13 +3672,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3391
3672
  }
3392
3673
  if (a instanceof Date && b instanceof Date) {
3393
3674
  const ta = a.getTime(), tb = b.getTime();
3394
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("SkipList"));
3675
+ if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("SkipList"));
3395
3676
  return ta - tb;
3396
3677
  }
3397
3678
  if (typeof a === "bigint" && typeof b === "bigint") {
3398
3679
  return a < b ? -1 : a > b ? 1 : 0;
3399
3680
  }
3400
- throw new TypeError(ERR.comparatorRequired("SkipList"));
3681
+ raise(TypeError, ERR.comparatorRequired("SkipList"));
3401
3682
  };
3402
3683
  }
3403
3684
  // ─── Size & lifecycle ────────────────────────────────────────
@@ -3434,6 +3715,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3434
3715
 
3435
3716
 
3436
3717
 
3718
+
3719
+
3720
+
3721
+
3722
+
3723
+
3724
+
3725
+
3437
3726
 
3438
3727
 
3439
3728
 
@@ -3472,6 +3761,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3472
3761
 
3473
3762
 
3474
3763
 
3764
+
3765
+
3766
+
3767
+
3768
+
3769
+
3770
+
3771
+
3475
3772
 
3476
3773
 
3477
3774
 
@@ -3513,6 +3810,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3513
3810
 
3514
3811
 
3515
3812
 
3813
+
3814
+
3815
+
3816
+
3817
+
3818
+
3819
+
3820
+
3516
3821
 
3517
3822
 
3518
3823
 
@@ -3562,6 +3867,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3562
3867
 
3563
3868
 
3564
3869
 
3870
+
3871
+
3872
+
3873
+
3874
+
3875
+
3876
+
3877
+
3565
3878
 
3566
3879
 
3567
3880
 
@@ -3636,6 +3949,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3636
3949
 
3637
3950
 
3638
3951
 
3952
+
3953
+
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3639
3960
 
3640
3961
 
3641
3962
 
@@ -3695,6 +4016,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3695
4016
 
3696
4017
 
3697
4018
 
4019
+
4020
+
4021
+
4022
+
4023
+
4024
+
4025
+
4026
+
3698
4027
 
3699
4028
 
3700
4029
 
@@ -3737,6 +4066,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3737
4066
 
3738
4067
 
3739
4068
 
4069
+
4070
+
4071
+
4072
+
4073
+
4074
+
4075
+
4076
+
3740
4077
 
3741
4078
 
3742
4079
 
@@ -3799,6 +4136,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3799
4136
 
3800
4137
 
3801
4138
 
4139
+
4140
+
4141
+
4142
+
4143
+
4144
+
4145
+
4146
+
3802
4147
 
3803
4148
 
3804
4149
 
@@ -3841,6 +4186,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3841
4186
 
3842
4187
 
3843
4188
 
4189
+
4190
+
4191
+
4192
+
4193
+
4194
+
4195
+
4196
+
3844
4197
 
3845
4198
 
3846
4199
 
@@ -3885,6 +4238,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3885
4238
 
3886
4239
 
3887
4240
 
4241
+
4242
+
4243
+
4244
+
4245
+
4246
+
4247
+
4248
+
3888
4249
 
3889
4250
 
3890
4251
 
@@ -3927,6 +4288,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3927
4288
 
3928
4289
 
3929
4290
 
4291
+
4292
+
4293
+
4294
+
4295
+
4296
+
4297
+
4298
+
3930
4299
 
3931
4300
 
3932
4301
 
@@ -3972,6 +4341,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3972
4341
 
3973
4342
 
3974
4343
 
4344
+
4345
+
4346
+
4347
+
4348
+
4349
+
4350
+
4351
+
3975
4352
 
3976
4353
 
3977
4354
 
@@ -4022,6 +4399,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4022
4399
 
4023
4400
 
4024
4401
 
4402
+
4403
+
4404
+
4405
+
4406
+
4407
+
4408
+
4409
+
4025
4410
 
4026
4411
 
4027
4412
 
@@ -4070,6 +4455,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4070
4455
 
4071
4456
 
4072
4457
 
4458
+
4459
+
4460
+
4461
+
4462
+
4463
+
4464
+
4465
+
4073
4466
 
4074
4467
 
4075
4468
 
@@ -4117,6 +4510,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4117
4510
 
4118
4511
 
4119
4512
 
4513
+
4514
+
4515
+
4516
+
4517
+
4518
+
4519
+
4520
+
4120
4521
 
4121
4522
 
4122
4523
 
@@ -4170,6 +4571,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4170
4571
 
4171
4572
 
4172
4573
 
4574
+
4575
+
4576
+
4577
+
4578
+
4579
+
4580
+
4581
+
4173
4582
 
4174
4583
 
4175
4584
 
@@ -4231,6 +4640,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4231
4640
 
4232
4641
 
4233
4642
 
4643
+
4644
+
4645
+
4646
+
4647
+
4648
+
4649
+
4650
+
4234
4651
 
4235
4652
 
4236
4653
 
@@ -4276,6 +4693,14 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4276
4693
 
4277
4694
 
4278
4695
 
4696
+
4697
+
4698
+
4699
+
4700
+
4701
+
4702
+
4703
+
4279
4704
 
4280
4705
 
4281
4706