data-structure-typed 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (711) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/COMMANDS.md +13 -3
  3. package/README.md +21 -38
  4. package/benchmark/report.html +1 -1
  5. package/benchmark/report.json +101 -101
  6. package/dist/cjs/index.cjs +13062 -0
  7. package/dist/cjs/index.cjs.map +1 -0
  8. package/dist/esm/index.mjs +12984 -0
  9. package/dist/esm/index.mjs.map +1 -0
  10. package/dist/{cjs → types}/data-structures/binary-tree/avl-tree-counter.d.ts +5 -5
  11. package/dist/{esm → types}/data-structures/binary-tree/avl-tree-multi-map.d.ts +6 -6
  12. package/dist/{esm → types}/data-structures/binary-tree/avl-tree.d.ts +5 -5
  13. package/dist/{esm → types}/data-structures/binary-tree/binary-tree.d.ts +6 -6
  14. package/dist/{esm → types}/data-structures/binary-tree/bst.d.ts +6 -6
  15. package/dist/{esm → types}/data-structures/binary-tree/red-black-tree.d.ts +6 -6
  16. package/dist/{cjs → types}/data-structures/binary-tree/tree-counter.d.ts +5 -5
  17. package/dist/{cjs → types}/data-structures/binary-tree/tree-multi-map.d.ts +6 -6
  18. package/dist/{esm → types}/data-structures/heap/heap.d.ts +4 -4
  19. package/dist/{esm → types}/data-structures/linked-list/singly-linked-list.d.ts +1 -1
  20. package/dist/{esm → types}/interfaces/binary-tree.d.ts +3 -3
  21. package/dist/umd/data-structure-typed.js +97 -174
  22. package/dist/umd/data-structure-typed.js.map +1 -0
  23. package/dist/umd/data-structure-typed.min.js +2 -2
  24. package/dist/umd/data-structure-typed.min.js.map +1 -1
  25. package/jest.integration.config.js +8 -1
  26. package/package.json +20 -14
  27. package/src/data-structures/binary-tree/avl-tree-counter.ts +8 -11
  28. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +6 -11
  29. package/src/data-structures/binary-tree/avl-tree.ts +6 -8
  30. package/src/data-structures/binary-tree/binary-tree.ts +18 -20
  31. package/src/data-structures/binary-tree/bst.ts +6 -11
  32. package/src/data-structures/binary-tree/red-black-tree.ts +6 -11
  33. package/src/data-structures/binary-tree/tree-counter.ts +8 -13
  34. package/src/data-structures/binary-tree/tree-multi-map.ts +6 -11
  35. package/src/data-structures/heap/heap.ts +5 -5
  36. package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
  37. package/src/interfaces/binary-tree.ts +3 -3
  38. package/test/integration/all-in-one.test.ts +1 -1
  39. package/test/integration/compile.test.mjs +159 -0
  40. package/test/integration/compile.test.ts +176 -0
  41. package/test/integration/heap.test.js +1 -1
  42. package/test/integration/index.html +1 -1
  43. package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
  44. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
  45. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +109 -1
  46. package/tsconfig.base.json +23 -0
  47. package/tsconfig.test.json +9 -0
  48. package/tsconfig.types.json +15 -0
  49. package/tsup.config.js +12 -24
  50. package/tsup.node.config.js +37 -0
  51. package/dist/cjs/common/index.js +0 -29
  52. package/dist/cjs/common/index.js.map +0 -1
  53. package/dist/cjs/data-structures/base/index.js +0 -19
  54. package/dist/cjs/data-structures/base/index.js.map +0 -1
  55. package/dist/cjs/data-structures/base/iterable-element-base.js +0 -244
  56. package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
  57. package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -184
  58. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
  59. package/dist/cjs/data-structures/base/linear-base.js +0 -416
  60. package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
  61. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -375
  62. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  63. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  64. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -251
  65. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  66. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -291
  67. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -612
  68. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  69. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
  70. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  71. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -754
  72. package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -1926
  73. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  74. package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -413
  75. package/dist/cjs/data-structures/binary-tree/bst.js +0 -904
  76. package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
  77. package/dist/cjs/data-structures/binary-tree/index.js +0 -27
  78. package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
  79. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  80. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -547
  81. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  82. package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
  83. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
  84. package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -414
  85. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
  86. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -385
  87. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  88. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -897
  89. package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
  90. package/dist/cjs/data-structures/graph/directed-graph.js +0 -526
  91. package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
  92. package/dist/cjs/data-structures/graph/index.js +0 -21
  93. package/dist/cjs/data-structures/graph/index.js.map +0 -1
  94. package/dist/cjs/data-structures/graph/map-graph.js +0 -108
  95. package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
  96. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -425
  97. package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
  98. package/dist/cjs/data-structures/hash/hash-map.js +0 -693
  99. package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
  100. package/dist/cjs/data-structures/hash/index.js +0 -18
  101. package/dist/cjs/data-structures/hash/index.js.map +0 -1
  102. package/dist/cjs/data-structures/heap/heap.d.ts +0 -503
  103. package/dist/cjs/data-structures/heap/heap.js +0 -902
  104. package/dist/cjs/data-structures/heap/heap.js.map +0 -1
  105. package/dist/cjs/data-structures/heap/index.js +0 -20
  106. package/dist/cjs/data-structures/heap/index.js.map +0 -1
  107. package/dist/cjs/data-structures/heap/max-heap.js +0 -41
  108. package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
  109. package/dist/cjs/data-structures/heap/min-heap.js +0 -32
  110. package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
  111. package/dist/cjs/data-structures/index.js +0 -29
  112. package/dist/cjs/data-structures/index.js.map +0 -1
  113. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1112
  114. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  115. package/dist/cjs/data-structures/linked-list/index.js +0 -20
  116. package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
  117. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  118. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -851
  119. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  120. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -145
  121. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  122. package/dist/cjs/data-structures/matrix/index.js +0 -19
  123. package/dist/cjs/data-structures/matrix/index.js.map +0 -1
  124. package/dist/cjs/data-structures/matrix/matrix.js +0 -449
  125. package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
  126. package/dist/cjs/data-structures/matrix/navigator.js +0 -112
  127. package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
  128. package/dist/cjs/data-structures/priority-queue/index.js +0 -20
  129. package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
  130. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -35
  131. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  132. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -25
  133. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  134. package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -21
  135. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
  136. package/dist/cjs/data-structures/queue/deque.js +0 -880
  137. package/dist/cjs/data-structures/queue/deque.js.map +0 -1
  138. package/dist/cjs/data-structures/queue/index.js +0 -19
  139. package/dist/cjs/data-structures/queue/index.js.map +0 -1
  140. package/dist/cjs/data-structures/queue/queue.js +0 -474
  141. package/dist/cjs/data-structures/queue/queue.js.map +0 -1
  142. package/dist/cjs/data-structures/stack/index.js +0 -18
  143. package/dist/cjs/data-structures/stack/index.js.map +0 -1
  144. package/dist/cjs/data-structures/stack/stack.js +0 -402
  145. package/dist/cjs/data-structures/stack/stack.js.map +0 -1
  146. package/dist/cjs/data-structures/tree/index.js +0 -18
  147. package/dist/cjs/data-structures/tree/index.js.map +0 -1
  148. package/dist/cjs/data-structures/tree/tree.js +0 -108
  149. package/dist/cjs/data-structures/tree/tree.js.map +0 -1
  150. package/dist/cjs/data-structures/trie/index.js +0 -18
  151. package/dist/cjs/data-structures/trie/index.js.map +0 -1
  152. package/dist/cjs/data-structures/trie/trie.js +0 -611
  153. package/dist/cjs/data-structures/trie/trie.js.map +0 -1
  154. package/dist/cjs/index.js +0 -22
  155. package/dist/cjs/index.js.map +0 -1
  156. package/dist/cjs/interfaces/binary-tree.d.ts +0 -59
  157. package/dist/cjs/interfaces/binary-tree.js +0 -3
  158. package/dist/cjs/interfaces/binary-tree.js.map +0 -1
  159. package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
  160. package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
  161. package/dist/cjs/interfaces/graph.js +0 -3
  162. package/dist/cjs/interfaces/graph.js.map +0 -1
  163. package/dist/cjs/interfaces/heap.js +0 -3
  164. package/dist/cjs/interfaces/heap.js.map +0 -1
  165. package/dist/cjs/interfaces/index.js +0 -25
  166. package/dist/cjs/interfaces/index.js.map +0 -1
  167. package/dist/cjs/interfaces/navigator.js +0 -3
  168. package/dist/cjs/interfaces/navigator.js.map +0 -1
  169. package/dist/cjs/interfaces/priority-queue.js +0 -3
  170. package/dist/cjs/interfaces/priority-queue.js.map +0 -1
  171. package/dist/cjs/interfaces/segment-tree.js +0 -3
  172. package/dist/cjs/interfaces/segment-tree.js.map +0 -1
  173. package/dist/cjs/interfaces/singly-linked-list.js +0 -3
  174. package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
  175. package/dist/cjs/types/common.js +0 -3
  176. package/dist/cjs/types/common.js.map +0 -1
  177. package/dist/cjs/types/data-structures/base/base.js +0 -3
  178. package/dist/cjs/types/data-structures/base/base.js.map +0 -1
  179. package/dist/cjs/types/data-structures/base/index.js +0 -18
  180. package/dist/cjs/types/data-structures/base/index.js.map +0 -1
  181. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
  182. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  183. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
  184. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  185. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
  186. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  187. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +0 -3
  188. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  189. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -3
  190. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  191. package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
  192. package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
  193. package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
  194. package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
  195. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
  196. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  197. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
  198. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  199. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
  200. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  201. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
  202. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  203. package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
  204. package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
  205. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
  206. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
  207. package/dist/cjs/types/data-structures/graph/index.js +0 -20
  208. package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
  209. package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
  210. package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
  211. package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
  212. package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
  213. package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
  214. package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
  215. package/dist/cjs/types/data-structures/hash/index.js +0 -18
  216. package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
  217. package/dist/cjs/types/data-structures/heap/heap.js +0 -3
  218. package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
  219. package/dist/cjs/types/data-structures/heap/index.js +0 -18
  220. package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
  221. package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
  222. package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
  223. package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
  224. package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
  225. package/dist/cjs/types/data-structures/index.js +0 -29
  226. package/dist/cjs/types/data-structures/index.js.map +0 -1
  227. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
  228. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  229. package/dist/cjs/types/data-structures/linked-list/index.js +0 -20
  230. package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
  231. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js +0 -3
  232. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  233. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +0 -3
  234. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  235. package/dist/cjs/types/data-structures/matrix/index.js +0 -19
  236. package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
  237. package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
  238. package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
  239. package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
  240. package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
  241. package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
  242. package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
  243. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +0 -3
  244. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  245. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +0 -3
  246. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  247. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js +0 -3
  248. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  249. package/dist/cjs/types/data-structures/queue/deque.js +0 -3
  250. package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
  251. package/dist/cjs/types/data-structures/queue/index.js +0 -19
  252. package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
  253. package/dist/cjs/types/data-structures/queue/queue.js +0 -3
  254. package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
  255. package/dist/cjs/types/data-structures/stack/index.js +0 -18
  256. package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
  257. package/dist/cjs/types/data-structures/stack/stack.js +0 -3
  258. package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
  259. package/dist/cjs/types/data-structures/tree/index.js +0 -18
  260. package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
  261. package/dist/cjs/types/data-structures/tree/tree.js +0 -3
  262. package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
  263. package/dist/cjs/types/data-structures/trie/index.js +0 -18
  264. package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
  265. package/dist/cjs/types/data-structures/trie/trie.js +0 -3
  266. package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
  267. package/dist/cjs/types/index.js +0 -20
  268. package/dist/cjs/types/index.js.map +0 -1
  269. package/dist/cjs/types/utils/index.js +0 -19
  270. package/dist/cjs/types/utils/index.js.map +0 -1
  271. package/dist/cjs/types/utils/utils.js +0 -3
  272. package/dist/cjs/types/utils/utils.js.map +0 -1
  273. package/dist/cjs/types/utils/validate-type.js +0 -3
  274. package/dist/cjs/types/utils/validate-type.js.map +0 -1
  275. package/dist/cjs/utils/index.js +0 -19
  276. package/dist/cjs/utils/index.js.map +0 -1
  277. package/dist/cjs/utils/number.js +0 -24
  278. package/dist/cjs/utils/number.js.map +0 -1
  279. package/dist/cjs/utils/utils.js +0 -354
  280. package/dist/cjs/utils/utils.js.map +0 -1
  281. package/dist/esm/common/index.d.ts +0 -12
  282. package/dist/esm/common/index.js +0 -29
  283. package/dist/esm/common/index.js.map +0 -1
  284. package/dist/esm/data-structures/base/index.d.ts +0 -2
  285. package/dist/esm/data-structures/base/index.js +0 -3
  286. package/dist/esm/data-structures/base/index.js.map +0 -1
  287. package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -219
  288. package/dist/esm/data-structures/base/iterable-element-base.js +0 -247
  289. package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
  290. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -144
  291. package/dist/esm/data-structures/base/iterable-entry-base.js +0 -180
  292. package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
  293. package/dist/esm/data-structures/base/linear-base.d.ts +0 -335
  294. package/dist/esm/data-structures/base/linear-base.js +0 -412
  295. package/dist/esm/data-structures/base/linear-base.js.map +0 -1
  296. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  297. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -369
  298. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  299. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -244
  300. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  301. package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -607
  302. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
  303. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  304. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
  305. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  306. package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -1922
  307. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
  308. package/dist/esm/data-structures/binary-tree/bst.js +0 -901
  309. package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
  310. package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
  311. package/dist/esm/data-structures/binary-tree/index.js +0 -11
  312. package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
  313. package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -540
  314. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
  315. package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
  316. package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
  317. package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
  318. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -190
  319. package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -412
  320. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
  321. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  322. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -378
  323. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  324. package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -340
  325. package/dist/esm/data-structures/graph/abstract-graph.js +0 -892
  326. package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
  327. package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -207
  328. package/dist/esm/data-structures/graph/directed-graph.js +0 -521
  329. package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
  330. package/dist/esm/data-structures/graph/index.d.ts +0 -4
  331. package/dist/esm/data-structures/graph/index.js +0 -5
  332. package/dist/esm/data-structures/graph/index.js.map +0 -1
  333. package/dist/esm/data-structures/graph/map-graph.d.ts +0 -78
  334. package/dist/esm/data-structures/graph/map-graph.js +0 -105
  335. package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
  336. package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -188
  337. package/dist/esm/data-structures/graph/undirected-graph.js +0 -418
  338. package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
  339. package/dist/esm/data-structures/hash/hash-map.d.ts +0 -345
  340. package/dist/esm/data-structures/hash/hash-map.js +0 -691
  341. package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
  342. package/dist/esm/data-structures/hash/index.d.ts +0 -1
  343. package/dist/esm/data-structures/hash/index.js +0 -2
  344. package/dist/esm/data-structures/hash/index.js.map +0 -1
  345. package/dist/esm/data-structures/heap/heap.js +0 -894
  346. package/dist/esm/data-structures/heap/heap.js.map +0 -1
  347. package/dist/esm/data-structures/heap/index.d.ts +0 -3
  348. package/dist/esm/data-structures/heap/index.js +0 -4
  349. package/dist/esm/data-structures/heap/index.js.map +0 -1
  350. package/dist/esm/data-structures/heap/max-heap.d.ts +0 -32
  351. package/dist/esm/data-structures/heap/max-heap.js +0 -40
  352. package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
  353. package/dist/esm/data-structures/heap/min-heap.d.ts +0 -33
  354. package/dist/esm/data-structures/heap/min-heap.js +0 -28
  355. package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
  356. package/dist/esm/data-structures/index.d.ts +0 -12
  357. package/dist/esm/data-structures/index.js +0 -13
  358. package/dist/esm/data-structures/index.js.map +0 -1
  359. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  360. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1109
  361. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  362. package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
  363. package/dist/esm/data-structures/linked-list/index.js +0 -4
  364. package/dist/esm/data-structures/linked-list/index.js.map +0 -1
  365. package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -847
  366. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
  367. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  368. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -143
  369. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
  370. package/dist/esm/data-structures/matrix/index.d.ts +0 -2
  371. package/dist/esm/data-structures/matrix/index.js +0 -3
  372. package/dist/esm/data-structures/matrix/index.js.map +0 -1
  373. package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
  374. package/dist/esm/data-structures/matrix/matrix.js +0 -444
  375. package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
  376. package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
  377. package/dist/esm/data-structures/matrix/navigator.js +0 -114
  378. package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
  379. package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
  380. package/dist/esm/data-structures/priority-queue/index.js +0 -4
  381. package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
  382. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  383. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -34
  384. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  385. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  386. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -21
  387. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  388. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -15
  389. package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -17
  390. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
  391. package/dist/esm/data-structures/queue/deque.d.ts +0 -431
  392. package/dist/esm/data-structures/queue/deque.js +0 -880
  393. package/dist/esm/data-structures/queue/deque.js.map +0 -1
  394. package/dist/esm/data-structures/queue/index.d.ts +0 -2
  395. package/dist/esm/data-structures/queue/index.js +0 -3
  396. package/dist/esm/data-structures/queue/index.js.map +0 -1
  397. package/dist/esm/data-structures/queue/queue.d.ts +0 -308
  398. package/dist/esm/data-structures/queue/queue.js +0 -467
  399. package/dist/esm/data-structures/queue/queue.js.map +0 -1
  400. package/dist/esm/data-structures/stack/index.d.ts +0 -1
  401. package/dist/esm/data-structures/stack/index.js +0 -2
  402. package/dist/esm/data-structures/stack/index.js.map +0 -1
  403. package/dist/esm/data-structures/stack/stack.d.ts +0 -306
  404. package/dist/esm/data-structures/stack/stack.js +0 -398
  405. package/dist/esm/data-structures/stack/stack.js.map +0 -1
  406. package/dist/esm/data-structures/tree/index.d.ts +0 -1
  407. package/dist/esm/data-structures/tree/index.js +0 -2
  408. package/dist/esm/data-structures/tree/index.js.map +0 -1
  409. package/dist/esm/data-structures/tree/tree.d.ts +0 -62
  410. package/dist/esm/data-structures/tree/tree.js +0 -107
  411. package/dist/esm/data-structures/tree/tree.js.map +0 -1
  412. package/dist/esm/data-structures/trie/index.d.ts +0 -1
  413. package/dist/esm/data-structures/trie/index.js +0 -2
  414. package/dist/esm/data-structures/trie/index.js.map +0 -1
  415. package/dist/esm/data-structures/trie/trie.d.ts +0 -350
  416. package/dist/esm/data-structures/trie/trie.js +0 -613
  417. package/dist/esm/data-structures/trie/trie.js.map +0 -1
  418. package/dist/esm/index.d.ts +0 -5
  419. package/dist/esm/index.js +0 -6
  420. package/dist/esm/index.js.map +0 -1
  421. package/dist/esm/interfaces/binary-tree.js +0 -2
  422. package/dist/esm/interfaces/binary-tree.js.map +0 -1
  423. package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
  424. package/dist/esm/interfaces/doubly-linked-list.js +0 -2
  425. package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
  426. package/dist/esm/interfaces/graph.d.ts +0 -21
  427. package/dist/esm/interfaces/graph.js +0 -2
  428. package/dist/esm/interfaces/graph.js.map +0 -1
  429. package/dist/esm/interfaces/heap.d.ts +0 -1
  430. package/dist/esm/interfaces/heap.js +0 -2
  431. package/dist/esm/interfaces/heap.js.map +0 -1
  432. package/dist/esm/interfaces/index.d.ts +0 -8
  433. package/dist/esm/interfaces/index.js +0 -9
  434. package/dist/esm/interfaces/index.js.map +0 -1
  435. package/dist/esm/interfaces/navigator.d.ts +0 -1
  436. package/dist/esm/interfaces/navigator.js +0 -2
  437. package/dist/esm/interfaces/navigator.js.map +0 -1
  438. package/dist/esm/interfaces/priority-queue.d.ts +0 -1
  439. package/dist/esm/interfaces/priority-queue.js +0 -2
  440. package/dist/esm/interfaces/priority-queue.js.map +0 -1
  441. package/dist/esm/interfaces/segment-tree.d.ts +0 -1
  442. package/dist/esm/interfaces/segment-tree.js +0 -2
  443. package/dist/esm/interfaces/segment-tree.js.map +0 -1
  444. package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
  445. package/dist/esm/interfaces/singly-linked-list.js +0 -2
  446. package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
  447. package/dist/esm/types/common.d.ts +0 -15
  448. package/dist/esm/types/common.js +0 -2
  449. package/dist/esm/types/common.js.map +0 -1
  450. package/dist/esm/types/data-structures/base/base.d.ts +0 -13
  451. package/dist/esm/types/data-structures/base/base.js +0 -2
  452. package/dist/esm/types/data-structures/base/base.js.map +0 -1
  453. package/dist/esm/types/data-structures/base/index.d.ts +0 -1
  454. package/dist/esm/types/data-structures/base/index.js +0 -2
  455. package/dist/esm/types/data-structures/base/index.js.map +0 -1
  456. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  457. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  458. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  459. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  460. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  461. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  462. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  463. package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
  464. package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  465. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
  466. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  467. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  468. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
  469. package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
  470. package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  471. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
  472. package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
  473. package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
  474. package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
  475. package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
  476. package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
  477. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
  478. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
  479. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  480. package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
  481. package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
  482. package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  483. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  484. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
  485. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  486. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
  487. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  488. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  489. package/dist/esm/types/data-structures/graph/abstract-graph.d.ts +0 -14
  490. package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
  491. package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
  492. package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
  493. package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
  494. package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
  495. package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
  496. package/dist/esm/types/data-structures/graph/index.js +0 -4
  497. package/dist/esm/types/data-structures/graph/index.js.map +0 -1
  498. package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
  499. package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
  500. package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
  501. package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
  502. package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
  503. package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
  504. package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
  505. package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
  506. package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
  507. package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
  508. package/dist/esm/types/data-structures/hash/index.js +0 -2
  509. package/dist/esm/types/data-structures/hash/index.js.map +0 -1
  510. package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
  511. package/dist/esm/types/data-structures/heap/heap.js +0 -2
  512. package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
  513. package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
  514. package/dist/esm/types/data-structures/heap/index.js +0 -2
  515. package/dist/esm/types/data-structures/heap/index.js.map +0 -1
  516. package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
  517. package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
  518. package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
  519. package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
  520. package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
  521. package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
  522. package/dist/esm/types/data-structures/index.d.ts +0 -12
  523. package/dist/esm/types/data-structures/index.js +0 -13
  524. package/dist/esm/types/data-structures/index.js.map +0 -1
  525. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
  526. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  527. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  528. package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
  529. package/dist/esm/types/data-structures/linked-list/index.js +0 -4
  530. package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
  531. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
  532. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
  533. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  534. package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
  535. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
  536. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  537. package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
  538. package/dist/esm/types/data-structures/matrix/index.js +0 -3
  539. package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
  540. package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
  541. package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
  542. package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
  543. package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
  544. package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
  545. package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
  546. package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
  547. package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
  548. package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
  549. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
  550. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  551. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  552. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
  553. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  554. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  555. package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
  556. package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
  557. package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  558. package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
  559. package/dist/esm/types/data-structures/queue/deque.js +0 -2
  560. package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
  561. package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
  562. package/dist/esm/types/data-structures/queue/index.js +0 -3
  563. package/dist/esm/types/data-structures/queue/index.js.map +0 -1
  564. package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
  565. package/dist/esm/types/data-structures/queue/queue.js +0 -2
  566. package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
  567. package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
  568. package/dist/esm/types/data-structures/stack/index.js +0 -2
  569. package/dist/esm/types/data-structures/stack/index.js.map +0 -1
  570. package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
  571. package/dist/esm/types/data-structures/stack/stack.js +0 -2
  572. package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
  573. package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
  574. package/dist/esm/types/data-structures/tree/index.js +0 -2
  575. package/dist/esm/types/data-structures/tree/index.js.map +0 -1
  576. package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
  577. package/dist/esm/types/data-structures/tree/tree.js +0 -2
  578. package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
  579. package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
  580. package/dist/esm/types/data-structures/trie/index.js +0 -2
  581. package/dist/esm/types/data-structures/trie/index.js.map +0 -1
  582. package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
  583. package/dist/esm/types/data-structures/trie/trie.js +0 -2
  584. package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
  585. package/dist/esm/types/index.d.ts +0 -3
  586. package/dist/esm/types/index.js +0 -4
  587. package/dist/esm/types/index.js.map +0 -1
  588. package/dist/esm/types/utils/index.d.ts +0 -2
  589. package/dist/esm/types/utils/index.js +0 -3
  590. package/dist/esm/types/utils/index.js.map +0 -1
  591. package/dist/esm/types/utils/utils.d.ts +0 -22
  592. package/dist/esm/types/utils/utils.js +0 -2
  593. package/dist/esm/types/utils/utils.js.map +0 -1
  594. package/dist/esm/types/utils/validate-type.d.ts +0 -19
  595. package/dist/esm/types/utils/validate-type.js +0 -2
  596. package/dist/esm/types/utils/validate-type.js.map +0 -1
  597. package/dist/esm/utils/index.d.ts +0 -2
  598. package/dist/esm/utils/index.js +0 -3
  599. package/dist/esm/utils/index.js.map +0 -1
  600. package/dist/esm/utils/number.d.ts +0 -14
  601. package/dist/esm/utils/number.js +0 -21
  602. package/dist/esm/utils/number.js.map +0 -1
  603. package/dist/esm/utils/utils.d.ts +0 -209
  604. package/dist/esm/utils/utils.js +0 -325
  605. package/dist/esm/utils/utils.js.map +0 -1
  606. package/test/integration/compile.js +0 -144
  607. package/test/integration/compile.mjs +0 -135
  608. package/test/integration/compile.ts +0 -171
  609. package/tsconfig-base.json +0 -24
  610. package/tsconfig-cjs.json +0 -14
  611. package/tsconfig-esm.json +0 -14
  612. /package/dist/{cjs → types}/common/index.d.ts +0 -0
  613. /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
  614. /package/dist/{cjs → types}/data-structures/base/iterable-element-base.d.ts +0 -0
  615. /package/dist/{cjs → types}/data-structures/base/iterable-entry-base.d.ts +0 -0
  616. /package/dist/{cjs → types}/data-structures/base/linear-base.d.ts +0 -0
  617. /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  618. /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
  619. /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  620. /package/dist/{cjs → types}/data-structures/graph/abstract-graph.d.ts +0 -0
  621. /package/dist/{cjs → types}/data-structures/graph/directed-graph.d.ts +0 -0
  622. /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
  623. /package/dist/{cjs → types}/data-structures/graph/map-graph.d.ts +0 -0
  624. /package/dist/{cjs → types}/data-structures/graph/undirected-graph.d.ts +0 -0
  625. /package/dist/{cjs → types}/data-structures/hash/hash-map.d.ts +0 -0
  626. /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
  627. /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
  628. /package/dist/{cjs → types}/data-structures/heap/max-heap.d.ts +0 -0
  629. /package/dist/{cjs → types}/data-structures/heap/min-heap.d.ts +0 -0
  630. /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
  631. /package/dist/{cjs → types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  632. /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
  633. /package/dist/{cjs → types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  634. /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
  635. /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
  636. /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
  637. /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
  638. /package/dist/{cjs → types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  639. /package/dist/{cjs → types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  640. /package/dist/{cjs → types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  641. /package/dist/{cjs → types}/data-structures/queue/deque.d.ts +0 -0
  642. /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
  643. /package/dist/{cjs → types}/data-structures/queue/queue.d.ts +0 -0
  644. /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
  645. /package/dist/{cjs → types}/data-structures/stack/stack.d.ts +0 -0
  646. /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
  647. /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
  648. /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
  649. /package/dist/{cjs → types}/data-structures/trie/trie.d.ts +0 -0
  650. /package/dist/{cjs → types}/index.d.ts +0 -0
  651. /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
  652. /package/dist/{cjs → types}/interfaces/graph.d.ts +0 -0
  653. /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
  654. /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
  655. /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
  656. /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
  657. /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
  658. /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
  659. /package/dist/{cjs → types}/types/common.d.ts +0 -0
  660. /package/dist/{cjs → types}/types/data-structures/base/base.d.ts +0 -0
  661. /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
  662. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
  663. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
  664. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
  665. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  666. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
  667. /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
  668. /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
  669. /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
  670. /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  671. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
  672. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
  673. /package/dist/{cjs → types}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  674. /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
  675. /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
  676. /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
  677. /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  678. /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
  679. /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
  680. /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
  681. /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
  682. /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
  683. /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
  684. /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
  685. /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  686. /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
  687. /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  688. /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  689. /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
  690. /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
  691. /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
  692. /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
  693. /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  694. /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  695. /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  696. /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
  697. /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
  698. /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
  699. /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
  700. /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
  701. /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
  702. /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
  703. /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
  704. /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
  705. /package/dist/{cjs → types}/types/index.d.ts +0 -0
  706. /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
  707. /package/dist/{cjs → types}/types/utils/utils.d.ts +0 -0
  708. /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
  709. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  710. /package/dist/{cjs → types}/utils/number.d.ts +0 -0
  711. /package/dist/{cjs → types}/utils/utils.d.ts +0 -0
@@ -1,847 +0,0 @@
1
- /**
2
- * data-structure-typed
3
- *
4
- * @author Pablo Zeng
5
- * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
- * @license MIT License
7
- */
8
- import { LinearLinkedBase, LinkedListNode } from '../base/linear-base';
9
- /**
10
- * Node of a singly linked list; stores value and the next link.
11
- * @remarks Time O(1), Space O(1)
12
- * @template E
13
- */
14
- export class SinglyLinkedListNode extends LinkedListNode {
15
- /**
16
- * Create a list node.
17
- * @remarks Time O(1), Space O(1)
18
- * @param value - Element value to store.
19
- * @returns New node instance.
20
- */
21
- constructor(value) {
22
- super(value);
23
- this._value = value;
24
- this._next = undefined;
25
- }
26
- _next;
27
- /**
28
- * Get the next node.
29
- * @remarks Time O(1), Space O(1)
30
- * @returns Next node or undefined.
31
- */
32
- get next() {
33
- return this._next;
34
- }
35
- /**
36
- * Set the next node.
37
- * @remarks Time O(1), Space O(1)
38
- * @param value - Next node or undefined.
39
- * @returns void
40
- */
41
- set next(value) {
42
- this._next = value;
43
- }
44
- }
45
- /**
46
- * Singly linked list with O(1) push/pop-like ends operations and linear scans.
47
- * @remarks Time O(1), Space O(1)
48
- * @template E
49
- * @template R
50
- * 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
51
- * 2. Bidirectional Traversal: Unlike doubly linked lists, singly linked lists can be easily traversed forwards but not backwards.
52
- * 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
53
- * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
54
- * Caution: Although our linked list classes provide methods such as at, setAt, addAt, and indexOf that are based on array indices, their time complexity, like that of the native Array.lastIndexOf, is 𝑂(𝑛). If you need to use these methods frequently, you might want to consider other data structures, such as Deque or Queue (designed for random access). Similarly, since the native Array.shift method has a time complexity of 𝑂(𝑛), using an array to simulate a queue can be inefficient. In such cases, you should use Queue or Deque, as these data structures leverage deferred array rearrangement, effectively reducing the average time complexity to 𝑂(1).
55
- * @example
56
- * // implementation of a basic text editor
57
- * class TextEditor {
58
- * private content: SinglyLinkedList<string>;
59
- * private cursorIndex: number;
60
- * private undoStack: Stack<{ operation: string; data?: any }>;
61
- *
62
- * constructor() {
63
- * this.content = new SinglyLinkedList<string>();
64
- * this.cursorIndex = 0; // Cursor starts at the beginning
65
- * this.undoStack = new Stack<{ operation: string; data?: any }>(); // Stack to keep track of operations for undo
66
- * }
67
- *
68
- * insert(char: string) {
69
- * this.content.addAt(this.cursorIndex, char);
70
- * this.cursorIndex++;
71
- * this.undoStack.push({ operation: 'insert', data: { index: this.cursorIndex - 1 } });
72
- * }
73
- *
74
- * delete() {
75
- * if (this.cursorIndex === 0) return; // Nothing to delete
76
- * const deleted = this.content.deleteAt(this.cursorIndex - 1);
77
- * this.cursorIndex--;
78
- * this.undoStack.push({ operation: 'delete', data: { index: this.cursorIndex, char: deleted } });
79
- * }
80
- *
81
- * moveCursor(index: number) {
82
- * this.cursorIndex = Math.max(0, Math.min(index, this.content.length));
83
- * }
84
- *
85
- * undo() {
86
- * if (this.undoStack.size === 0) return; // No operations to undo
87
- * const lastAction = this.undoStack.pop();
88
- *
89
- * if (lastAction!.operation === 'insert') {
90
- * this.content.deleteAt(lastAction!.data.index);
91
- * this.cursorIndex = lastAction!.data.index;
92
- * } else if (lastAction!.operation === 'delete') {
93
- * this.content.addAt(lastAction!.data.index, lastAction!.data.char);
94
- * this.cursorIndex = lastAction!.data.index + 1;
95
- * }
96
- * }
97
- *
98
- * getText(): string {
99
- * return [...this.content].join('');
100
- * }
101
- * }
102
- *
103
- * // Example Usage
104
- * const editor = new TextEditor();
105
- * editor.insert('H');
106
- * editor.insert('e');
107
- * editor.insert('l');
108
- * editor.insert('l');
109
- * editor.insert('o');
110
- * console.log(editor.getText()); // 'Hello' // Output: "Hello"
111
- *
112
- * editor.delete();
113
- * console.log(editor.getText()); // 'Hell' // Output: "Hell"
114
- *
115
- * editor.undo();
116
- * console.log(editor.getText()); // 'Hello' // Output: "Hello"
117
- *
118
- * editor.moveCursor(1);
119
- * editor.insert('a');
120
- * console.log(editor.getText()); // 'Haello'
121
- */
122
- export class SinglyLinkedList extends LinearLinkedBase {
123
- _equals = Object.is;
124
- /**
125
- * Create a SinglyLinkedList and optionally bulk-insert elements.
126
- * @remarks Time O(N), Space O(N)
127
- * @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).
128
- * @param [options] - Options such as maxLen and toElementFn.
129
- * @returns New SinglyLinkedList instance.
130
- */
131
- constructor(elements = [], options) {
132
- super(options);
133
- this.pushMany(elements);
134
- }
135
- _head;
136
- /**
137
- * Get the head node.
138
- * @remarks Time O(1), Space O(1)
139
- * @returns Head node or undefined.
140
- */
141
- get head() {
142
- return this._head;
143
- }
144
- _tail;
145
- /**
146
- * Get the tail node.
147
- * @remarks Time O(1), Space O(1)
148
- * @returns Tail node or undefined.
149
- */
150
- get tail() {
151
- return this._tail;
152
- }
153
- _length = 0;
154
- /**
155
- * Get the number of elements.
156
- * @remarks Time O(1), Space O(1)
157
- * @returns Current length.
158
- */
159
- get length() {
160
- return this._length;
161
- }
162
- /**
163
- * Get the first element value.
164
- * @remarks Time O(1), Space O(1)
165
- * @returns First element or undefined.
166
- */
167
- get first() {
168
- return this.head?.value;
169
- }
170
- /**
171
- * Get the last element value.
172
- * @remarks Time O(1), Space O(1)
173
- * @returns Last element or undefined.
174
- */
175
- get last() {
176
- return this.tail?.value;
177
- }
178
- /**
179
- * Create a new list from an iterable of elements.
180
- * @remarks Time O(N), Space O(N)
181
- * @template E
182
- * @template R
183
- * @template S
184
- * @param this - The constructor (subclass) to instantiate.
185
- * @param data - Iterable of elements to insert.
186
- * @param [options] - Options forwarded to the constructor.
187
- * @returns A new list populated with the iterable's elements.
188
- */
189
- static from(data, options) {
190
- const list = new this([], options);
191
- for (const x of data)
192
- list.push(x);
193
- return list;
194
- }
195
- /**
196
- * Append an element/node to the tail.
197
- * @remarks Time O(1), Space O(1)
198
- * @param elementOrNode - Element or node to append.
199
- * @returns True when appended.
200
- */
201
- push(elementOrNode) {
202
- const newNode = this._ensureNode(elementOrNode);
203
- if (!this.head) {
204
- this._head = this._tail = newNode;
205
- }
206
- else {
207
- this.tail.next = newNode;
208
- this._tail = newNode;
209
- }
210
- this._length++;
211
- if (this._maxLen > 0 && this.length > this._maxLen)
212
- this.shift();
213
- return true;
214
- }
215
- /**
216
- * Remove and return the tail element.
217
- * @remarks Time O(N), Space O(1)
218
- * @returns Removed element or undefined.
219
- */
220
- pop() {
221
- if (!this.head)
222
- return undefined;
223
- if (this.head === this.tail) {
224
- const value = this.head.value;
225
- this._head = undefined;
226
- this._tail = undefined;
227
- this._length--;
228
- return value;
229
- }
230
- let current = this.head;
231
- while (current.next !== this.tail)
232
- current = current.next;
233
- const value = this.tail.value;
234
- current.next = undefined;
235
- this._tail = current;
236
- this._length--;
237
- return value;
238
- }
239
- /**
240
- * Remove and return the head element.
241
- * @remarks Time O(1), Space O(1)
242
- * @returns Removed element or undefined.
243
- */
244
- shift() {
245
- if (!this.head)
246
- return undefined;
247
- const removed = this.head;
248
- this._head = this.head.next;
249
- if (!this._head)
250
- this._tail = undefined;
251
- this._length--;
252
- return removed.value;
253
- }
254
- /**
255
- * Prepend an element/node to the head.
256
- * @remarks Time O(1), Space O(1)
257
- * @param elementOrNode - Element or node to prepend.
258
- * @returns True when prepended.
259
- */
260
- unshift(elementOrNode) {
261
- const newNode = this._ensureNode(elementOrNode);
262
- if (!this.head) {
263
- this._head = this._tail = newNode;
264
- }
265
- else {
266
- newNode.next = this.head;
267
- this._head = newNode;
268
- }
269
- this._length++;
270
- return true;
271
- }
272
- /**
273
- * Append a sequence of elements/nodes.
274
- * @remarks Time O(N), Space O(1)
275
- * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
276
- * @returns Array of per-element success flags.
277
- */
278
- pushMany(elements) {
279
- const ans = [];
280
- for (const el of elements) {
281
- if (this.toElementFn)
282
- ans.push(this.push(this.toElementFn(el)));
283
- else
284
- ans.push(this.push(el));
285
- }
286
- return ans;
287
- }
288
- /**
289
- * Prepend a sequence of elements/nodes.
290
- * @remarks Time O(N), Space O(1)
291
- * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
292
- * @returns Array of per-element success flags.
293
- */
294
- unshiftMany(elements) {
295
- const ans = [];
296
- for (const el of elements) {
297
- if (this.toElementFn)
298
- ans.push(this.unshift(this.toElementFn(el)));
299
- else
300
- ans.push(this.unshift(el));
301
- }
302
- return ans;
303
- }
304
- /**
305
- * Find the first value matching a predicate (by node).
306
- * @remarks Time O(N), Space O(1)
307
- * @param elementNodeOrPredicate - Element, node, or node predicate to match.
308
- * @returns Matched value or undefined.
309
- */
310
- search(elementNodeOrPredicate) {
311
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
312
- let current = this.head;
313
- while (current) {
314
- if (predicate(current))
315
- return current.value;
316
- current = current.next;
317
- }
318
- return undefined;
319
- }
320
- /**
321
- * Get the element at a given index.
322
- * @remarks Time O(N), Space O(1)
323
- * @param index - Zero-based index.
324
- * @returns Element or undefined.
325
- */
326
- at(index) {
327
- if (index < 0 || index >= this._length)
328
- return undefined;
329
- let current = this.head;
330
- for (let i = 0; i < index; i++)
331
- current = current.next;
332
- return current.value;
333
- }
334
- /**
335
- * Type guard: check whether the input is a SinglyLinkedListNode.
336
- * @remarks Time O(1), Space O(1)
337
- * @param elementNodeOrPredicate - Element, node, or predicate.
338
- * @returns True if the value is a SinglyLinkedListNode.
339
- */
340
- isNode(elementNodeOrPredicate) {
341
- return elementNodeOrPredicate instanceof SinglyLinkedListNode;
342
- }
343
- /**
344
- * Get the node reference at a given index.
345
- * @remarks Time O(N), Space O(1)
346
- * @param index - Zero-based index.
347
- * @returns Node or undefined.
348
- */
349
- getNodeAt(index) {
350
- if (index < 0 || index >= this._length)
351
- return undefined;
352
- let current = this.head;
353
- for (let i = 0; i < index; i++)
354
- current = current.next;
355
- return current;
356
- }
357
- /**
358
- * Delete the element at an index.
359
- * @remarks Time O(N), Space O(1)
360
- * @param index - Zero-based index.
361
- * @returns Removed element or undefined.
362
- */
363
- deleteAt(index) {
364
- if (index < 0 || index >= this._length)
365
- return undefined;
366
- if (index === 0)
367
- return this.shift();
368
- const targetNode = this.getNodeAt(index);
369
- const prevNode = this._getPrevNode(targetNode);
370
- const value = targetNode.value;
371
- prevNode.next = targetNode.next;
372
- if (targetNode === this.tail)
373
- this._tail = prevNode;
374
- this._length--;
375
- return value;
376
- }
377
- /**
378
- * Delete the first match by value/node.
379
- * @remarks Time O(N), Space O(1)
380
- * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
381
- * @returns True if removed.
382
- */
383
- delete(elementOrNode) {
384
- if (elementOrNode === undefined || !this.head)
385
- return false;
386
- const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);
387
- if (!node)
388
- return false;
389
- const prevNode = this._getPrevNode(node);
390
- if (!prevNode) {
391
- this._head = node.next;
392
- if (node === this.tail)
393
- this._tail = undefined;
394
- }
395
- else {
396
- prevNode.next = node.next;
397
- if (node === this.tail)
398
- this._tail = prevNode;
399
- }
400
- this._length--;
401
- return true;
402
- }
403
- /**
404
- * Insert a new element/node at an index, shifting following nodes.
405
- * @remarks Time O(N), Space O(1)
406
- * @param index - Zero-based index.
407
- * @param newElementOrNode - Element or node to insert.
408
- * @returns True if inserted.
409
- */
410
- addAt(index, newElementOrNode) {
411
- if (index < 0 || index > this._length)
412
- return false;
413
- if (index === 0)
414
- return this.unshift(newElementOrNode);
415
- if (index === this._length)
416
- return this.push(newElementOrNode);
417
- const newNode = this._ensureNode(newElementOrNode);
418
- const prevNode = this.getNodeAt(index - 1);
419
- newNode.next = prevNode.next;
420
- prevNode.next = newNode;
421
- this._length++;
422
- return true;
423
- }
424
- /**
425
- * Set the element value at an index.
426
- * @remarks Time O(N), Space O(1)
427
- * @param index - Zero-based index.
428
- * @param value - New value.
429
- * @returns True if updated.
430
- */
431
- setAt(index, value) {
432
- const node = this.getNodeAt(index);
433
- if (!node)
434
- return false;
435
- node.value = value;
436
- return true;
437
- }
438
- /**
439
- * Check whether the list is empty.
440
- * @remarks Time O(1), Space O(1)
441
- * @returns True if length is 0.
442
- */
443
- isEmpty() {
444
- return this._length === 0;
445
- }
446
- /**
447
- * Remove all nodes and reset length.
448
- * @remarks Time O(N), Space O(1)
449
- * @returns void
450
- */
451
- clear() {
452
- this._head = undefined;
453
- this._tail = undefined;
454
- this._length = 0;
455
- }
456
- /**
457
- * Reverse the list in place.
458
- * @remarks Time O(N), Space O(1)
459
- * @returns This list.
460
- */
461
- reverse() {
462
- if (!this.head || this.head === this.tail)
463
- return this;
464
- let prev;
465
- let current = this.head;
466
- let next;
467
- while (current) {
468
- next = current.next;
469
- current.next = prev;
470
- prev = current;
471
- current = next;
472
- }
473
- [this._head, this._tail] = [this.tail, this.head];
474
- return this;
475
- }
476
- /**
477
- * Find a node by value, reference, or predicate.
478
- * @remarks Time O(N), Space O(1)
479
- * @param [elementNodeOrPredicate] - Element, node, or node predicate to match.
480
- * @returns Matching node or undefined.
481
- */
482
- getNode(elementNodeOrPredicate) {
483
- if (elementNodeOrPredicate === undefined)
484
- return;
485
- if (this.isNode(elementNodeOrPredicate))
486
- return elementNodeOrPredicate;
487
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
488
- let current = this.head;
489
- while (current) {
490
- if (predicate(current))
491
- return current;
492
- current = current.next;
493
- }
494
- return undefined;
495
- }
496
- /**
497
- * Insert a new element/node before an existing one.
498
- * @remarks Time O(N), Space O(1)
499
- * @param existingElementOrNode - Existing element or node.
500
- * @param newElementOrNode - Element or node to insert.
501
- * @returns True if inserted.
502
- */
503
- addBefore(existingElementOrNode, newElementOrNode) {
504
- const existingNode = this.getNode(existingElementOrNode);
505
- if (!existingNode)
506
- return false;
507
- const prevNode = this._getPrevNode(existingNode);
508
- const newNode = this._ensureNode(newElementOrNode);
509
- if (!prevNode) {
510
- newNode.next = this._head;
511
- this._head = newNode;
512
- if (!this._tail)
513
- this._tail = newNode;
514
- this._length++;
515
- }
516
- else {
517
- prevNode.next = newNode;
518
- newNode.next = existingNode;
519
- this._length++;
520
- }
521
- return true;
522
- }
523
- /**
524
- * Insert a new element/node after an existing one.
525
- * @remarks Time O(N), Space O(1)
526
- * @param existingElementOrNode - Existing element or node.
527
- * @param newElementOrNode - Element or node to insert.
528
- * @returns True if inserted.
529
- */
530
- addAfter(existingElementOrNode, newElementOrNode) {
531
- const existingNode = this.getNode(existingElementOrNode);
532
- if (!existingNode)
533
- return false;
534
- const newNode = this._ensureNode(newElementOrNode);
535
- newNode.next = existingNode.next;
536
- existingNode.next = newNode;
537
- if (existingNode === this.tail)
538
- this._tail = newNode;
539
- this._length++;
540
- return true;
541
- }
542
- /**
543
- * Remove and/or insert elements at a position (array-like behavior).
544
- * @remarks Time O(N + M), Space O(M)
545
- * @param start - Start index (clamped to [0, length]).
546
- * @param [deleteCount] - Number of elements to remove (default 0).
547
- * @param [items] - Elements to insert after `start`.
548
- * @returns A new list containing the removed elements (typed as `this`).
549
- */
550
- splice(start, deleteCount = 0, ...items) {
551
- start = Math.max(0, Math.min(start, this.length));
552
- deleteCount = Math.max(0, deleteCount);
553
- const removedList = this._createInstance();
554
- const prevNode = start === 0 ? undefined : this.getNodeAt(start - 1);
555
- let cur = prevNode ? prevNode.next : this.head;
556
- let removedCount = 0;
557
- while (removedCount < deleteCount && cur) {
558
- removedList.push(cur.value);
559
- cur = cur.next;
560
- removedCount++;
561
- }
562
- const afterNode = cur;
563
- if (prevNode) {
564
- prevNode.next = afterNode;
565
- }
566
- else {
567
- this._head = afterNode;
568
- }
569
- if (!afterNode)
570
- this._tail = prevNode;
571
- if (items.length > 0) {
572
- let firstInserted;
573
- let lastInserted;
574
- for (const it of items) {
575
- const node = this._ensureNode(it);
576
- if (!firstInserted)
577
- firstInserted = node;
578
- if (lastInserted)
579
- lastInserted.next = node;
580
- lastInserted = node;
581
- }
582
- if (prevNode)
583
- prevNode.next = firstInserted;
584
- else
585
- this._head = firstInserted;
586
- lastInserted.next = afterNode;
587
- if (!afterNode)
588
- this._tail = lastInserted;
589
- }
590
- this._length += items.length - removedCount;
591
- if (this._length === 0) {
592
- this._head = undefined;
593
- this._tail = undefined;
594
- }
595
- return removedList;
596
- }
597
- /**
598
- * Count how many nodes match a value/node/predicate.
599
- * @remarks Time O(N), Space O(1)
600
- * @param elementOrNode - Element, node, or node predicate to match.
601
- * @returns Number of matches in the list.
602
- */
603
- countOccurrences(elementOrNode) {
604
- const predicate = elementOrPredicate(elementOrNode, this._equals);
605
- let count = 0;
606
- let current = this.head;
607
- while (current) {
608
- if (predicate(current))
609
- count++;
610
- current = current.next;
611
- }
612
- return count;
613
- }
614
- /**
615
- * Set the equality comparator used to compare values.
616
- * @remarks Time O(1), Space O(1)
617
- * @param equals - Equality predicate (a, b) → boolean.
618
- * @returns This list.
619
- */
620
- setEquality(equals) {
621
- this._equals = equals;
622
- return this;
623
- }
624
- /**
625
- * Delete the first node whose value matches a predicate.
626
- * @remarks Time O(N), Space O(1)
627
- * @param predicate - Predicate (value, index, list) → boolean to decide deletion.
628
- * @returns True if a node was removed.
629
- */
630
- deleteWhere(predicate) {
631
- let prev;
632
- let current = this.head;
633
- let i = 0;
634
- while (current) {
635
- if (predicate(current.value, i++, this)) {
636
- if (!prev) {
637
- this._head = current.next;
638
- if (current === this._tail)
639
- this._tail = undefined;
640
- }
641
- else {
642
- prev.next = current.next;
643
- if (current === this._tail)
644
- this._tail = prev;
645
- }
646
- this._length--;
647
- return true;
648
- }
649
- prev = current;
650
- current = current.next;
651
- }
652
- return false;
653
- }
654
- /**
655
- * Deep clone this list (values are copied by reference).
656
- * @remarks Time O(N), Space O(N)
657
- * @returns A new list with the same element sequence.
658
- */
659
- clone() {
660
- const out = this._createInstance();
661
- for (const v of this)
662
- out.push(v);
663
- return out;
664
- }
665
- /**
666
- * Filter values into a new list of the same class.
667
- * @remarks Time O(N), Space O(N)
668
- * @param callback - Predicate (value, index, list) → boolean to keep value.
669
- * @param [thisArg] - Value for `this` inside the callback.
670
- * @returns A new list with kept values.
671
- */
672
- filter(callback, thisArg) {
673
- const out = this._createInstance();
674
- let index = 0;
675
- for (const value of this)
676
- if (callback.call(thisArg, value, index++, this))
677
- out.push(value);
678
- return out;
679
- }
680
- /**
681
- * Map values into a new list of the same class.
682
- * @remarks Time O(N), Space O(N)
683
- * @param callback - Mapping function (value, index, list) → newValue.
684
- * @param [thisArg] - Value for `this` inside the callback.
685
- * @returns A new list with mapped values.
686
- */
687
- mapSame(callback, thisArg) {
688
- const out = this._createInstance();
689
- let index = 0;
690
- for (const value of this) {
691
- const mv = thisArg === undefined ? callback(value, index++, this) : callback.call(thisArg, value, index++, this);
692
- out.push(mv);
693
- }
694
- return out;
695
- }
696
- /**
697
- * Map values into a new list (possibly different element type).
698
- * @remarks Time O(N), Space O(N)
699
- * @template EM
700
- * @template RM
701
- * @param callback - Mapping function (value, index, list) → newElement.
702
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
703
- * @param [thisArg] - Value for `this` inside the callback.
704
- * @returns A new SinglyLinkedList with mapped values.
705
- */
706
- map(callback, options, thisArg) {
707
- const out = this._createLike([], { ...(options ?? {}), maxLen: this._maxLen });
708
- let index = 0;
709
- for (const value of this)
710
- out.push(callback.call(thisArg, value, index++, this));
711
- return out;
712
- }
713
- /**
714
- * (Protected) Create a node from a value.
715
- * @remarks Time O(1), Space O(1)
716
- * @param value - Value to wrap in a node.
717
- * @returns A new SinglyLinkedListNode instance.
718
- */
719
- _createNode(value) {
720
- return new SinglyLinkedListNode(value);
721
- }
722
- /**
723
- * (Protected) Check if input is a node predicate function.
724
- * @remarks Time O(1), Space O(1)
725
- * @param elementNodeOrPredicate - Element, node, or node predicate.
726
- * @returns True if input is a predicate function.
727
- */
728
- _isPredicate(elementNodeOrPredicate) {
729
- return typeof elementNodeOrPredicate === 'function';
730
- }
731
- /**
732
- * (Protected) Normalize input into a node instance.
733
- * @remarks Time O(1), Space O(1)
734
- * @param elementOrNode - Element or node.
735
- * @returns A SinglyLinkedListNode for the provided input.
736
- */
737
- _ensureNode(elementOrNode) {
738
- if (this.isNode(elementOrNode))
739
- return elementOrNode;
740
- return this._createNode(elementOrNode);
741
- }
742
- /**
743
- * (Protected) Normalize input into a node predicate.
744
- * @remarks Time O(1), Space O(1)
745
- * @param elementNodeOrPredicate - Element, node, or predicate.
746
- * @returns A predicate taking a node and returning true/false.
747
- */
748
- _ensurePredicate(elementNodeOrPredicate) {
749
- if (this.isNode(elementNodeOrPredicate))
750
- return (node) => node === elementNodeOrPredicate;
751
- if (this._isPredicate(elementNodeOrPredicate))
752
- return elementNodeOrPredicate;
753
- const value = elementNodeOrPredicate;
754
- return (node) => this._equals(node.value, value);
755
- }
756
- /**
757
- * (Protected) Get the previous node of a given node.
758
- * @remarks Time O(N), Space O(1)
759
- * @param node - A node in the list.
760
- * @returns Previous node or undefined.
761
- */
762
- _getPrevNode(node) {
763
- if (!this.head || this.head === node)
764
- return undefined;
765
- let current = this.head;
766
- while (current.next && current.next !== node)
767
- current = current.next;
768
- return current.next === node ? current : undefined;
769
- }
770
- /**
771
- * (Protected) Iterate values from head to tail.
772
- * @remarks Time O(N), Space O(1)
773
- * @returns Iterator of values (E).
774
- */
775
- *_getIterator() {
776
- let current = this.head;
777
- while (current) {
778
- yield current.value;
779
- current = current.next;
780
- }
781
- }
782
- /**
783
- * (Protected) Iterate values from tail to head.
784
- * @remarks Time O(N), Space O(N)
785
- * @returns Iterator of values (E).
786
- */
787
- *_getReverseIterator() {
788
- const reversedArr = [...this].reverse();
789
- for (const item of reversedArr)
790
- yield item;
791
- }
792
- /**
793
- * (Protected) Iterate nodes from head to tail.
794
- * @remarks Time O(N), Space O(1)
795
- * @returns Iterator of nodes.
796
- */
797
- *_getNodeIterator() {
798
- let current = this.head;
799
- while (current) {
800
- yield current;
801
- current = current.next;
802
- }
803
- }
804
- /**
805
- * (Protected) Create an empty instance of the same concrete class.
806
- * @remarks Time O(1), Space O(1)
807
- * @param [options] - Options forwarded to the constructor.
808
- * @returns An empty like-kind list instance.
809
- */
810
- _createInstance(options) {
811
- const Ctor = this.constructor;
812
- return new Ctor([], options);
813
- }
814
- /**
815
- * (Protected) Create a like-kind instance and seed it from an iterable.
816
- * @remarks Time O(N), Space O(N)
817
- * @template EM
818
- * @template RM
819
- * @param [elements] - Iterable used to seed the new list.
820
- * @param [options] - Options forwarded to the constructor.
821
- * @returns A like-kind SinglyLinkedList instance.
822
- */
823
- _createLike(elements = [], options) {
824
- const Ctor = this.constructor;
825
- return new Ctor(elements, options);
826
- }
827
- /**
828
- * (Protected) Spawn an empty like-kind list instance.
829
- * @remarks Time O(1), Space O(1)
830
- * @template EM
831
- * @template RM
832
- * @param [options] - Options forwarded to the constructor.
833
- * @returns An empty like-kind SinglyLinkedList instance.
834
- */
835
- _spawnLike(options) {
836
- return this._createLike([], options);
837
- }
838
- }
839
- function elementOrPredicate(input, equals) {
840
- if (input instanceof SinglyLinkedListNode)
841
- return (node) => node === input;
842
- if (typeof input === 'function')
843
- return input;
844
- const value = input;
845
- return (node) => equals(node.value, value);
846
- }
847
- //# sourceMappingURL=singly-linked-list.js.map