data-structure-typed 2.1.0 → 2.1.1

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 (704) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/COMMANDS.md +13 -3
  3. package/README.md +5 -34
  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/index.cjs +13091 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.js +13013 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/{cjs → types}/data-structures/binary-tree/avl-tree-counter.d.ts +4 -4
  15. package/dist/{esm → types}/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
  16. package/dist/{esm → types}/data-structures/binary-tree/avl-tree.d.ts +4 -4
  17. package/dist/{esm → types}/data-structures/binary-tree/binary-tree.d.ts +5 -5
  18. package/dist/{esm → types}/data-structures/binary-tree/bst.d.ts +5 -5
  19. package/dist/{esm → types}/data-structures/binary-tree/red-black-tree.d.ts +5 -5
  20. package/dist/{cjs → types}/data-structures/binary-tree/tree-counter.d.ts +4 -4
  21. package/dist/{cjs → types}/data-structures/binary-tree/tree-multi-map.d.ts +5 -5
  22. package/dist/{esm → types}/interfaces/binary-tree.d.ts +2 -2
  23. package/dist/umd/data-structure-typed.js +12 -11
  24. package/dist/umd/data-structure-typed.js.map +1 -0
  25. package/dist/umd/data-structure-typed.min.js +2 -2
  26. package/dist/umd/data-structure-typed.min.js.map +1 -1
  27. package/jest.integration.config.js +3 -0
  28. package/package.json +13 -11
  29. package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -7
  30. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +5 -10
  31. package/src/data-structures/binary-tree/avl-tree.ts +4 -6
  32. package/src/data-structures/binary-tree/binary-tree.ts +14 -16
  33. package/src/data-structures/binary-tree/bst.ts +5 -10
  34. package/src/data-structures/binary-tree/red-black-tree.ts +5 -10
  35. package/src/data-structures/binary-tree/tree-counter.ts +4 -9
  36. package/src/data-structures/binary-tree/tree-multi-map.ts +5 -10
  37. package/src/interfaces/binary-tree.ts +2 -2
  38. package/test/integration/all-in-one.test.ts +1 -1
  39. package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
  40. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +109 -1
  41. package/tsconfig-base.json +20 -20
  42. package/tsconfig-types.json +17 -0
  43. package/tsconfig.test.json +8 -0
  44. package/tsup.config.js +11 -22
  45. package/tsup.node.config.ts +37 -0
  46. package/dist/cjs/common/index.js +0 -29
  47. package/dist/cjs/common/index.js.map +0 -1
  48. package/dist/cjs/data-structures/base/index.js +0 -19
  49. package/dist/cjs/data-structures/base/index.js.map +0 -1
  50. package/dist/cjs/data-structures/base/iterable-element-base.js +0 -244
  51. package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
  52. package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -184
  53. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
  54. package/dist/cjs/data-structures/base/linear-base.js +0 -416
  55. package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
  56. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -375
  57. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  58. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  59. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -251
  60. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  61. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -291
  62. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -612
  63. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  64. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
  65. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  66. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -754
  67. package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -1926
  68. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  69. package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -413
  70. package/dist/cjs/data-structures/binary-tree/bst.js +0 -904
  71. package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
  72. package/dist/cjs/data-structures/binary-tree/index.js +0 -27
  73. package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
  74. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  75. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -547
  76. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  77. package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
  78. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
  79. package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -414
  80. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
  81. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -385
  82. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  83. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -897
  84. package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
  85. package/dist/cjs/data-structures/graph/directed-graph.js +0 -526
  86. package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
  87. package/dist/cjs/data-structures/graph/index.js +0 -21
  88. package/dist/cjs/data-structures/graph/index.js.map +0 -1
  89. package/dist/cjs/data-structures/graph/map-graph.js +0 -108
  90. package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
  91. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -425
  92. package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
  93. package/dist/cjs/data-structures/hash/hash-map.js +0 -693
  94. package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
  95. package/dist/cjs/data-structures/hash/index.js +0 -18
  96. package/dist/cjs/data-structures/hash/index.js.map +0 -1
  97. package/dist/cjs/data-structures/heap/heap.js +0 -902
  98. package/dist/cjs/data-structures/heap/heap.js.map +0 -1
  99. package/dist/cjs/data-structures/heap/index.js +0 -20
  100. package/dist/cjs/data-structures/heap/index.js.map +0 -1
  101. package/dist/cjs/data-structures/heap/max-heap.js +0 -41
  102. package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
  103. package/dist/cjs/data-structures/heap/min-heap.js +0 -32
  104. package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
  105. package/dist/cjs/data-structures/index.js +0 -29
  106. package/dist/cjs/data-structures/index.js.map +0 -1
  107. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1112
  108. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  109. package/dist/cjs/data-structures/linked-list/index.js +0 -20
  110. package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
  111. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -851
  112. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  113. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -145
  114. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  115. package/dist/cjs/data-structures/matrix/index.js +0 -19
  116. package/dist/cjs/data-structures/matrix/index.js.map +0 -1
  117. package/dist/cjs/data-structures/matrix/matrix.js +0 -449
  118. package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
  119. package/dist/cjs/data-structures/matrix/navigator.js +0 -112
  120. package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
  121. package/dist/cjs/data-structures/priority-queue/index.js +0 -20
  122. package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
  123. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -35
  124. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  125. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -25
  126. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  127. package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -21
  128. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
  129. package/dist/cjs/data-structures/queue/deque.js +0 -880
  130. package/dist/cjs/data-structures/queue/deque.js.map +0 -1
  131. package/dist/cjs/data-structures/queue/index.js +0 -19
  132. package/dist/cjs/data-structures/queue/index.js.map +0 -1
  133. package/dist/cjs/data-structures/queue/queue.js +0 -474
  134. package/dist/cjs/data-structures/queue/queue.js.map +0 -1
  135. package/dist/cjs/data-structures/stack/index.js +0 -18
  136. package/dist/cjs/data-structures/stack/index.js.map +0 -1
  137. package/dist/cjs/data-structures/stack/stack.js +0 -402
  138. package/dist/cjs/data-structures/stack/stack.js.map +0 -1
  139. package/dist/cjs/data-structures/tree/index.js +0 -18
  140. package/dist/cjs/data-structures/tree/index.js.map +0 -1
  141. package/dist/cjs/data-structures/tree/tree.js +0 -108
  142. package/dist/cjs/data-structures/tree/tree.js.map +0 -1
  143. package/dist/cjs/data-structures/trie/index.js +0 -18
  144. package/dist/cjs/data-structures/trie/index.js.map +0 -1
  145. package/dist/cjs/data-structures/trie/trie.js +0 -611
  146. package/dist/cjs/data-structures/trie/trie.js.map +0 -1
  147. package/dist/cjs/index.js +0 -22
  148. package/dist/cjs/index.js.map +0 -1
  149. package/dist/cjs/interfaces/binary-tree.d.ts +0 -59
  150. package/dist/cjs/interfaces/binary-tree.js +0 -3
  151. package/dist/cjs/interfaces/binary-tree.js.map +0 -1
  152. package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
  153. package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
  154. package/dist/cjs/interfaces/graph.js +0 -3
  155. package/dist/cjs/interfaces/graph.js.map +0 -1
  156. package/dist/cjs/interfaces/heap.js +0 -3
  157. package/dist/cjs/interfaces/heap.js.map +0 -1
  158. package/dist/cjs/interfaces/index.js +0 -25
  159. package/dist/cjs/interfaces/index.js.map +0 -1
  160. package/dist/cjs/interfaces/navigator.js +0 -3
  161. package/dist/cjs/interfaces/navigator.js.map +0 -1
  162. package/dist/cjs/interfaces/priority-queue.js +0 -3
  163. package/dist/cjs/interfaces/priority-queue.js.map +0 -1
  164. package/dist/cjs/interfaces/segment-tree.js +0 -3
  165. package/dist/cjs/interfaces/segment-tree.js.map +0 -1
  166. package/dist/cjs/interfaces/singly-linked-list.js +0 -3
  167. package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
  168. package/dist/cjs/types/common.js +0 -3
  169. package/dist/cjs/types/common.js.map +0 -1
  170. package/dist/cjs/types/data-structures/base/base.js +0 -3
  171. package/dist/cjs/types/data-structures/base/base.js.map +0 -1
  172. package/dist/cjs/types/data-structures/base/index.js +0 -18
  173. package/dist/cjs/types/data-structures/base/index.js.map +0 -1
  174. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
  175. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  176. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
  177. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  178. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
  179. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  180. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +0 -3
  181. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  182. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -3
  183. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  184. package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
  185. package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
  186. package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
  187. package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
  188. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
  189. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  190. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
  191. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  192. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
  193. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  194. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
  195. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  196. package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
  197. package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
  198. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
  199. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
  200. package/dist/cjs/types/data-structures/graph/index.js +0 -20
  201. package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
  202. package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
  203. package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
  204. package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
  205. package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
  206. package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
  207. package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
  208. package/dist/cjs/types/data-structures/hash/index.js +0 -18
  209. package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
  210. package/dist/cjs/types/data-structures/heap/heap.js +0 -3
  211. package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
  212. package/dist/cjs/types/data-structures/heap/index.js +0 -18
  213. package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
  214. package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
  215. package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
  216. package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
  217. package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
  218. package/dist/cjs/types/data-structures/index.js +0 -29
  219. package/dist/cjs/types/data-structures/index.js.map +0 -1
  220. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
  221. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  222. package/dist/cjs/types/data-structures/linked-list/index.js +0 -20
  223. package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
  224. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js +0 -3
  225. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  226. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +0 -3
  227. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  228. package/dist/cjs/types/data-structures/matrix/index.js +0 -19
  229. package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
  230. package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
  231. package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
  232. package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
  233. package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
  234. package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
  235. package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
  236. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +0 -3
  237. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  238. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +0 -3
  239. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  240. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js +0 -3
  241. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  242. package/dist/cjs/types/data-structures/queue/deque.js +0 -3
  243. package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
  244. package/dist/cjs/types/data-structures/queue/index.js +0 -19
  245. package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
  246. package/dist/cjs/types/data-structures/queue/queue.js +0 -3
  247. package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
  248. package/dist/cjs/types/data-structures/stack/index.js +0 -18
  249. package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
  250. package/dist/cjs/types/data-structures/stack/stack.js +0 -3
  251. package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
  252. package/dist/cjs/types/data-structures/tree/index.js +0 -18
  253. package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
  254. package/dist/cjs/types/data-structures/tree/tree.js +0 -3
  255. package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
  256. package/dist/cjs/types/data-structures/trie/index.js +0 -18
  257. package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
  258. package/dist/cjs/types/data-structures/trie/trie.js +0 -3
  259. package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
  260. package/dist/cjs/types/index.js +0 -20
  261. package/dist/cjs/types/index.js.map +0 -1
  262. package/dist/cjs/types/utils/index.js +0 -19
  263. package/dist/cjs/types/utils/index.js.map +0 -1
  264. package/dist/cjs/types/utils/utils.js +0 -3
  265. package/dist/cjs/types/utils/utils.js.map +0 -1
  266. package/dist/cjs/types/utils/validate-type.js +0 -3
  267. package/dist/cjs/types/utils/validate-type.js.map +0 -1
  268. package/dist/cjs/utils/index.js +0 -19
  269. package/dist/cjs/utils/index.js.map +0 -1
  270. package/dist/cjs/utils/number.js +0 -24
  271. package/dist/cjs/utils/number.js.map +0 -1
  272. package/dist/cjs/utils/utils.js +0 -354
  273. package/dist/cjs/utils/utils.js.map +0 -1
  274. package/dist/esm/common/index.d.ts +0 -12
  275. package/dist/esm/common/index.js +0 -29
  276. package/dist/esm/common/index.js.map +0 -1
  277. package/dist/esm/data-structures/base/index.d.ts +0 -2
  278. package/dist/esm/data-structures/base/index.js +0 -3
  279. package/dist/esm/data-structures/base/index.js.map +0 -1
  280. package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -219
  281. package/dist/esm/data-structures/base/iterable-element-base.js +0 -247
  282. package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
  283. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -144
  284. package/dist/esm/data-structures/base/iterable-entry-base.js +0 -180
  285. package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
  286. package/dist/esm/data-structures/base/linear-base.d.ts +0 -335
  287. package/dist/esm/data-structures/base/linear-base.js +0 -412
  288. package/dist/esm/data-structures/base/linear-base.js.map +0 -1
  289. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  290. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -369
  291. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  292. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -244
  293. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  294. package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -607
  295. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
  296. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  297. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
  298. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  299. package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -1922
  300. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
  301. package/dist/esm/data-structures/binary-tree/bst.js +0 -901
  302. package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
  303. package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
  304. package/dist/esm/data-structures/binary-tree/index.js +0 -11
  305. package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
  306. package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -540
  307. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
  308. package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
  309. package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
  310. package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
  311. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -190
  312. package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -412
  313. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
  314. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  315. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -378
  316. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  317. package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -340
  318. package/dist/esm/data-structures/graph/abstract-graph.js +0 -892
  319. package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
  320. package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -207
  321. package/dist/esm/data-structures/graph/directed-graph.js +0 -521
  322. package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
  323. package/dist/esm/data-structures/graph/index.d.ts +0 -4
  324. package/dist/esm/data-structures/graph/index.js +0 -5
  325. package/dist/esm/data-structures/graph/index.js.map +0 -1
  326. package/dist/esm/data-structures/graph/map-graph.d.ts +0 -78
  327. package/dist/esm/data-structures/graph/map-graph.js +0 -105
  328. package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
  329. package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -188
  330. package/dist/esm/data-structures/graph/undirected-graph.js +0 -418
  331. package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
  332. package/dist/esm/data-structures/hash/hash-map.d.ts +0 -345
  333. package/dist/esm/data-structures/hash/hash-map.js +0 -691
  334. package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
  335. package/dist/esm/data-structures/hash/index.d.ts +0 -1
  336. package/dist/esm/data-structures/hash/index.js +0 -2
  337. package/dist/esm/data-structures/hash/index.js.map +0 -1
  338. package/dist/esm/data-structures/heap/heap.d.ts +0 -503
  339. package/dist/esm/data-structures/heap/heap.js +0 -894
  340. package/dist/esm/data-structures/heap/heap.js.map +0 -1
  341. package/dist/esm/data-structures/heap/index.d.ts +0 -3
  342. package/dist/esm/data-structures/heap/index.js +0 -4
  343. package/dist/esm/data-structures/heap/index.js.map +0 -1
  344. package/dist/esm/data-structures/heap/max-heap.d.ts +0 -32
  345. package/dist/esm/data-structures/heap/max-heap.js +0 -40
  346. package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
  347. package/dist/esm/data-structures/heap/min-heap.d.ts +0 -33
  348. package/dist/esm/data-structures/heap/min-heap.js +0 -28
  349. package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
  350. package/dist/esm/data-structures/index.d.ts +0 -12
  351. package/dist/esm/data-structures/index.js +0 -13
  352. package/dist/esm/data-structures/index.js.map +0 -1
  353. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  354. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1109
  355. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  356. package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
  357. package/dist/esm/data-structures/linked-list/index.js +0 -4
  358. package/dist/esm/data-structures/linked-list/index.js.map +0 -1
  359. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  360. package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -847
  361. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
  362. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  363. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -143
  364. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
  365. package/dist/esm/data-structures/matrix/index.d.ts +0 -2
  366. package/dist/esm/data-structures/matrix/index.js +0 -3
  367. package/dist/esm/data-structures/matrix/index.js.map +0 -1
  368. package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
  369. package/dist/esm/data-structures/matrix/matrix.js +0 -444
  370. package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
  371. package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
  372. package/dist/esm/data-structures/matrix/navigator.js +0 -114
  373. package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
  374. package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
  375. package/dist/esm/data-structures/priority-queue/index.js +0 -4
  376. package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
  377. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  378. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -34
  379. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  380. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  381. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -21
  382. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  383. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -15
  384. package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -17
  385. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
  386. package/dist/esm/data-structures/queue/deque.d.ts +0 -431
  387. package/dist/esm/data-structures/queue/deque.js +0 -880
  388. package/dist/esm/data-structures/queue/deque.js.map +0 -1
  389. package/dist/esm/data-structures/queue/index.d.ts +0 -2
  390. package/dist/esm/data-structures/queue/index.js +0 -3
  391. package/dist/esm/data-structures/queue/index.js.map +0 -1
  392. package/dist/esm/data-structures/queue/queue.d.ts +0 -308
  393. package/dist/esm/data-structures/queue/queue.js +0 -467
  394. package/dist/esm/data-structures/queue/queue.js.map +0 -1
  395. package/dist/esm/data-structures/stack/index.d.ts +0 -1
  396. package/dist/esm/data-structures/stack/index.js +0 -2
  397. package/dist/esm/data-structures/stack/index.js.map +0 -1
  398. package/dist/esm/data-structures/stack/stack.d.ts +0 -306
  399. package/dist/esm/data-structures/stack/stack.js +0 -398
  400. package/dist/esm/data-structures/stack/stack.js.map +0 -1
  401. package/dist/esm/data-structures/tree/index.d.ts +0 -1
  402. package/dist/esm/data-structures/tree/index.js +0 -2
  403. package/dist/esm/data-structures/tree/index.js.map +0 -1
  404. package/dist/esm/data-structures/tree/tree.d.ts +0 -62
  405. package/dist/esm/data-structures/tree/tree.js +0 -107
  406. package/dist/esm/data-structures/tree/tree.js.map +0 -1
  407. package/dist/esm/data-structures/trie/index.d.ts +0 -1
  408. package/dist/esm/data-structures/trie/index.js +0 -2
  409. package/dist/esm/data-structures/trie/index.js.map +0 -1
  410. package/dist/esm/data-structures/trie/trie.d.ts +0 -350
  411. package/dist/esm/data-structures/trie/trie.js +0 -613
  412. package/dist/esm/data-structures/trie/trie.js.map +0 -1
  413. package/dist/esm/index.d.ts +0 -5
  414. package/dist/esm/index.js +0 -6
  415. package/dist/esm/index.js.map +0 -1
  416. package/dist/esm/interfaces/binary-tree.js +0 -2
  417. package/dist/esm/interfaces/binary-tree.js.map +0 -1
  418. package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
  419. package/dist/esm/interfaces/doubly-linked-list.js +0 -2
  420. package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
  421. package/dist/esm/interfaces/graph.d.ts +0 -21
  422. package/dist/esm/interfaces/graph.js +0 -2
  423. package/dist/esm/interfaces/graph.js.map +0 -1
  424. package/dist/esm/interfaces/heap.d.ts +0 -1
  425. package/dist/esm/interfaces/heap.js +0 -2
  426. package/dist/esm/interfaces/heap.js.map +0 -1
  427. package/dist/esm/interfaces/index.d.ts +0 -8
  428. package/dist/esm/interfaces/index.js +0 -9
  429. package/dist/esm/interfaces/index.js.map +0 -1
  430. package/dist/esm/interfaces/navigator.d.ts +0 -1
  431. package/dist/esm/interfaces/navigator.js +0 -2
  432. package/dist/esm/interfaces/navigator.js.map +0 -1
  433. package/dist/esm/interfaces/priority-queue.d.ts +0 -1
  434. package/dist/esm/interfaces/priority-queue.js +0 -2
  435. package/dist/esm/interfaces/priority-queue.js.map +0 -1
  436. package/dist/esm/interfaces/segment-tree.d.ts +0 -1
  437. package/dist/esm/interfaces/segment-tree.js +0 -2
  438. package/dist/esm/interfaces/segment-tree.js.map +0 -1
  439. package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
  440. package/dist/esm/interfaces/singly-linked-list.js +0 -2
  441. package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
  442. package/dist/esm/types/common.d.ts +0 -15
  443. package/dist/esm/types/common.js +0 -2
  444. package/dist/esm/types/common.js.map +0 -1
  445. package/dist/esm/types/data-structures/base/base.d.ts +0 -13
  446. package/dist/esm/types/data-structures/base/base.js +0 -2
  447. package/dist/esm/types/data-structures/base/base.js.map +0 -1
  448. package/dist/esm/types/data-structures/base/index.d.ts +0 -1
  449. package/dist/esm/types/data-structures/base/index.js +0 -2
  450. package/dist/esm/types/data-structures/base/index.js.map +0 -1
  451. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  452. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  453. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  454. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  455. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  456. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  457. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  458. package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
  459. package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  460. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
  461. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  462. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  463. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
  464. package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
  465. package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  466. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
  467. package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
  468. package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
  469. package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
  470. package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
  471. package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
  472. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
  473. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
  474. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  475. package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
  476. package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
  477. package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  478. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  479. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
  480. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  481. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
  482. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  483. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  484. package/dist/esm/types/data-structures/graph/abstract-graph.d.ts +0 -14
  485. package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
  486. package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
  487. package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
  488. package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
  489. package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
  490. package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
  491. package/dist/esm/types/data-structures/graph/index.js +0 -4
  492. package/dist/esm/types/data-structures/graph/index.js.map +0 -1
  493. package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
  494. package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
  495. package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
  496. package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
  497. package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
  498. package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
  499. package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
  500. package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
  501. package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
  502. package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
  503. package/dist/esm/types/data-structures/hash/index.js +0 -2
  504. package/dist/esm/types/data-structures/hash/index.js.map +0 -1
  505. package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
  506. package/dist/esm/types/data-structures/heap/heap.js +0 -2
  507. package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
  508. package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
  509. package/dist/esm/types/data-structures/heap/index.js +0 -2
  510. package/dist/esm/types/data-structures/heap/index.js.map +0 -1
  511. package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
  512. package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
  513. package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
  514. package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
  515. package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
  516. package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
  517. package/dist/esm/types/data-structures/index.d.ts +0 -12
  518. package/dist/esm/types/data-structures/index.js +0 -13
  519. package/dist/esm/types/data-structures/index.js.map +0 -1
  520. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
  521. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  522. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  523. package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
  524. package/dist/esm/types/data-structures/linked-list/index.js +0 -4
  525. package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
  526. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
  527. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
  528. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  529. package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
  530. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
  531. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  532. package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
  533. package/dist/esm/types/data-structures/matrix/index.js +0 -3
  534. package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
  535. package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
  536. package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
  537. package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
  538. package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
  539. package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
  540. package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
  541. package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
  542. package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
  543. package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
  544. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
  545. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  546. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  547. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
  548. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  549. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  550. package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
  551. package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
  552. package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  553. package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
  554. package/dist/esm/types/data-structures/queue/deque.js +0 -2
  555. package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
  556. package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
  557. package/dist/esm/types/data-structures/queue/index.js +0 -3
  558. package/dist/esm/types/data-structures/queue/index.js.map +0 -1
  559. package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
  560. package/dist/esm/types/data-structures/queue/queue.js +0 -2
  561. package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
  562. package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
  563. package/dist/esm/types/data-structures/stack/index.js +0 -2
  564. package/dist/esm/types/data-structures/stack/index.js.map +0 -1
  565. package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
  566. package/dist/esm/types/data-structures/stack/stack.js +0 -2
  567. package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
  568. package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
  569. package/dist/esm/types/data-structures/tree/index.js +0 -2
  570. package/dist/esm/types/data-structures/tree/index.js.map +0 -1
  571. package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
  572. package/dist/esm/types/data-structures/tree/tree.js +0 -2
  573. package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
  574. package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
  575. package/dist/esm/types/data-structures/trie/index.js +0 -2
  576. package/dist/esm/types/data-structures/trie/index.js.map +0 -1
  577. package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
  578. package/dist/esm/types/data-structures/trie/trie.js +0 -2
  579. package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
  580. package/dist/esm/types/index.d.ts +0 -3
  581. package/dist/esm/types/index.js +0 -4
  582. package/dist/esm/types/index.js.map +0 -1
  583. package/dist/esm/types/utils/index.d.ts +0 -2
  584. package/dist/esm/types/utils/index.js +0 -3
  585. package/dist/esm/types/utils/index.js.map +0 -1
  586. package/dist/esm/types/utils/utils.d.ts +0 -22
  587. package/dist/esm/types/utils/utils.js +0 -2
  588. package/dist/esm/types/utils/utils.js.map +0 -1
  589. package/dist/esm/types/utils/validate-type.d.ts +0 -19
  590. package/dist/esm/types/utils/validate-type.js +0 -2
  591. package/dist/esm/types/utils/validate-type.js.map +0 -1
  592. package/dist/esm/utils/index.d.ts +0 -2
  593. package/dist/esm/utils/index.js +0 -3
  594. package/dist/esm/utils/index.js.map +0 -1
  595. package/dist/esm/utils/number.d.ts +0 -14
  596. package/dist/esm/utils/number.js +0 -21
  597. package/dist/esm/utils/number.js.map +0 -1
  598. package/dist/esm/utils/utils.d.ts +0 -209
  599. package/dist/esm/utils/utils.js +0 -325
  600. package/dist/esm/utils/utils.js.map +0 -1
  601. package/tsconfig-cjs.json +0 -14
  602. package/tsconfig-esm.json +0 -14
  603. /package/dist/{cjs → types}/common/index.d.ts +0 -0
  604. /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
  605. /package/dist/{cjs → types}/data-structures/base/iterable-element-base.d.ts +0 -0
  606. /package/dist/{cjs → types}/data-structures/base/iterable-entry-base.d.ts +0 -0
  607. /package/dist/{cjs → types}/data-structures/base/linear-base.d.ts +0 -0
  608. /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  609. /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
  610. /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  611. /package/dist/{cjs → types}/data-structures/graph/abstract-graph.d.ts +0 -0
  612. /package/dist/{cjs → types}/data-structures/graph/directed-graph.d.ts +0 -0
  613. /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
  614. /package/dist/{cjs → types}/data-structures/graph/map-graph.d.ts +0 -0
  615. /package/dist/{cjs → types}/data-structures/graph/undirected-graph.d.ts +0 -0
  616. /package/dist/{cjs → types}/data-structures/hash/hash-map.d.ts +0 -0
  617. /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
  618. /package/dist/{cjs → types}/data-structures/heap/heap.d.ts +0 -0
  619. /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
  620. /package/dist/{cjs → types}/data-structures/heap/max-heap.d.ts +0 -0
  621. /package/dist/{cjs → types}/data-structures/heap/min-heap.d.ts +0 -0
  622. /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
  623. /package/dist/{cjs → types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  624. /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
  625. /package/dist/{cjs → types}/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  626. /package/dist/{cjs → types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  627. /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
  628. /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
  629. /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
  630. /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
  631. /package/dist/{cjs → types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  632. /package/dist/{cjs → types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  633. /package/dist/{cjs → types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  634. /package/dist/{cjs → types}/data-structures/queue/deque.d.ts +0 -0
  635. /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
  636. /package/dist/{cjs → types}/data-structures/queue/queue.d.ts +0 -0
  637. /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
  638. /package/dist/{cjs → types}/data-structures/stack/stack.d.ts +0 -0
  639. /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
  640. /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
  641. /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
  642. /package/dist/{cjs → types}/data-structures/trie/trie.d.ts +0 -0
  643. /package/dist/{cjs → types}/index.d.ts +0 -0
  644. /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
  645. /package/dist/{cjs → types}/interfaces/graph.d.ts +0 -0
  646. /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
  647. /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
  648. /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
  649. /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
  650. /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
  651. /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
  652. /package/dist/{cjs → types}/types/common.d.ts +0 -0
  653. /package/dist/{cjs → types}/types/data-structures/base/base.d.ts +0 -0
  654. /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
  655. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
  656. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
  657. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
  658. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  659. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
  660. /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
  661. /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
  662. /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
  663. /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  664. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
  665. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
  666. /package/dist/{cjs → types}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  667. /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
  668. /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
  669. /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
  670. /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  671. /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
  672. /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
  673. /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
  674. /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
  675. /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
  676. /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
  677. /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
  678. /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  679. /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
  680. /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  681. /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  682. /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
  683. /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
  684. /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
  685. /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
  686. /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  687. /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  688. /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  689. /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
  690. /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
  691. /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
  692. /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
  693. /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
  694. /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
  695. /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
  696. /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
  697. /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
  698. /package/dist/{cjs → types}/types/index.d.ts +0 -0
  699. /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
  700. /package/dist/{cjs → types}/types/utils/utils.d.ts +0 -0
  701. /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
  702. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  703. /package/dist/{cjs → types}/utils/number.d.ts +0 -0
  704. /package/dist/{cjs → types}/utils/utils.d.ts +0 -0
@@ -1,1109 +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 doubly linked list; stores value and prev/next links.
11
- * @remarks Time O(1), Space O(1)
12
- * @template E
13
- */
14
- export class DoublyLinkedListNode extends LinkedListNode {
15
- /**
16
- * Create a 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
- this._prev = undefined;
26
- }
27
- _next;
28
- /**
29
- * Get the next node link.
30
- * @remarks Time O(1), Space O(1)
31
- * @returns Next node or undefined.
32
- */
33
- get next() {
34
- return this._next;
35
- }
36
- /**
37
- * Set the next node link.
38
- * @remarks Time O(1), Space O(1)
39
- * @param value - Next node or undefined.
40
- * @returns void
41
- */
42
- set next(value) {
43
- this._next = value;
44
- }
45
- _prev;
46
- /**
47
- * Get the previous node link.
48
- * @remarks Time O(1), Space O(1)
49
- * @returns Previous node or undefined.
50
- */
51
- get prev() {
52
- return this._prev;
53
- }
54
- /**
55
- * Set the previous node link.
56
- * @remarks Time O(1), Space O(1)
57
- * @param value - Previous node or undefined.
58
- * @returns void
59
- */
60
- set prev(value) {
61
- this._prev = value;
62
- }
63
- }
64
- /**
65
- * Doubly linked list with O(1) push/pop/unshift/shift and linear scans.
66
- * @remarks Time O(1), Space O(1)
67
- * @template E
68
- * @template R
69
- * 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.
70
- * 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
71
- * 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.
72
- * 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.
73
- * 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).
74
- * @example
75
- * // text editor operation history
76
- * const actions = [
77
- * { type: 'insert', content: 'first line of text' },
78
- * { type: 'insert', content: 'second line of text' },
79
- * { type: 'delete', content: 'delete the first line' }
80
- * ];
81
- * const editorHistory = new DoublyLinkedList<{ type: string; content: string }>(actions);
82
- *
83
- * console.log(editorHistory.last?.type); // 'delete'
84
- * console.log(editorHistory.pop()?.content); // 'delete the first line'
85
- * console.log(editorHistory.last?.type); // 'insert'
86
- * @example
87
- * // Browser history
88
- * const browserHistory = new DoublyLinkedList<string>();
89
- *
90
- * browserHistory.push('home page');
91
- * browserHistory.push('search page');
92
- * browserHistory.push('details page');
93
- *
94
- * console.log(browserHistory.last); // 'details page'
95
- * console.log(browserHistory.pop()); // 'details page'
96
- * console.log(browserHistory.last); // 'search page'
97
- * @example
98
- * // Use DoublyLinkedList to implement music player
99
- * // Define the Song interface
100
- * interface Song {
101
- * title: string;
102
- * artist: string;
103
- * duration: number; // duration in seconds
104
- * }
105
- *
106
- * class Player {
107
- * private playlist: DoublyLinkedList<Song>;
108
- * private currentSong: ReturnType<typeof this.playlist.getNodeAt> | undefined;
109
- *
110
- * constructor(songs: Song[]) {
111
- * this.playlist = new DoublyLinkedList<Song>();
112
- * songs.forEach(song => this.playlist.push(song));
113
- * this.currentSong = this.playlist.head;
114
- * }
115
- *
116
- * // Play the next song in the playlist
117
- * playNext(): Song | undefined {
118
- * if (!this.currentSong?.next) {
119
- * this.currentSong = this.playlist.head; // Loop to the first song
120
- * } else {
121
- * this.currentSong = this.currentSong.next;
122
- * }
123
- * return this.currentSong?.value;
124
- * }
125
- *
126
- * // Play the previous song in the playlist
127
- * playPrevious(): Song | undefined {
128
- * if (!this.currentSong?.prev) {
129
- * this.currentSong = this.playlist.tail; // Loop to the last song
130
- * } else {
131
- * this.currentSong = this.currentSong.prev;
132
- * }
133
- * return this.currentSong?.value;
134
- * }
135
- *
136
- * // Get the current song
137
- * getCurrentSong(): Song | undefined {
138
- * return this.currentSong?.value;
139
- * }
140
- *
141
- * // Loop through the playlist twice
142
- * loopThroughPlaylist(): Song[] {
143
- * const playedSongs: Song[] = [];
144
- * const initialNode = this.currentSong;
145
- *
146
- * // Loop through the playlist twice
147
- * for (let i = 0; i < this.playlist.length * 2; i++) {
148
- * playedSongs.push(this.currentSong!.value);
149
- * this.currentSong = this.currentSong!.next || this.playlist.head; // Loop back to the start if needed
150
- * }
151
- *
152
- * // Reset the current song to the initial song
153
- * this.currentSong = initialNode;
154
- * return playedSongs;
155
- * }
156
- * }
157
- *
158
- * const songs = [
159
- * { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
160
- * { title: 'Hotel California', artist: 'Eagles', duration: 391 },
161
- * { title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
162
- * { title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 }
163
- * ];
164
- * let player = new Player(songs);
165
- * // should play the next song
166
- * player = new Player(songs);
167
- * const firstSong = player.getCurrentSong();
168
- * const nextSong = player.playNext();
169
- *
170
- * // Expect the next song to be "Hotel California by Eagles"
171
- * console.log(nextSong); // { title: 'Hotel California', artist: 'Eagles', duration: 391 }
172
- * console.log(firstSong); // { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 }
173
- *
174
- * // should play the previous song
175
- * player = new Player(songs);
176
- * player.playNext(); // Move to the second song
177
- * const currentSong = player.getCurrentSong();
178
- * const previousSong = player.playPrevious();
179
- *
180
- * // Expect the previous song to be "Bohemian Rhapsody by Queen"
181
- * console.log(previousSong); // { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 }
182
- * console.log(currentSong); // { title: 'Hotel California', artist: 'Eagles', duration: 391 }
183
- *
184
- * // should loop to the first song when playing next from the last song
185
- * player = new Player(songs);
186
- * player.playNext(); // Move to the second song
187
- * player.playNext(); // Move to the third song
188
- * player.playNext(); // Move to the fourth song
189
- *
190
- * const nextSongToFirst = player.playNext(); // Should loop to the first song
191
- *
192
- * // Expect the next song to be "Bohemian Rhapsody by Queen"
193
- * console.log(nextSongToFirst); // { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 }
194
- *
195
- * // should loop to the last song when playing previous from the first song
196
- * player = new Player(songs);
197
- * player.playNext(); // Move to the first song
198
- * player.playNext(); // Move to the second song
199
- * player.playNext(); // Move to the third song
200
- * player.playNext(); // Move to the fourth song
201
- *
202
- * const previousToLast = player.playPrevious(); // Should loop to the last song
203
- *
204
- * // Expect the previous song to be "Billie Jean by Michael Jackson"
205
- * console.log(previousToLast); // { title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 }
206
- *
207
- * // should loop through the entire playlist
208
- * player = new Player(songs);
209
- * const playedSongs = player.loopThroughPlaylist();
210
- *
211
- * // The expected order of songs for two loops
212
- * console.log(playedSongs); // [
213
- * // { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
214
- * // { title: 'Hotel California', artist: 'Eagles', duration: 391 },
215
- * // { title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
216
- * // { title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 },
217
- * // { title: 'Bohemian Rhapsody', artist: 'Queen', duration: 354 },
218
- * // { title: 'Hotel California', artist: 'Eagles', duration: 391 },
219
- * // { title: 'Shape of You', artist: 'Ed Sheeran', duration: 233 },
220
- * // { title: 'Billie Jean', artist: 'Michael Jackson', duration: 294 }
221
- * // ]
222
- * @example
223
- * // Use DoublyLinkedList to implement LRU cache
224
- * interface CacheEntry<K, V> {
225
- * key: K;
226
- * value: V;
227
- * }
228
- *
229
- * class LRUCache<K = string, V = any> {
230
- * private readonly capacity: number;
231
- * private list: DoublyLinkedList<CacheEntry<K, V>>;
232
- * private map: Map<K, DoublyLinkedListNode<CacheEntry<K, V>>>;
233
- *
234
- * constructor(capacity: number) {
235
- * if (capacity <= 0) {
236
- * throw new Error('lru cache capacity must be greater than 0');
237
- * }
238
- * this.capacity = capacity;
239
- * this.list = new DoublyLinkedList<CacheEntry<K, V>>();
240
- * this.map = new Map<K, DoublyLinkedListNode<CacheEntry<K, V>>>();
241
- * }
242
- *
243
- * // Get the current cache length
244
- * get length(): number {
245
- * return this.list.length;
246
- * }
247
- *
248
- * // Check if it is empty
249
- * get isEmpty(): boolean {
250
- * return this.list.isEmpty();
251
- * }
252
- *
253
- * // Get cached value
254
- * get(key: K): V | undefined {
255
- * const node = this.map.get(key);
256
- *
257
- * if (!node) return undefined;
258
- *
259
- * // Move the visited node to the head of the linked list (most recently used)
260
- * this.moveToFront(node);
261
- *
262
- * return node.value.value;
263
- * }
264
- *
265
- * // Set cache value
266
- * set(key: K, value: V): void {
267
- * // Check if it already exists
268
- * const node = this.map.get(key);
269
- *
270
- * if (node) {
271
- * // Update value and move to head
272
- * node.value.value = value;
273
- * this.moveToFront(node);
274
- * return;
275
- * }
276
- *
277
- * // Check capacity
278
- * if (this.list.length >= this.capacity) {
279
- * // Delete the least recently used element (the tail of the linked list)
280
- * const removedNode = this.list.tail;
281
- * if (removedNode) {
282
- * this.map.delete(removedNode.value.key);
283
- * this.list.pop();
284
- * }
285
- * }
286
- *
287
- * // Create new node and add to head
288
- * const newEntry: CacheEntry<K, V> = { key, value };
289
- * this.list.unshift(newEntry);
290
- *
291
- * // Save node reference in map
292
- * const newNode = this.list.head;
293
- * if (newNode) {
294
- * this.map.set(key, newNode);
295
- * }
296
- * }
297
- *
298
- * // Delete specific key
299
- * delete(key: K): boolean {
300
- * const node = this.map.get(key);
301
- * if (!node) return false;
302
- *
303
- * // Remove from linked list
304
- * this.list.delete(node);
305
- * // Remove from map
306
- * this.map.delete(key);
307
- *
308
- * return true;
309
- * }
310
- *
311
- * // Clear cache
312
- * clear(): void {
313
- * this.list.clear();
314
- * this.map.clear();
315
- * }
316
- *
317
- * // Move the node to the head of the linked list
318
- * private moveToFront(node: DoublyLinkedListNode<CacheEntry<K, V>>): void {
319
- * this.list.delete(node);
320
- * this.list.unshift(node.value);
321
- * }
322
- * }
323
- *
324
- * // should set and get values correctly
325
- * const cache = new LRUCache<string, number>(3);
326
- * cache.set('a', 1);
327
- * cache.set('b', 2);
328
- * cache.set('c', 3);
329
- *
330
- * console.log(cache.get('a')); // 1
331
- * console.log(cache.get('b')); // 2
332
- * console.log(cache.get('c')); // 3
333
- *
334
- * // The least recently used element should be evicted when capacity is exceeded
335
- * cache.clear();
336
- * cache.set('a', 1);
337
- * cache.set('b', 2);
338
- * cache.set('c', 3);
339
- * cache.set('d', 4); // This will eliminate 'a'
340
- *
341
- * console.log(cache.get('a')); // undefined
342
- * console.log(cache.get('b')); // 2
343
- * console.log(cache.get('c')); // 3
344
- * console.log(cache.get('d')); // 4
345
- *
346
- * // The priority of an element should be updated when it is accessed
347
- * cache.clear();
348
- * cache.set('a', 1);
349
- * cache.set('b', 2);
350
- * cache.set('c', 3);
351
- *
352
- * cache.get('a'); // access 'a'
353
- * cache.set('d', 4); // This will eliminate 'b'
354
- *
355
- * console.log(cache.get('a')); // 1
356
- * console.log(cache.get('b')); // undefined
357
- * console.log(cache.get('c')); // 3
358
- * console.log(cache.get('d')); // 4
359
- *
360
- * // Should support updating existing keys
361
- * cache.clear();
362
- * cache.set('a', 1);
363
- * cache.set('a', 10);
364
- *
365
- * console.log(cache.get('a')); // 10
366
- *
367
- * // Should support deleting specified keys
368
- * cache.clear();
369
- * cache.set('a', 1);
370
- * cache.set('b', 2);
371
- *
372
- * console.log(cache.delete('a')); // true
373
- * console.log(cache.get('a')); // undefined
374
- * console.log(cache.length); // 1
375
- *
376
- * // Should support clearing cache
377
- * cache.clear();
378
- * cache.set('a', 1);
379
- * cache.set('b', 2);
380
- * cache.clear();
381
- *
382
- * console.log(cache.length); // 0
383
- * console.log(cache.isEmpty); // true
384
- * @example
385
- * // finding lyrics by timestamp in Coldplay's "Fix You"
386
- * // Create a DoublyLinkedList to store song lyrics with timestamps
387
- * const lyricsList = new DoublyLinkedList<{ time: number; text: string }>();
388
- *
389
- * // Detailed lyrics with precise timestamps (in milliseconds)
390
- * const lyrics = [
391
- * { time: 0, text: "When you try your best, but you don't succeed" },
392
- * { time: 4000, text: 'When you get what you want, but not what you need' },
393
- * { time: 8000, text: "When you feel so tired, but you can't sleep" },
394
- * { time: 12000, text: 'Stuck in reverse' },
395
- * { time: 16000, text: 'And the tears come streaming down your face' },
396
- * { time: 20000, text: "When you lose something you can't replace" },
397
- * { time: 24000, text: 'When you love someone, but it goes to waste' },
398
- * { time: 28000, text: 'Could it be worse?' },
399
- * { time: 32000, text: 'Lights will guide you home' },
400
- * { time: 36000, text: 'And ignite your bones' },
401
- * { time: 40000, text: 'And I will try to fix you' }
402
- * ];
403
- *
404
- * // Populate the DoublyLinkedList with lyrics
405
- * lyrics.forEach(lyric => lyricsList.push(lyric));
406
- *
407
- * // Test different scenarios of lyric synchronization
408
- *
409
- * // 1. Find lyric at exact timestamp
410
- * const exactTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 36000);
411
- * console.log(exactTimeLyric?.text); // 'And ignite your bones'
412
- *
413
- * // 2. Find lyric between timestamps
414
- * const betweenTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 22000);
415
- * console.log(betweenTimeLyric?.text); // "When you lose something you can't replace"
416
- *
417
- * // 3. Find first lyric when timestamp is less than first entry
418
- * const earlyTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= -1000);
419
- * console.log(earlyTimeLyric); // undefined
420
- *
421
- * // 4. Find last lyric when timestamp is after last entry
422
- * const lateTimeLyric = lyricsList.getBackward(lyric => lyric.value.time <= 50000);
423
- * console.log(lateTimeLyric?.text); // 'And I will try to fix you'
424
- * @example
425
- * // cpu process schedules
426
- * class Process {
427
- * constructor(
428
- * public id: number,
429
- * public priority: number
430
- * ) {}
431
- *
432
- * execute(): string {
433
- * return `Process ${this.id} executed.`;
434
- * }
435
- * }
436
- *
437
- * class Scheduler {
438
- * private queue: DoublyLinkedList<Process>;
439
- *
440
- * constructor() {
441
- * this.queue = new DoublyLinkedList<Process>();
442
- * }
443
- *
444
- * addProcess(process: Process): void {
445
- * // Insert processes into a queue based on priority, keeping priority in descending order
446
- * let current = this.queue.head;
447
- * while (current && current.value.priority >= process.priority) {
448
- * current = current.next;
449
- * }
450
- *
451
- * if (!current) {
452
- * this.queue.push(process);
453
- * } else {
454
- * this.queue.addBefore(current, process);
455
- * }
456
- * }
457
- *
458
- * executeNext(): string | undefined {
459
- * // Execute tasks at the head of the queue in order
460
- * const process = this.queue.shift();
461
- * return process ? process.execute() : undefined;
462
- * }
463
- *
464
- * listProcesses(): string[] {
465
- * return this.queue.toArray().map(process => `Process ${process.id} (Priority: ${process.priority})`);
466
- * }
467
- *
468
- * clear(): void {
469
- * this.queue.clear();
470
- * }
471
- * }
472
- *
473
- * // should add processes based on priority
474
- * let scheduler = new Scheduler();
475
- * scheduler.addProcess(new Process(1, 10));
476
- * scheduler.addProcess(new Process(2, 20));
477
- * scheduler.addProcess(new Process(3, 15));
478
- *
479
- * console.log(scheduler.listProcesses()); // [
480
- * // 'Process 2 (Priority: 20)',
481
- * // 'Process 3 (Priority: 15)',
482
- * // 'Process 1 (Priority: 10)'
483
- * // ]
484
- *
485
- * // should execute the highest priority process
486
- * scheduler = new Scheduler();
487
- * scheduler.addProcess(new Process(1, 10));
488
- * scheduler.addProcess(new Process(2, 20));
489
- *
490
- * console.log(scheduler.executeNext()); // 'Process 2 executed.'
491
- * console.log(scheduler.listProcesses()); // ['Process 1 (Priority: 10)']
492
- *
493
- * // should clear all processes
494
- * scheduler = new Scheduler();
495
- * scheduler.addProcess(new Process(1, 10));
496
- * scheduler.addProcess(new Process(2, 20));
497
- *
498
- * scheduler.clear();
499
- * console.log(scheduler.listProcesses()); // []
500
- */
501
- export class DoublyLinkedList extends LinearLinkedBase {
502
- _equals = Object.is;
503
- /**
504
- * Create a DoublyLinkedList and optionally bulk-insert elements.
505
- * @remarks Time O(N), Space O(N)
506
- * @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).
507
- * @param [options] - Options such as maxLen and toElementFn.
508
- * @returns New DoublyLinkedList instance.
509
- */
510
- constructor(elements = [], options) {
511
- super(options);
512
- this._head = undefined;
513
- this._tail = undefined;
514
- this._length = 0;
515
- if (options?.maxLen && Number.isInteger(options.maxLen) && options.maxLen > 0) {
516
- this._maxLen = options.maxLen;
517
- }
518
- this.pushMany(elements);
519
- }
520
- _head;
521
- /**
522
- * Get the head node.
523
- * @remarks Time O(1), Space O(1)
524
- * @returns Head node or undefined.
525
- */
526
- get head() {
527
- return this._head;
528
- }
529
- _tail;
530
- /**
531
- * Get the tail node.
532
- * @remarks Time O(1), Space O(1)
533
- * @returns Tail node or undefined.
534
- */
535
- get tail() {
536
- return this._tail;
537
- }
538
- _length = 0;
539
- /**
540
- * Get the number of elements.
541
- * @remarks Time O(1), Space O(1)
542
- * @returns Current length.
543
- */
544
- get length() {
545
- return this._length;
546
- }
547
- /**
548
- * Get the first element value.
549
- * @remarks Time O(1), Space O(1)
550
- * @returns First element or undefined.
551
- */
552
- get first() {
553
- return this.head?.value;
554
- }
555
- /**
556
- * Get the last element value.
557
- * @remarks Time O(1), Space O(1)
558
- * @returns Last element or undefined.
559
- */
560
- get last() {
561
- return this.tail?.value;
562
- }
563
- /**
564
- * Create a new list from an array of elements.
565
- * @remarks Time O(N), Space O(N)
566
- * @template E
567
- * @template R
568
- * @param this - The constructor (subclass) to instantiate.
569
- * @param data - Array of elements to insert.
570
- * @returns A new list populated with the array's elements.
571
- */
572
- static fromArray(data) {
573
- return new this(data);
574
- }
575
- /**
576
- * Type guard: check whether the input is a DoublyLinkedListNode.
577
- * @remarks Time O(1), Space O(1)
578
- * @param elementNodeOrPredicate - Element, node, or predicate.
579
- * @returns True if the value is a DoublyLinkedListNode.
580
- */
581
- isNode(elementNodeOrPredicate) {
582
- return elementNodeOrPredicate instanceof DoublyLinkedListNode;
583
- }
584
- /**
585
- * Append an element/node to the tail.
586
- * @remarks Time O(1), Space O(1)
587
- * @param elementOrNode - Element or node to append.
588
- * @returns True when appended.
589
- */
590
- push(elementOrNode) {
591
- const newNode = this._ensureNode(elementOrNode);
592
- if (!this.head) {
593
- this._head = newNode;
594
- this._tail = newNode;
595
- }
596
- else {
597
- newNode.prev = this.tail;
598
- this.tail.next = newNode;
599
- this._tail = newNode;
600
- }
601
- this._length++;
602
- if (this._maxLen > 0 && this.length > this._maxLen)
603
- this.shift();
604
- return true;
605
- }
606
- /**
607
- * Remove and return the tail element.
608
- * @remarks Time O(1), Space O(1)
609
- * @returns Removed element or undefined.
610
- */
611
- pop() {
612
- if (!this.tail)
613
- return undefined;
614
- const removed = this.tail;
615
- if (this.head === this.tail) {
616
- this._head = undefined;
617
- this._tail = undefined;
618
- }
619
- else {
620
- this._tail = removed.prev;
621
- this.tail.next = undefined;
622
- }
623
- this._length--;
624
- return removed.value;
625
- }
626
- /**
627
- * Remove and return the head element.
628
- * @remarks Time O(1), Space O(1)
629
- * @returns Removed element or undefined.
630
- */
631
- shift() {
632
- if (!this.head)
633
- return undefined;
634
- const removed = this.head;
635
- if (this.head === this.tail) {
636
- this._head = undefined;
637
- this._tail = undefined;
638
- }
639
- else {
640
- this._head = removed.next;
641
- this.head.prev = undefined;
642
- }
643
- this._length--;
644
- return removed.value;
645
- }
646
- /**
647
- * Prepend an element/node to the head.
648
- * @remarks Time O(1), Space O(1)
649
- * @param elementOrNode - Element or node to prepend.
650
- * @returns True when prepended.
651
- */
652
- unshift(elementOrNode) {
653
- const newNode = this._ensureNode(elementOrNode);
654
- if (!this.head) {
655
- this._head = newNode;
656
- this._tail = newNode;
657
- }
658
- else {
659
- newNode.next = this.head;
660
- this.head.prev = newNode;
661
- this._head = newNode;
662
- }
663
- this._length++;
664
- if (this._maxLen > 0 && this._length > this._maxLen)
665
- this.pop();
666
- return true;
667
- }
668
- /**
669
- * Append a sequence of elements/nodes.
670
- * @remarks Time O(N), Space O(1)
671
- * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
672
- * @returns Array of per-element success flags.
673
- */
674
- pushMany(elements) {
675
- const ans = [];
676
- for (const el of elements) {
677
- if (this.toElementFn)
678
- ans.push(this.push(this.toElementFn(el)));
679
- else
680
- ans.push(this.push(el));
681
- }
682
- return ans;
683
- }
684
- /**
685
- * Prepend a sequence of elements/nodes.
686
- * @remarks Time O(N), Space O(1)
687
- * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).
688
- * @returns Array of per-element success flags.
689
- */
690
- unshiftMany(elements) {
691
- const ans = [];
692
- for (const el of elements) {
693
- if (this.toElementFn)
694
- ans.push(this.unshift(this.toElementFn(el)));
695
- else
696
- ans.push(this.unshift(el));
697
- }
698
- return ans;
699
- }
700
- /**
701
- * Get the element at a given index.
702
- * @remarks Time O(N), Space O(1)
703
- * @param index - Zero-based index.
704
- * @returns Element or undefined.
705
- */
706
- at(index) {
707
- if (index < 0 || index >= this._length)
708
- return undefined;
709
- let current = this.head;
710
- for (let i = 0; i < index; i++)
711
- current = current.next;
712
- return current.value;
713
- }
714
- /**
715
- * Get the node reference at a given index.
716
- * @remarks Time O(N), Space O(1)
717
- * @param index - Zero-based index.
718
- * @returns Node or undefined.
719
- */
720
- getNodeAt(index) {
721
- if (index < 0 || index >= this._length)
722
- return undefined;
723
- let current = this.head;
724
- for (let i = 0; i < index; i++)
725
- current = current.next;
726
- return current;
727
- }
728
- /**
729
- * Find a node by value, reference, or predicate.
730
- * @remarks Time O(N), Space O(1)
731
- * @param [elementNodeOrPredicate] - Element, node, or predicate to match.
732
- * @returns Matching node or undefined.
733
- */
734
- getNode(elementNodeOrPredicate) {
735
- if (elementNodeOrPredicate === undefined)
736
- return;
737
- if (this.isNode(elementNodeOrPredicate)) {
738
- const target = elementNodeOrPredicate;
739
- let cur = this.head;
740
- while (cur) {
741
- if (cur === target)
742
- return target;
743
- cur = cur.next;
744
- }
745
- const isMatch = (node) => this._equals(node.value, target.value);
746
- cur = this.head;
747
- while (cur) {
748
- if (isMatch(cur))
749
- return cur;
750
- cur = cur.next;
751
- }
752
- return undefined;
753
- }
754
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
755
- let current = this.head;
756
- while (current) {
757
- if (predicate(current))
758
- return current;
759
- current = current.next;
760
- }
761
- return undefined;
762
- }
763
- /**
764
- * Insert a new element/node at an index, shifting following nodes.
765
- * @remarks Time O(N), Space O(1)
766
- * @param index - Zero-based index.
767
- * @param newElementOrNode - Element or node to insert.
768
- * @returns True if inserted.
769
- */
770
- addAt(index, newElementOrNode) {
771
- if (index < 0 || index > this._length)
772
- return false;
773
- if (index === 0)
774
- return this.unshift(newElementOrNode);
775
- if (index === this._length)
776
- return this.push(newElementOrNode);
777
- const newNode = this._ensureNode(newElementOrNode);
778
- const prevNode = this.getNodeAt(index - 1);
779
- const nextNode = prevNode.next;
780
- newNode.prev = prevNode;
781
- newNode.next = nextNode;
782
- prevNode.next = newNode;
783
- nextNode.prev = newNode;
784
- this._length++;
785
- return true;
786
- }
787
- /**
788
- * Insert a new element/node before an existing one.
789
- * @remarks Time O(N), Space O(1)
790
- * @param existingElementOrNode - Existing element or node.
791
- * @param newElementOrNode - Element or node to insert.
792
- * @returns True if inserted.
793
- */
794
- addBefore(existingElementOrNode, newElementOrNode) {
795
- const existingNode = this.isNode(existingElementOrNode)
796
- ? existingElementOrNode
797
- : this.getNode(existingElementOrNode);
798
- if (!existingNode)
799
- return false;
800
- const newNode = this._ensureNode(newElementOrNode);
801
- newNode.prev = existingNode.prev;
802
- if (existingNode.prev)
803
- existingNode.prev.next = newNode;
804
- newNode.next = existingNode;
805
- existingNode.prev = newNode;
806
- if (existingNode === this.head)
807
- this._head = newNode;
808
- this._length++;
809
- return true;
810
- }
811
- /**
812
- * Insert a new element/node after an existing one.
813
- * @remarks Time O(N), Space O(1)
814
- * @param existingElementOrNode - Existing element or node.
815
- * @param newElementOrNode - Element or node to insert.
816
- * @returns True if inserted.
817
- */
818
- addAfter(existingElementOrNode, newElementOrNode) {
819
- const existingNode = this.isNode(existingElementOrNode)
820
- ? existingElementOrNode
821
- : this.getNode(existingElementOrNode);
822
- if (!existingNode)
823
- return false;
824
- const newNode = this._ensureNode(newElementOrNode);
825
- newNode.next = existingNode.next;
826
- if (existingNode.next)
827
- existingNode.next.prev = newNode;
828
- newNode.prev = existingNode;
829
- existingNode.next = newNode;
830
- if (existingNode === this.tail)
831
- this._tail = newNode;
832
- this._length++;
833
- return true;
834
- }
835
- /**
836
- * Set the element value at an index.
837
- * @remarks Time O(N), Space O(1)
838
- * @param index - Zero-based index.
839
- * @param value - New value.
840
- * @returns True if updated.
841
- */
842
- setAt(index, value) {
843
- const node = this.getNodeAt(index);
844
- if (!node)
845
- return false;
846
- node.value = value;
847
- return true;
848
- }
849
- /**
850
- * Delete the element at an index.
851
- * @remarks Time O(N), Space O(1)
852
- * @param index - Zero-based index.
853
- * @returns Removed element or undefined.
854
- */
855
- deleteAt(index) {
856
- if (index < 0 || index >= this._length)
857
- return;
858
- if (index === 0)
859
- return this.shift();
860
- if (index === this._length - 1)
861
- return this.pop();
862
- const removedNode = this.getNodeAt(index);
863
- const prevNode = removedNode.prev;
864
- const nextNode = removedNode.next;
865
- prevNode.next = nextNode;
866
- nextNode.prev = prevNode;
867
- this._length--;
868
- return removedNode.value;
869
- }
870
- /**
871
- * Delete the first match by value/node.
872
- * @remarks Time O(N), Space O(1)
873
- * @param [elementOrNode] - Element or node to remove.
874
- * @returns True if removed.
875
- */
876
- delete(elementOrNode) {
877
- const node = this.getNode(elementOrNode);
878
- if (!node)
879
- return false;
880
- if (node === this.head)
881
- this.shift();
882
- else if (node === this.tail)
883
- this.pop();
884
- else {
885
- const prevNode = node.prev;
886
- const nextNode = node.next;
887
- prevNode.next = nextNode;
888
- nextNode.prev = prevNode;
889
- this._length--;
890
- }
891
- return true;
892
- }
893
- /**
894
- * Check whether the list is empty.
895
- * @remarks Time O(1), Space O(1)
896
- * @returns True if length is 0.
897
- */
898
- isEmpty() {
899
- return this._length === 0;
900
- }
901
- /**
902
- * Remove all nodes and reset length.
903
- * @remarks Time O(N), Space O(1)
904
- * @returns void
905
- */
906
- clear() {
907
- this._head = undefined;
908
- this._tail = undefined;
909
- this._length = 0;
910
- }
911
- /**
912
- * Find the first value matching a predicate scanning forward.
913
- * @remarks Time O(N), Space O(1)
914
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
915
- * @returns Matched value or undefined.
916
- */
917
- search(elementNodeOrPredicate) {
918
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
919
- let current = this.head;
920
- while (current) {
921
- if (predicate(current))
922
- return current.value;
923
- current = current.next;
924
- }
925
- return undefined;
926
- }
927
- /**
928
- * Find the first value matching a predicate scanning backward.
929
- * @remarks Time O(N), Space O(1)
930
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
931
- * @returns Matched value or undefined.
932
- */
933
- getBackward(elementNodeOrPredicate) {
934
- const predicate = this._ensurePredicate(elementNodeOrPredicate);
935
- let current = this.tail;
936
- while (current) {
937
- if (predicate(current))
938
- return current.value;
939
- current = current.prev;
940
- }
941
- return undefined;
942
- }
943
- /**
944
- * Reverse the list in place.
945
- * @remarks Time O(N), Space O(1)
946
- * @returns This list.
947
- */
948
- reverse() {
949
- let current = this.head;
950
- [this._head, this._tail] = [this.tail, this.head];
951
- while (current) {
952
- const next = current.next;
953
- [current.prev, current.next] = [current.next, current.prev];
954
- current = next;
955
- }
956
- return this;
957
- }
958
- /**
959
- * Set the equality comparator used to compare values.
960
- * @remarks Time O(1), Space O(1)
961
- * @param equals - Equality predicate (a, b) → boolean.
962
- * @returns This list.
963
- */
964
- setEquality(equals) {
965
- this._equals = equals;
966
- return this;
967
- }
968
- /**
969
- * Deep clone this list (values are copied by reference).
970
- * @remarks Time O(N), Space O(N)
971
- * @returns A new list with the same element sequence.
972
- */
973
- clone() {
974
- const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
975
- for (const v of this)
976
- out.push(v);
977
- return out;
978
- }
979
- /**
980
- * Filter values into a new list of the same class.
981
- * @remarks Time O(N), Space O(N)
982
- * @param callback - Predicate (value, index, list) → boolean to keep value.
983
- * @param [thisArg] - Value for `this` inside the callback.
984
- * @returns A new list with kept values.
985
- */
986
- filter(callback, thisArg) {
987
- const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
988
- let index = 0;
989
- for (const v of this)
990
- if (callback.call(thisArg, v, index++, this))
991
- out.push(v);
992
- return out;
993
- }
994
- /**
995
- * Map values into a new list of the same class.
996
- * @remarks Time O(N), Space O(N)
997
- * @param callback - Mapping function (value, index, list) → newValue.
998
- * @param [thisArg] - Value for `this` inside the callback.
999
- * @returns A new list with mapped values.
1000
- */
1001
- mapSame(callback, thisArg) {
1002
- const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
1003
- let index = 0;
1004
- for (const v of this) {
1005
- const mv = thisArg === undefined ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);
1006
- out.push(mv);
1007
- }
1008
- return out;
1009
- }
1010
- /**
1011
- * Map values into a new list (possibly different element type).
1012
- * @remarks Time O(N), Space O(N)
1013
- * @template EM
1014
- * @template RM
1015
- * @param callback - Mapping function (value, index, list) → newElement.
1016
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1017
- * @param [thisArg] - Value for `this` inside the callback.
1018
- * @returns A new DoublyLinkedList with mapped values.
1019
- */
1020
- map(callback, options, thisArg) {
1021
- const out = this._createLike([], { ...(options ?? {}), maxLen: this._maxLen });
1022
- let index = 0;
1023
- for (const v of this)
1024
- out.push(callback.call(thisArg, v, index++, this));
1025
- return out;
1026
- }
1027
- /**
1028
- * (Protected) Create or return a node for the given input (node or raw element).
1029
- * @remarks Time O(1), Space O(1)
1030
- * @param elementOrNode - Element value or node to normalize.
1031
- * @returns A DoublyLinkedListNode for the provided input.
1032
- */
1033
- _ensureNode(elementOrNode) {
1034
- if (this.isNode(elementOrNode))
1035
- return elementOrNode;
1036
- return new DoublyLinkedListNode(elementOrNode);
1037
- }
1038
- /**
1039
- * (Protected) Normalize input into a predicate over nodes.
1040
- * @remarks Time O(1), Space O(1)
1041
- * @param elementNodeOrPredicate - Element, node, or node predicate.
1042
- * @returns A predicate function taking a node and returning true/false.
1043
- */
1044
- _ensurePredicate(elementNodeOrPredicate) {
1045
- if (this.isNode(elementNodeOrPredicate)) {
1046
- const target = elementNodeOrPredicate;
1047
- return (node) => node === target;
1048
- }
1049
- if (typeof elementNodeOrPredicate === 'function') {
1050
- return elementNodeOrPredicate;
1051
- }
1052
- const value = elementNodeOrPredicate;
1053
- return (node) => this._equals(node.value, value);
1054
- }
1055
- /**
1056
- * (Protected) Get the previous node of a given node.
1057
- * @remarks Time O(1), Space O(1)
1058
- * @param node - A node in the list.
1059
- * @returns Previous node or undefined.
1060
- */
1061
- _getPrevNode(node) {
1062
- return node.prev;
1063
- }
1064
- /**
1065
- * (Protected) Create an empty instance of the same concrete class.
1066
- * @remarks Time O(1), Space O(1)
1067
- * @param [options] - Options forwarded to the constructor.
1068
- * @returns An empty like-kind list instance.
1069
- */
1070
- _createInstance(options) {
1071
- const Ctor = this.constructor;
1072
- return new Ctor([], options);
1073
- }
1074
- /**
1075
- * (Protected) Create a like-kind instance and seed it from an iterable.
1076
- * @remarks Time O(N), Space O(N)
1077
- * @template EM
1078
- * @template RM
1079
- * @param [elements] - Iterable used to seed the new list.
1080
- * @param [options] - Options forwarded to the constructor.
1081
- * @returns A like-kind DoublyLinkedList instance.
1082
- */
1083
- _createLike(elements = [], options) {
1084
- const Ctor = this.constructor;
1085
- return new Ctor(elements, options);
1086
- }
1087
- *_getIterator() {
1088
- let current = this.head;
1089
- while (current) {
1090
- yield current.value;
1091
- current = current.next;
1092
- }
1093
- }
1094
- *_getReverseIterator() {
1095
- let current = this.tail;
1096
- while (current) {
1097
- yield current.value;
1098
- current = current.prev;
1099
- }
1100
- }
1101
- *_getNodeIterator() {
1102
- let current = this.head;
1103
- while (current) {
1104
- yield current;
1105
- current = current.next;
1106
- }
1107
- }
1108
- }
1109
- //# sourceMappingURL=doubly-linked-list.js.map