min-heap-typed 1.40.0-rc → 1.40.0

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 (347) hide show
  1. package/.dependency-cruiser.js +422 -422
  2. package/.eslintrc.js +59 -59
  3. package/.prettierrc.js +14 -14
  4. package/README.md +20 -3
  5. package/coverage/clover.xml +11 -7
  6. package/coverage/coverage-final.json +95 -1
  7. package/coverage/coverage-summary.json +59 -2
  8. package/coverage/lcov-report/base.css +278 -99
  9. package/coverage/lcov-report/index.html +69 -65
  10. package/coverage/lcov-report/index.ts.html +36 -35
  11. package/coverage/lcov-report/sorter.js +15 -5
  12. package/dist/data-structures/binary-tree/avl-tree.d.ts +106 -0
  13. package/dist/data-structures/binary-tree/avl-tree.js +347 -0
  14. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +149 -0
  15. package/dist/data-structures/binary-tree/binary-indexed-tree.js +269 -0
  16. package/dist/data-structures/binary-tree/binary-tree.d.ts +355 -0
  17. package/dist/data-structures/binary-tree/binary-tree.js +1115 -0
  18. package/dist/data-structures/binary-tree/bst.d.ts +167 -0
  19. package/dist/data-structures/binary-tree/bst.js +512 -0
  20. package/dist/data-structures/binary-tree/index.d.ts +7 -0
  21. package/dist/data-structures/binary-tree/index.js +23 -0
  22. package/dist/data-structures/binary-tree/rb-tree.d.ts +11 -0
  23. package/dist/data-structures/binary-tree/rb-tree.js +21 -0
  24. package/dist/data-structures/binary-tree/segment-tree.d.ts +67 -0
  25. package/dist/data-structures/binary-tree/segment-tree.js +180 -0
  26. package/dist/data-structures/binary-tree/tree-multiset.d.ts +126 -0
  27. package/dist/data-structures/binary-tree/tree-multiset.js +355 -0
  28. package/dist/data-structures/graph/abstract-graph.d.ts +313 -0
  29. package/dist/data-structures/graph/abstract-graph.js +884 -0
  30. package/dist/data-structures/graph/directed-graph.d.ts +194 -0
  31. package/dist/data-structures/graph/directed-graph.js +404 -0
  32. package/dist/data-structures/graph/index.d.ts +4 -0
  33. package/dist/data-structures/graph/index.js +20 -0
  34. package/dist/data-structures/graph/map-graph.d.ts +73 -0
  35. package/dist/data-structures/graph/map-graph.js +93 -0
  36. package/dist/data-structures/graph/undirected-graph.d.ts +120 -0
  37. package/dist/data-structures/graph/undirected-graph.js +239 -0
  38. package/dist/data-structures/hash/coordinate-map.d.ts +44 -0
  39. package/dist/data-structures/hash/coordinate-map.js +62 -0
  40. package/dist/data-structures/hash/coordinate-set.d.ts +36 -0
  41. package/dist/data-structures/hash/coordinate-set.js +52 -0
  42. package/dist/data-structures/hash/hash-map.d.ts +50 -0
  43. package/dist/data-structures/hash/hash-map.js +153 -0
  44. package/dist/data-structures/hash/hash-table.d.ts +103 -0
  45. package/dist/data-structures/hash/hash-table.js +236 -0
  46. package/dist/data-structures/hash/index.d.ts +6 -0
  47. package/dist/data-structures/hash/index.js +22 -0
  48. package/dist/data-structures/hash/tree-map.d.ts +2 -0
  49. package/dist/data-structures/hash/tree-map.js +6 -0
  50. package/dist/data-structures/hash/tree-set.d.ts +2 -0
  51. package/dist/data-structures/hash/tree-set.js +6 -0
  52. package/dist/data-structures/heap/heap.d.ts +235 -0
  53. package/dist/data-structures/heap/heap.js +515 -0
  54. package/dist/data-structures/heap/index.d.ts +3 -0
  55. package/dist/data-structures/heap/index.js +19 -0
  56. package/dist/data-structures/heap/max-heap.d.ts +15 -0
  57. package/dist/data-structures/heap/max-heap.js +26 -0
  58. package/dist/data-structures/heap/min-heap.d.ts +15 -0
  59. package/dist/data-structures/heap/min-heap.js +26 -0
  60. package/dist/data-structures/index.d.ts +11 -0
  61. package/dist/data-structures/index.js +27 -0
  62. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +253 -0
  63. package/dist/data-structures/linked-list/doubly-linked-list.js +569 -0
  64. package/dist/data-structures/linked-list/index.d.ts +3 -0
  65. package/dist/data-structures/linked-list/index.js +19 -0
  66. package/dist/data-structures/linked-list/singly-linked-list.d.ts +232 -0
  67. package/dist/data-structures/linked-list/singly-linked-list.js +533 -0
  68. package/dist/data-structures/linked-list/skip-linked-list.d.ts +80 -0
  69. package/dist/data-structures/linked-list/skip-linked-list.js +187 -0
  70. package/dist/data-structures/matrix/index.d.ts +4 -0
  71. package/dist/data-structures/matrix/index.js +20 -0
  72. package/dist/data-structures/matrix/matrix.d.ts +21 -0
  73. package/dist/data-structures/matrix/matrix.js +28 -0
  74. package/dist/data-structures/matrix/matrix2d.d.ts +107 -0
  75. package/dist/data-structures/matrix/matrix2d.js +199 -0
  76. package/dist/data-structures/matrix/navigator.d.ts +52 -0
  77. package/dist/data-structures/matrix/navigator.js +106 -0
  78. package/dist/data-structures/matrix/vector2d.d.ts +200 -0
  79. package/dist/data-structures/matrix/vector2d.js +290 -0
  80. package/dist/data-structures/priority-queue/index.d.ts +3 -0
  81. package/dist/data-structures/priority-queue/index.js +19 -0
  82. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +15 -0
  83. package/dist/data-structures/priority-queue/max-priority-queue.js +26 -0
  84. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +15 -0
  85. package/dist/data-structures/priority-queue/min-priority-queue.js +26 -0
  86. package/dist/data-structures/priority-queue/priority-queue.d.ts +15 -0
  87. package/dist/data-structures/priority-queue/priority-queue.js +17 -0
  88. package/dist/data-structures/queue/deque.d.ts +161 -0
  89. package/dist/data-structures/queue/deque.js +264 -0
  90. package/dist/data-structures/queue/index.d.ts +2 -0
  91. package/dist/data-structures/queue/index.js +18 -0
  92. package/dist/data-structures/queue/queue.d.ts +122 -0
  93. package/dist/data-structures/queue/queue.js +187 -0
  94. package/dist/data-structures/stack/index.d.ts +1 -0
  95. package/dist/data-structures/stack/index.js +17 -0
  96. package/dist/data-structures/stack/stack.d.ts +64 -0
  97. package/dist/data-structures/stack/stack.js +94 -0
  98. package/dist/data-structures/tree/index.d.ts +1 -0
  99. package/dist/data-structures/tree/index.js +17 -0
  100. package/dist/data-structures/tree/tree.d.ts +8 -0
  101. package/dist/data-structures/tree/tree.js +40 -0
  102. package/dist/data-structures/trie/index.d.ts +1 -0
  103. package/dist/data-structures/trie/index.js +17 -0
  104. package/dist/data-structures/trie/trie.d.ts +79 -0
  105. package/dist/data-structures/trie/trie.js +251 -0
  106. package/dist/index.d.ts +3 -1
  107. package/dist/index.js +18 -4
  108. package/dist/interfaces/binary-tree.d.ts +7 -0
  109. package/dist/interfaces/binary-tree.js +2 -0
  110. package/dist/interfaces/doubly-linked-list.d.ts +1 -0
  111. package/dist/interfaces/doubly-linked-list.js +2 -0
  112. package/dist/interfaces/graph.d.ts +5 -0
  113. package/dist/interfaces/graph.js +2 -0
  114. package/dist/interfaces/heap.d.ts +1 -0
  115. package/dist/interfaces/heap.js +2 -0
  116. package/dist/interfaces/index.d.ts +8 -0
  117. package/dist/interfaces/index.js +24 -0
  118. package/dist/interfaces/navigator.d.ts +1 -0
  119. package/dist/interfaces/navigator.js +2 -0
  120. package/dist/interfaces/priority-queue.d.ts +1 -0
  121. package/dist/interfaces/priority-queue.js +2 -0
  122. package/dist/interfaces/segment-tree.d.ts +1 -0
  123. package/dist/interfaces/segment-tree.js +2 -0
  124. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  125. package/dist/interfaces/singly-linked-list.js +2 -0
  126. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
  127. package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
  128. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  129. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
  130. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  131. package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
  132. package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
  133. package/dist/types/data-structures/binary-tree/bst.js +2 -0
  134. package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
  135. package/dist/types/data-structures/binary-tree/index.js +22 -0
  136. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
  137. package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
  138. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  139. package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
  140. package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
  141. package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
  142. package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
  143. package/dist/types/data-structures/graph/abstract-graph.js +2 -0
  144. package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
  145. package/dist/types/data-structures/graph/directed-graph.js +9 -0
  146. package/dist/types/data-structures/graph/index.d.ts +3 -0
  147. package/dist/types/data-structures/graph/index.js +19 -0
  148. package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
  149. package/dist/types/data-structures/graph/map-graph.js +2 -0
  150. package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
  151. package/dist/types/data-structures/graph/undirected-graph.js +2 -0
  152. package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
  153. package/dist/types/data-structures/hash/coordinate-map.js +2 -0
  154. package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
  155. package/dist/types/data-structures/hash/coordinate-set.js +2 -0
  156. package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
  157. package/dist/types/data-structures/hash/hash-map.js +2 -0
  158. package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
  159. package/dist/types/data-structures/hash/hash-table.js +2 -0
  160. package/dist/types/data-structures/hash/index.d.ts +1 -0
  161. package/dist/types/data-structures/hash/index.js +2 -0
  162. package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
  163. package/dist/types/data-structures/hash/tree-map.js +2 -0
  164. package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
  165. package/dist/types/data-structures/hash/tree-set.js +2 -0
  166. package/dist/types/data-structures/heap/heap.d.ts +1 -0
  167. package/dist/types/data-structures/heap/heap.js +2 -0
  168. package/dist/types/data-structures/heap/index.d.ts +1 -0
  169. package/dist/types/data-structures/heap/index.js +17 -0
  170. package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
  171. package/dist/types/data-structures/heap/max-heap.js +2 -0
  172. package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
  173. package/dist/types/data-structures/heap/min-heap.js +2 -0
  174. package/dist/types/data-structures/index.d.ts +11 -0
  175. package/dist/types/data-structures/index.js +27 -0
  176. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
  177. package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
  178. package/dist/types/data-structures/linked-list/index.d.ts +2 -0
  179. package/dist/types/data-structures/linked-list/index.js +18 -0
  180. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
  181. package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
  182. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
  183. package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
  184. package/dist/types/data-structures/matrix/index.d.ts +1 -0
  185. package/dist/types/data-structures/matrix/index.js +17 -0
  186. package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
  187. package/dist/types/data-structures/matrix/matrix.js +2 -0
  188. package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
  189. package/dist/types/data-structures/matrix/matrix2d.js +2 -0
  190. package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
  191. package/dist/types/data-structures/matrix/navigator.js +2 -0
  192. package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
  193. package/dist/types/data-structures/matrix/vector2d.js +2 -0
  194. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  195. package/dist/types/data-structures/priority-queue/index.js +19 -0
  196. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  197. package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
  198. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  199. package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
  200. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  201. package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
  202. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  203. package/dist/types/data-structures/queue/deque.js +2 -0
  204. package/dist/types/data-structures/queue/index.d.ts +2 -0
  205. package/dist/types/data-structures/queue/index.js +18 -0
  206. package/dist/types/data-structures/queue/queue.d.ts +1 -0
  207. package/dist/types/data-structures/queue/queue.js +2 -0
  208. package/dist/types/data-structures/stack/index.d.ts +1 -0
  209. package/dist/types/data-structures/stack/index.js +17 -0
  210. package/dist/types/data-structures/stack/stack.d.ts +1 -0
  211. package/dist/types/data-structures/stack/stack.js +2 -0
  212. package/dist/types/data-structures/tree/index.d.ts +1 -0
  213. package/dist/types/data-structures/tree/index.js +17 -0
  214. package/dist/types/data-structures/tree/tree.d.ts +1 -0
  215. package/dist/types/data-structures/tree/tree.js +2 -0
  216. package/dist/types/data-structures/trie/index.d.ts +1 -0
  217. package/dist/types/data-structures/trie/index.js +17 -0
  218. package/dist/types/data-structures/trie/trie.d.ts +1 -0
  219. package/dist/types/data-structures/trie/trie.js +2 -0
  220. package/dist/types/helpers.d.ts +8 -0
  221. package/dist/types/helpers.js +9 -0
  222. package/dist/types/index.d.ts +3 -0
  223. package/dist/types/index.js +19 -0
  224. package/dist/types/utils/index.d.ts +2 -0
  225. package/dist/types/utils/index.js +18 -0
  226. package/dist/types/utils/utils.d.ts +7 -0
  227. package/dist/types/utils/utils.js +2 -0
  228. package/dist/types/utils/validate-type.d.ts +19 -0
  229. package/dist/types/utils/validate-type.js +2 -0
  230. package/dist/utils/index.d.ts +1 -0
  231. package/dist/utils/index.js +17 -0
  232. package/dist/utils/utils.d.ts +20 -0
  233. package/dist/utils/utils.js +73 -0
  234. package/jest.config.js +6 -6
  235. package/package.json +2 -2
  236. package/src/data-structures/binary-tree/avl-tree.ts +350 -0
  237. package/src/data-structures/binary-tree/binary-indexed-tree.ts +306 -0
  238. package/src/data-structures/binary-tree/binary-tree.ts +1262 -0
  239. package/src/data-structures/binary-tree/bst.ts +522 -0
  240. package/src/data-structures/binary-tree/index.ts +7 -0
  241. package/src/data-structures/binary-tree/rb-tree.ts +358 -0
  242. package/src/data-structures/binary-tree/segment-tree.ts +190 -0
  243. package/src/data-structures/binary-tree/tree-multiset.ts +379 -0
  244. package/src/data-structures/graph/abstract-graph.ts +1000 -0
  245. package/src/data-structures/graph/directed-graph.ts +449 -0
  246. package/src/data-structures/graph/index.ts +4 -0
  247. package/src/data-structures/graph/map-graph.ts +106 -0
  248. package/src/data-structures/graph/undirected-graph.ts +259 -0
  249. package/src/data-structures/hash/coordinate-map.ts +63 -0
  250. package/src/data-structures/hash/coordinate-set.ts +52 -0
  251. package/src/data-structures/hash/hash-map.ts +185 -0
  252. package/src/data-structures/hash/hash-table.ts +268 -0
  253. package/src/data-structures/hash/index.ts +6 -0
  254. package/src/data-structures/hash/tree-map.ts +2 -0
  255. package/src/data-structures/hash/tree-set.ts +2 -0
  256. package/src/data-structures/heap/heap.ts +589 -0
  257. package/src/data-structures/heap/index.ts +3 -0
  258. package/src/data-structures/heap/max-heap.ts +26 -0
  259. package/src/data-structures/heap/min-heap.ts +26 -0
  260. package/src/data-structures/index.ts +11 -0
  261. package/src/data-structures/linked-list/doubly-linked-list.ts +605 -0
  262. package/src/data-structures/linked-list/index.ts +3 -0
  263. package/src/data-structures/linked-list/singly-linked-list.ts +576 -0
  264. package/src/data-structures/linked-list/skip-linked-list.ts +221 -0
  265. package/src/data-structures/matrix/index.ts +4 -0
  266. package/src/data-structures/matrix/matrix.ts +27 -0
  267. package/src/data-structures/matrix/matrix2d.ts +211 -0
  268. package/src/data-structures/matrix/navigator.ts +121 -0
  269. package/src/data-structures/matrix/vector2d.ts +315 -0
  270. package/src/data-structures/priority-queue/index.ts +3 -0
  271. package/src/data-structures/priority-queue/max-priority-queue.ts +25 -0
  272. package/src/data-structures/priority-queue/min-priority-queue.ts +25 -0
  273. package/src/data-structures/priority-queue/priority-queue.ts +16 -0
  274. package/src/data-structures/queue/deque.ts +282 -0
  275. package/src/data-structures/queue/index.ts +2 -0
  276. package/src/data-structures/queue/queue.ts +209 -0
  277. package/src/data-structures/stack/index.ts +1 -0
  278. package/src/data-structures/stack/stack.ts +102 -0
  279. package/src/data-structures/tree/index.ts +1 -0
  280. package/src/data-structures/tree/tree.ts +41 -0
  281. package/src/data-structures/trie/index.ts +1 -0
  282. package/src/data-structures/trie/trie.ts +262 -0
  283. package/src/index.ts +4 -1
  284. package/src/interfaces/binary-tree.ts +10 -0
  285. package/src/interfaces/doubly-linked-list.ts +1 -0
  286. package/src/interfaces/graph.ts +7 -0
  287. package/src/interfaces/heap.ts +1 -0
  288. package/src/interfaces/index.ts +8 -0
  289. package/src/interfaces/navigator.ts +1 -0
  290. package/src/interfaces/priority-queue.ts +1 -0
  291. package/src/interfaces/segment-tree.ts +1 -0
  292. package/src/interfaces/singly-linked-list.ts +1 -0
  293. package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
  294. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  295. package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
  296. package/src/types/data-structures/binary-tree/bst.ts +11 -0
  297. package/src/types/data-structures/binary-tree/index.ts +6 -0
  298. package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
  299. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
  300. package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
  301. package/src/types/data-structures/graph/abstract-graph.ts +11 -0
  302. package/src/types/data-structures/graph/directed-graph.ts +8 -0
  303. package/src/types/data-structures/graph/index.ts +3 -0
  304. package/src/types/data-structures/graph/map-graph.ts +1 -0
  305. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  306. package/src/types/data-structures/hash/coordinate-map.ts +1 -0
  307. package/src/types/data-structures/hash/coordinate-set.ts +1 -0
  308. package/src/types/data-structures/hash/hash-map.ts +1 -0
  309. package/src/types/data-structures/hash/hash-table.ts +1 -0
  310. package/src/types/data-structures/hash/index.ts +1 -0
  311. package/src/types/data-structures/hash/tree-map.ts +1 -0
  312. package/src/types/data-structures/hash/tree-set.ts +1 -0
  313. package/src/types/data-structures/heap/heap.ts +1 -0
  314. package/src/types/data-structures/heap/index.ts +1 -0
  315. package/src/types/data-structures/heap/max-heap.ts +1 -0
  316. package/src/types/data-structures/heap/min-heap.ts +1 -0
  317. package/src/types/data-structures/index.ts +11 -0
  318. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
  319. package/src/types/data-structures/linked-list/index.ts +2 -0
  320. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
  321. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  322. package/src/types/data-structures/matrix/index.ts +1 -0
  323. package/src/types/data-structures/matrix/matrix.ts +1 -0
  324. package/src/types/data-structures/matrix/matrix2d.ts +1 -0
  325. package/src/types/data-structures/matrix/navigator.ts +14 -0
  326. package/src/types/data-structures/matrix/vector2d.ts +1 -0
  327. package/src/types/data-structures/priority-queue/index.ts +3 -0
  328. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  329. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  330. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  331. package/src/types/data-structures/queue/deque.ts +1 -0
  332. package/src/types/data-structures/queue/index.ts +2 -0
  333. package/src/types/data-structures/queue/queue.ts +1 -0
  334. package/src/types/data-structures/stack/index.ts +1 -0
  335. package/src/types/data-structures/stack/stack.ts +1 -0
  336. package/src/types/data-structures/tree/index.ts +1 -0
  337. package/src/types/data-structures/tree/tree.ts +1 -0
  338. package/src/types/data-structures/trie/index.ts +1 -0
  339. package/src/types/data-structures/trie/trie.ts +1 -0
  340. package/src/types/helpers.ts +11 -0
  341. package/src/types/index.ts +3 -0
  342. package/src/types/utils/index.ts +2 -0
  343. package/src/types/utils/utils.ts +6 -0
  344. package/src/types/utils/validate-type.ts +35 -0
  345. package/src/utils/index.ts +1 -0
  346. package/src/utils/utils.ts +86 -0
  347. package/tsconfig.json +1 -2
@@ -0,0 +1,253 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ export declare class DoublyLinkedListNode<E = any> {
9
+ value: E;
10
+ next: DoublyLinkedListNode<E> | null;
11
+ prev: DoublyLinkedListNode<E> | null;
12
+ /**
13
+ * The constructor function initializes the value, next, and previous properties of an object.
14
+ * @param {E} value - The "value" parameter is the value that will be stored in the node. It can be of any data type, as it
15
+ * is defined as a generic type "E".
16
+ */
17
+ constructor(value: E);
18
+ }
19
+ export declare class DoublyLinkedList<E = any> {
20
+ /**
21
+ * The constructor initializes the linked list with an empty head, tail, and length.
22
+ */
23
+ constructor();
24
+ protected _head: DoublyLinkedListNode<E> | null;
25
+ get head(): DoublyLinkedListNode<E> | null;
26
+ protected _tail: DoublyLinkedListNode<E> | null;
27
+ get tail(): DoublyLinkedListNode<E> | null;
28
+ protected _length: number;
29
+ get length(): number;
30
+ get size(): number;
31
+ /**
32
+ * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
33
+ * given array.
34
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
35
+ * @returns The `fromArray` function returns a DoublyLinkedList object.
36
+ */
37
+ static fromArray<E>(data: E[]): DoublyLinkedList<E>;
38
+ /**
39
+ * The push function adds a new node with the given value to the end of the doubly linked list.
40
+ * @param {E} value - The value to be added to the linked list.
41
+ */
42
+ push(value: E): void;
43
+ /**
44
+ * The addLast function adds a new node with the given value to the end of the doubly linked list.
45
+ * @param {E} value - The value to be added to the linked list.
46
+ */
47
+ addLast(value: E): void;
48
+ /**
49
+ * The `pop()` function removes and returns the value of the last node in a doubly linked list.
50
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
51
+ * list is empty, it returns null.
52
+ */
53
+ pop(): E | undefined;
54
+ /**
55
+ * The `popLast()` function removes and returns the value of the last node in a doubly linked list.
56
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
57
+ * list is empty, it returns null.
58
+ */
59
+ popLast(): E | undefined;
60
+ /**
61
+ * The `shift()` function removes and returns the value of the first node in a doubly linked list.
62
+ * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
63
+ * list.
64
+ */
65
+ shift(): E | undefined;
66
+ /**
67
+ * The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
68
+ * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
69
+ * list.
70
+ */
71
+ popFirst(): E | undefined;
72
+ /**
73
+ * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
74
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
75
+ * doubly linked list.
76
+ */
77
+ unshift(value: E): void;
78
+ /**
79
+ * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
80
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
81
+ * doubly linked list.
82
+ */
83
+ addFirst(value: E): void;
84
+ /**
85
+ * The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.
86
+ * @returns The method `getFirst()` returns the first node of the doubly linked list, or `null` if the list is empty.
87
+ */
88
+ getFirst(): E | undefined;
89
+ /**
90
+ * The `getLast` function returns the last node in a doubly linked list, or null if the list is empty.
91
+ * @returns The method `getLast()` returns the last node of the doubly linked list, or `null` if the list is empty.
92
+ */
93
+ getLast(): E | undefined;
94
+ /**
95
+ * The `getAt` function returns the value at a specified index in a linked list, or null if the index is out of bounds.
96
+ * @param {number} index - The index parameter is a number that represents the position of the element we want to
97
+ * retrieve from the list.
98
+ * @returns The method is returning the value at the specified index in the linked list. If the index is out of bounds
99
+ * or the linked list is empty, it will return null.
100
+ */
101
+ getAt(index: number): E | undefined;
102
+ /**
103
+ * The function `getNodeAt` returns the node at a given index in a doubly linked list, or null if the index is out of
104
+ * range.
105
+ * @param {number} index - The `index` parameter is a number that represents the position of the node we want to
106
+ * retrieve from the doubly linked list. It indicates the zero-based index of the node we want to access.
107
+ * @returns The method `getNodeAt(index: number)` returns a `DoublyLinkedListNode<E>` object if the index is within the
108
+ * valid range of the linked list, otherwise it returns `null`.
109
+ */
110
+ getNodeAt(index: number): DoublyLinkedListNode<E> | null;
111
+ /**
112
+ * The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
113
+ * node if found, otherwise it returns null.
114
+ * @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
115
+ * @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
116
+ * is found in the linked list. If no such node is found, it returns `null`.
117
+ */
118
+ getNode(value: E | null): DoublyLinkedListNode<E> | null;
119
+ /**
120
+ * The `insert` function inserts a value at a specified index in a doubly linked list.
121
+ * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
122
+ * DoublyLinkedList. It is of type number.
123
+ * @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
124
+ * specified index.
125
+ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
126
+ * if the index is out of bounds.
127
+ */
128
+ insertAt(index: number, value: E): boolean;
129
+ /**
130
+ * The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
131
+ * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
132
+ * before which the new value will be inserted. It can be either the value of the existing node or the existing node
133
+ * itself.
134
+ * @param {E} newValue - The `newValue` parameter represents the value that you want to insert into the doubly linked
135
+ * list.
136
+ * @returns The method returns a boolean value. It returns `true` if the insertion is successful, and `false` if the
137
+ * insertion fails.
138
+ */
139
+ insertBefore(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
140
+ /**
141
+ * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
142
+ * @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
143
+ * data structure. It is of type number.
144
+ * @returns The method `deleteAt` returns the value of the node that was deleted, or `null` if the index is out of
145
+ * bounds.
146
+ */
147
+ deleteAt(index: number): E | undefined;
148
+ /**
149
+ * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
150
+ * @param {E | DoublyLinkedListNode<E>} valOrNode - The `valOrNode` parameter can accept either a value of type `E` or
151
+ * a `DoublyLinkedListNode<E>` object.
152
+ * @returns The `delete` method returns a boolean value. It returns `true` if the value or node was successfully
153
+ * deleted from the doubly linked list, and `false` if the value or node was not found in the list.
154
+ */
155
+ delete(valOrNode: E | DoublyLinkedListNode<E> | null): boolean;
156
+ /**
157
+ * The `toArray` function converts a linked list into an array.
158
+ * @returns The `toArray()` method is returning an array of type `E[]`.
159
+ */
160
+ toArray(): E[];
161
+ /**
162
+ * The function checks if a variable has a length greater than zero and returns a boolean value.
163
+ * @returns A boolean value is being returned.
164
+ */
165
+ isEmpty(): boolean;
166
+ /**
167
+ * The `clear` function resets the linked list by setting the head, tail, and length to null and 0 respectively.
168
+ */
169
+ clear(): void;
170
+ /**
171
+ * The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
172
+ * @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
173
+ * function is used to determine whether a particular value in the linked list satisfies a certain condition.
174
+ * @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
175
+ * the callback function. If no element satisfies the condition, it returns `null`.
176
+ */
177
+ find(callback: (value: E) => boolean): E | null;
178
+ /**
179
+ * The function returns the index of the first occurrence of a given value in a linked list.
180
+ * @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
181
+ * that we are searching for in the linked list.
182
+ * @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
183
+ * list. If the value is not found, it returns -1.
184
+ */
185
+ indexOf(value: E): number;
186
+ /**
187
+ * The `findBackward` function iterates through a linked list from the last node to the first node and returns the last
188
+ * value that satisfies the given callback function, or null if no value satisfies the callback.
189
+ * @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
190
+ * function is used to determine whether a given value satisfies a certain condition.
191
+ * @returns The method `findBackward` returns the last value in the linked list that satisfies the condition specified by
192
+ * the callback function. If no value satisfies the condition, it returns `null`.
193
+ */
194
+ findBackward(callback: (value: E) => boolean): E | null;
195
+ /**
196
+ * The `toArrayBackward` function converts a doubly linked list into an array in reverse order.
197
+ * @returns The `toArrayBackward()` function returns an array of type `E[]`.
198
+ */
199
+ toArrayBackward(): E[];
200
+ /**
201
+ * The `reverse` function reverses the order of the elements in a doubly linked list.
202
+ */
203
+ reverse(): void;
204
+ /**
205
+ * The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
206
+ * @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
207
+ * represents the value of the current node in the linked list, and the index argument represents the index of the
208
+ * current node in the linked list.
209
+ */
210
+ forEach(callback: (value: E, index: number) => void): void;
211
+ /**
212
+ * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
213
+ * DoublyLinkedList with the transformed values.
214
+ * @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
215
+ * the original DoublyLinkedList) and returns a value of type U (the type of values that will be stored in the mapped
216
+ * DoublyLinkedList).
217
+ * @returns The `map` function is returning a new instance of `DoublyLinkedList<U>` that contains the mapped values.
218
+ */
219
+ map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
220
+ /**
221
+ * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
222
+ * elements that satisfy the given callback function.
223
+ * @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
224
+ * It is used to determine whether a value should be included in the filtered list or not.
225
+ * @returns The filtered list, which is an instance of the DoublyLinkedList class.
226
+ */
227
+ filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
228
+ /**
229
+ * The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
230
+ * single value.
231
+ * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
232
+ * used to perform a specific operation on each element of the linked list.
233
+ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
234
+ * point for the reduction operation.
235
+ * @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
236
+ * elements in the linked list.
237
+ */
238
+ reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
239
+ /**
240
+ * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
241
+ * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
242
+ * after which the new value will be inserted. It can be either the value of the existing node or the existing node
243
+ * itself.
244
+ * @param {E} newValue - The value that you want to insert into the doubly linked list.
245
+ * @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
246
+ * existing value or node is not found in the doubly linked list.
247
+ */
248
+ insertAfter(existingValueOrNode: E | DoublyLinkedListNode<E>, newValue: E): boolean;
249
+ /**
250
+ * The function returns an iterator that iterates over the values of a linked list.
251
+ */
252
+ [Symbol.iterator](): Generator<E, void, unknown>;
253
+ }