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,15 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Kirk Qi
5
+ * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import { PriorityQueue } from './priority-queue';
9
+ import type { Comparator } from '../../types';
10
+ export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
11
+ constructor(options?: {
12
+ comparator: Comparator<E>;
13
+ nodes?: E[];
14
+ });
15
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MinPriorityQueue = void 0;
4
+ /**
5
+ * data-structure-typed
6
+ *
7
+ * @author Kirk Qi
8
+ * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
9
+ * @license MIT License
10
+ */
11
+ const priority_queue_1 = require("./priority-queue");
12
+ class MinPriorityQueue extends priority_queue_1.PriorityQueue {
13
+ constructor(options = {
14
+ comparator: (a, b) => {
15
+ if (!(typeof a === 'number' && typeof b === 'number')) {
16
+ throw new Error('The a, b params of compare function must be number');
17
+ }
18
+ else {
19
+ return a - b;
20
+ }
21
+ }
22
+ }) {
23
+ super(options);
24
+ }
25
+ }
26
+ exports.MinPriorityQueue = MinPriorityQueue;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Kirk Qi
5
+ * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import { Heap } from '../heap';
9
+ import { Comparator } from '../../types';
10
+ export declare class PriorityQueue<E = any> extends Heap<E> {
11
+ constructor(options: {
12
+ comparator: Comparator<E>;
13
+ nodes?: E[];
14
+ });
15
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * data-structure-typed
4
+ *
5
+ * @author Kirk Qi
6
+ * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
7
+ * @license MIT License
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PriorityQueue = void 0;
11
+ const heap_1 = require("../heap");
12
+ class PriorityQueue extends heap_1.Heap {
13
+ constructor(options) {
14
+ super(options);
15
+ }
16
+ }
17
+ exports.PriorityQueue = PriorityQueue;
@@ -0,0 +1,161 @@
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
+ import { DoublyLinkedList } from '../linked-list';
9
+ export declare class Deque<E = any> extends DoublyLinkedList<E> {
10
+ }
11
+ export declare class ObjectDeque<E = number> {
12
+ constructor(capacity?: number);
13
+ protected _nodes: {
14
+ [key: number]: E;
15
+ };
16
+ get nodes(): {
17
+ [p: number]: E;
18
+ };
19
+ protected _capacity: number;
20
+ get capacity(): number;
21
+ protected _first: number;
22
+ get first(): number;
23
+ protected _last: number;
24
+ get last(): number;
25
+ protected _size: number;
26
+ get size(): number;
27
+ /**
28
+ * The "addFirst" function adds a value to the beginning of an array-like data structure.
29
+ * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
30
+ * structure.
31
+ */
32
+ addFirst(value: E): void;
33
+ /**
34
+ * The addLast function adds a value to the end of an array-like data structure.
35
+ * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
36
+ */
37
+ addLast(value: E): void;
38
+ /**
39
+ * The function `popFirst()` removes and returns the first element in a data structure.
40
+ * @returns The value of the first element in the data structure.
41
+ */
42
+ popFirst(): E | undefined;
43
+ /**
44
+ * The `getFirst` function returns the first element in an array-like data structure if it exists.
45
+ * @returns The element at the first position of the `_nodes` array.
46
+ */
47
+ getFirst(): E | undefined;
48
+ /**
49
+ * The `popLast()` function removes and returns the last element in a data structure.
50
+ * @returns The value that was removed from the data structure.
51
+ */
52
+ popLast(): E | undefined;
53
+ /**
54
+ * The `getLast()` function returns the last element in an array-like data structure.
55
+ * @returns The last element in the array "_nodes" is being returned.
56
+ */
57
+ getLast(): E | undefined;
58
+ /**
59
+ * The get function returns the element at the specified index in an array-like data structure.
60
+ * @param {number} index - The index parameter is a number that represents the position of the element you want to
61
+ * retrieve from the array.
62
+ * @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that
63
+ * index, `null` is returned.
64
+ */
65
+ get(index: number): NonNullable<E> | null;
66
+ /**
67
+ * The function checks if the size of a data structure is less than or equal to zero.
68
+ * @returns The method is returning a boolean value indicating whether the size of the object is less than or equal to 0.
69
+ */
70
+ isEmpty(): boolean;
71
+ }
72
+ export declare class ArrayDeque<E> {
73
+ protected _nodes: E[];
74
+ get nodes(): E[];
75
+ get size(): number;
76
+ /**
77
+ * O(n) time complexity of adding at the beginning and the end
78
+ */
79
+ /**
80
+ * The function "addLast" adds a value to the end of an array.
81
+ * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
82
+ * @returns The return value is the new length of the array after the value has been added.
83
+ */
84
+ addLast(value: E): number;
85
+ /**
86
+ * The function "popLast" returns and removes the last element from an array, or returns null if the array is empty.
87
+ * @returns The method `popLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
88
+ */
89
+ popLast(): E | null;
90
+ /**
91
+ * The `popFirst` function removes and returns the first element from an array, or returns null if the array is empty.
92
+ * @returns The `popFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
93
+ * empty.
94
+ */
95
+ popFirst(): E | null;
96
+ /**
97
+ * O(n) time complexity of adding at the beginning and the end
98
+ */
99
+ /**
100
+ * The function "addFirst" adds a value to the beginning of an array.
101
+ * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
102
+ * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
103
+ * `value` at the beginning.
104
+ */
105
+ addFirst(value: E): number;
106
+ /**
107
+ * The `getFirst` function returns the first element of an array or null if the array is empty.
108
+ * @returns The function `getFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
109
+ * empty, it will return `null`.
110
+ */
111
+ getFirst(): E | null;
112
+ /**
113
+ * The `getLast` function returns the last element of an array or null if the array is empty.
114
+ * @returns The method `getLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
115
+ */
116
+ getLast(): E | null;
117
+ /**
118
+ * O(1) time complexity of obtaining the value
119
+ */
120
+ /**
121
+ * The get function returns the element at the specified index in an array, or null if the index is out of bounds.
122
+ * @param {number} index - The index parameter is a number that represents the position of the element you want to
123
+ * retrieve from the array.
124
+ * @returns The method is returning the element at the specified index in the `_nodes` array. If the element exists, it
125
+ * will be returned. If the element does not exist (i.e., the index is out of bounds), `null` will be returned.
126
+ */
127
+ get(index: number): E | null;
128
+ /**
129
+ * The set function assigns a value to a specific index in an array.
130
+ * @param {number} index - The index parameter is a number that represents the position of the element in the array
131
+ * that you want to set a new value for.
132
+ * @param {E} value - The value parameter represents the new value that you want to set at the specified index in the
133
+ * _nodes array.
134
+ * @returns The value that is being set at the specified index in the `_nodes` array.
135
+ */
136
+ set(index: number, value: E): E;
137
+ /**
138
+ * The insert function adds a value at a specified index in an array.
139
+ * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
140
+ * array. It is a number that represents the index of the array where the value should be inserted. The index starts
141
+ * from 0, so the first element of the array has an index of 0, the second element has
142
+ * @param {E} value - The value parameter represents the value that you want to insert into the array at the specified
143
+ * index.
144
+ * @returns The splice method returns an array containing the removed elements, if any. In this case, since no elements
145
+ * are being removed, an empty array will be returned.
146
+ */
147
+ insert(index: number, value: E): E[];
148
+ /**
149
+ * The delete function removes an element from an array at a specified index.
150
+ * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
151
+ * is a number that represents the index of the element to be removed.
152
+ * @returns The method is returning an array containing the removed element.
153
+ */
154
+ delete(index: number): E[];
155
+ /**
156
+ * The function checks if an array called "_nodes" is empty.
157
+ * @returns The method `isEmpty()` is returning a boolean value. It returns `true` if the length of the `_nodes` array
158
+ * is 0, indicating that the array is empty. Otherwise, it returns `false`.
159
+ */
160
+ isEmpty(): boolean;
161
+ }
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArrayDeque = exports.ObjectDeque = exports.Deque = void 0;
4
+ /**
5
+ * data-structure-typed
6
+ *
7
+ * @author Tyler Zeng
8
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
+ * @license MIT License
10
+ */
11
+ const linked_list_1 = require("../linked-list");
12
+ // O(n) time complexity of obtaining the value
13
+ // O(1) time complexity of adding at the beginning and the end
14
+ class Deque extends linked_list_1.DoublyLinkedList {
15
+ }
16
+ exports.Deque = Deque;
17
+ // O(1) time complexity of obtaining the value
18
+ // O(n) time complexity of adding at the beginning and the end
19
+ // todo tested slowest one
20
+ class ObjectDeque {
21
+ constructor(capacity) {
22
+ this._nodes = {};
23
+ this._capacity = Number.MAX_SAFE_INTEGER;
24
+ this._first = -1;
25
+ this._last = -1;
26
+ this._size = 0;
27
+ if (capacity !== undefined)
28
+ this._capacity = capacity;
29
+ }
30
+ get nodes() {
31
+ return this._nodes;
32
+ }
33
+ get capacity() {
34
+ return this._capacity;
35
+ }
36
+ get first() {
37
+ return this._first;
38
+ }
39
+ get last() {
40
+ return this._last;
41
+ }
42
+ get size() {
43
+ return this._size;
44
+ }
45
+ /**
46
+ * The "addFirst" function adds a value to the beginning of an array-like data structure.
47
+ * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
48
+ * structure.
49
+ */
50
+ addFirst(value) {
51
+ if (this.size === 0) {
52
+ const mid = Math.floor(this.capacity / 2);
53
+ this._first = mid;
54
+ this._last = mid;
55
+ }
56
+ else {
57
+ this._first--;
58
+ }
59
+ this.nodes[this.first] = value;
60
+ this._size++;
61
+ }
62
+ /**
63
+ * The addLast function adds a value to the end of an array-like data structure.
64
+ * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
65
+ */
66
+ addLast(value) {
67
+ if (this.size === 0) {
68
+ const mid = Math.floor(this.capacity / 2);
69
+ this._first = mid;
70
+ this._last = mid;
71
+ }
72
+ else {
73
+ this._last++;
74
+ }
75
+ this.nodes[this.last] = value;
76
+ this._size++;
77
+ }
78
+ /**
79
+ * The function `popFirst()` removes and returns the first element in a data structure.
80
+ * @returns The value of the first element in the data structure.
81
+ */
82
+ popFirst() {
83
+ if (!this.size)
84
+ return;
85
+ const value = this.getFirst();
86
+ delete this.nodes[this.first];
87
+ this._first++;
88
+ this._size--;
89
+ return value;
90
+ }
91
+ /**
92
+ * The `getFirst` function returns the first element in an array-like data structure if it exists.
93
+ * @returns The element at the first position of the `_nodes` array.
94
+ */
95
+ getFirst() {
96
+ if (this.size)
97
+ return this.nodes[this.first];
98
+ }
99
+ /**
100
+ * The `popLast()` function removes and returns the last element in a data structure.
101
+ * @returns The value that was removed from the data structure.
102
+ */
103
+ popLast() {
104
+ if (!this.size)
105
+ return;
106
+ const value = this.getLast();
107
+ delete this.nodes[this.last];
108
+ this._last--;
109
+ this._size--;
110
+ return value;
111
+ }
112
+ /**
113
+ * The `getLast()` function returns the last element in an array-like data structure.
114
+ * @returns The last element in the array "_nodes" is being returned.
115
+ */
116
+ getLast() {
117
+ if (this.size)
118
+ return this.nodes[this.last];
119
+ }
120
+ /**
121
+ * The get function returns the element at the specified index in an array-like data structure.
122
+ * @param {number} index - The index parameter is a number that represents the position of the element you want to
123
+ * retrieve from the array.
124
+ * @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that
125
+ * index, `null` is returned.
126
+ */
127
+ get(index) {
128
+ return this.nodes[this.first + index] || null;
129
+ }
130
+ /**
131
+ * The function checks if the size of a data structure is less than or equal to zero.
132
+ * @returns The method is returning a boolean value indicating whether the size of the object is less than or equal to 0.
133
+ */
134
+ isEmpty() {
135
+ return this.size <= 0;
136
+ }
137
+ }
138
+ exports.ObjectDeque = ObjectDeque;
139
+ // O(1) time complexity of obtaining the value
140
+ // O(n) time complexity of adding at the beginning and the end
141
+ class ArrayDeque {
142
+ constructor() {
143
+ this._nodes = [];
144
+ }
145
+ get nodes() {
146
+ return this._nodes;
147
+ }
148
+ get size() {
149
+ return this.nodes.length;
150
+ }
151
+ /**
152
+ * O(n) time complexity of adding at the beginning and the end
153
+ */
154
+ /**
155
+ * The function "addLast" adds a value to the end of an array.
156
+ * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
157
+ * @returns The return value is the new length of the array after the value has been added.
158
+ */
159
+ addLast(value) {
160
+ return this.nodes.push(value);
161
+ }
162
+ /**
163
+ * The function "popLast" returns and removes the last element from an array, or returns null if the array is empty.
164
+ * @returns The method `popLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
165
+ */
166
+ popLast() {
167
+ var _a;
168
+ return (_a = this.nodes.pop()) !== null && _a !== void 0 ? _a : null;
169
+ }
170
+ /**
171
+ * The `popFirst` function removes and returns the first element from an array, or returns null if the array is empty.
172
+ * @returns The `popFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
173
+ * empty.
174
+ */
175
+ popFirst() {
176
+ var _a;
177
+ return (_a = this.nodes.shift()) !== null && _a !== void 0 ? _a : null;
178
+ }
179
+ /**
180
+ * O(n) time complexity of adding at the beginning and the end
181
+ */
182
+ /**
183
+ * The function "addFirst" adds a value to the beginning of an array.
184
+ * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
185
+ * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
186
+ * `value` at the beginning.
187
+ */
188
+ addFirst(value) {
189
+ return this.nodes.unshift(value);
190
+ }
191
+ /**
192
+ * The `getFirst` function returns the first element of an array or null if the array is empty.
193
+ * @returns The function `getFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
194
+ * empty, it will return `null`.
195
+ */
196
+ getFirst() {
197
+ var _a;
198
+ return (_a = this.nodes[0]) !== null && _a !== void 0 ? _a : null;
199
+ }
200
+ /**
201
+ * The `getLast` function returns the last element of an array or null if the array is empty.
202
+ * @returns The method `getLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
203
+ */
204
+ getLast() {
205
+ var _a;
206
+ return (_a = this.nodes[this.nodes.length - 1]) !== null && _a !== void 0 ? _a : null;
207
+ }
208
+ /**
209
+ * O(1) time complexity of obtaining the value
210
+ */
211
+ /**
212
+ * The get function returns the element at the specified index in an array, or null if the index is out of bounds.
213
+ * @param {number} index - The index parameter is a number that represents the position of the element you want to
214
+ * retrieve from the array.
215
+ * @returns The method is returning the element at the specified index in the `_nodes` array. If the element exists, it
216
+ * will be returned. If the element does not exist (i.e., the index is out of bounds), `null` will be returned.
217
+ */
218
+ get(index) {
219
+ var _a;
220
+ return (_a = this.nodes[index]) !== null && _a !== void 0 ? _a : null;
221
+ }
222
+ /**
223
+ * The set function assigns a value to a specific index in an array.
224
+ * @param {number} index - The index parameter is a number that represents the position of the element in the array
225
+ * that you want to set a new value for.
226
+ * @param {E} value - The value parameter represents the new value that you want to set at the specified index in the
227
+ * _nodes array.
228
+ * @returns The value that is being set at the specified index in the `_nodes` array.
229
+ */
230
+ set(index, value) {
231
+ return (this.nodes[index] = value);
232
+ }
233
+ /**
234
+ * The insert function adds a value at a specified index in an array.
235
+ * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
236
+ * array. It is a number that represents the index of the array where the value should be inserted. The index starts
237
+ * from 0, so the first element of the array has an index of 0, the second element has
238
+ * @param {E} value - The value parameter represents the value that you want to insert into the array at the specified
239
+ * index.
240
+ * @returns The splice method returns an array containing the removed elements, if any. In this case, since no elements
241
+ * are being removed, an empty array will be returned.
242
+ */
243
+ insert(index, value) {
244
+ return this.nodes.splice(index, 0, value);
245
+ }
246
+ /**
247
+ * The delete function removes an element from an array at a specified index.
248
+ * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
249
+ * is a number that represents the index of the element to be removed.
250
+ * @returns The method is returning an array containing the removed element.
251
+ */
252
+ delete(index) {
253
+ return this.nodes.splice(index, 1);
254
+ }
255
+ /**
256
+ * The function checks if an array called "_nodes" is empty.
257
+ * @returns The method `isEmpty()` is returning a boolean value. It returns `true` if the length of the `_nodes` array
258
+ * is 0, indicating that the array is empty. Otherwise, it returns `false`.
259
+ */
260
+ isEmpty() {
261
+ return this.nodes.length === 0;
262
+ }
263
+ }
264
+ exports.ArrayDeque = ArrayDeque;
@@ -0,0 +1,2 @@
1
+ export * from './queue';
2
+ export * from './deque';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./queue"), exports);
18
+ __exportStar(require("./deque"), exports);
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @license MIT
3
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
4
+ * @class
5
+ */
6
+ import { SinglyLinkedList } from '../linked-list';
7
+ export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
8
+ /**
9
+ * The enqueue function adds a value to the end of an array.
10
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
11
+ */
12
+ enqueue(value: E): void;
13
+ /**
14
+ * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
15
+ * @returns The method is returning the element at the front of the queue, or null if the queue is empty.
16
+ */
17
+ dequeue(): E | undefined;
18
+ /**
19
+ * The `getFirst` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
20
+ * @returns The `getFirst()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
21
+ */
22
+ getFirst(): E | undefined;
23
+ /**
24
+ * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
25
+ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
26
+ */
27
+ peek(): E | undefined;
28
+ }
29
+ export declare class Queue<E = any> {
30
+ /**
31
+ * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
32
+ * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
33
+ * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
34
+ * initialized as an empty array.
35
+ */
36
+ constructor(elements?: E[]);
37
+ protected _nodes: E[];
38
+ get nodes(): E[];
39
+ protected _offset: number;
40
+ get offset(): number;
41
+ /**
42
+ * The size function returns the number of elements in an array.
43
+ * @returns {number} The size of the array, which is the difference between the length of the array and the offset.
44
+ */
45
+ get size(): number;
46
+ /**
47
+ * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
48
+ * @public
49
+ * @static
50
+ * @param {E[]} elements - The "elements" parameter is an array of elements of type E.
51
+ * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
52
+ * array.
53
+ */
54
+ static fromArray<E>(elements: E[]): Queue<E>;
55
+ /**
56
+ * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
57
+ * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
58
+ * @returns The `add` method is returning a `Queue<E>` object.
59
+ */
60
+ push(element: E): Queue<E>;
61
+ /**
62
+ * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
63
+ * necessary to optimize performance.
64
+ * @returns The function `shift()` returns either the first element in the queue or `null` if the queue is empty.
65
+ */
66
+ shift(): E | undefined;
67
+ /**
68
+ * The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
69
+ * @returns The `getFirst()` method returns the first element of the data structure, represented by the `_nodes` array at
70
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
71
+ */
72
+ getFirst(): E | undefined;
73
+ /**
74
+ * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
75
+ * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
76
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
77
+ */
78
+ peek(): E | undefined;
79
+ /**
80
+ * The `getLast` function returns the last element in an array-like data structure, or null if the structure is empty.
81
+ * @returns The method `getLast()` returns the last element of the `_nodes` array if the array is not empty. If the
82
+ * array is empty, it returns `null`.
83
+ */
84
+ getLast(): E | undefined;
85
+ /**
86
+ * The `peekLast` function returns the last element in an array-like data structure, or null if the structure is empty.
87
+ * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
88
+ * array is empty, it returns `null`.
89
+ */
90
+ peekLast(): E | undefined;
91
+ /**
92
+ * The enqueue function adds a value to the end of a queue.
93
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
94
+ */
95
+ enqueue(value: E): void;
96
+ /**
97
+ * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
98
+ * @returns The method is returning a value of type E or null.
99
+ */
100
+ dequeue(): E | undefined;
101
+ getAt(index: number): E | undefined;
102
+ /**
103
+ * The function checks if a data structure is empty by comparing its size to zero.
104
+ * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
105
+ */
106
+ isEmpty(): boolean;
107
+ /**
108
+ * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
109
+ * @returns An array of type E is being returned.
110
+ */
111
+ toArray(): E[];
112
+ /**
113
+ * The clear function resets the nodes array and offset to their initial values.
114
+ */
115
+ clear(): void;
116
+ /**
117
+ * The `clone()` function returns a new Queue object with the same elements as the original Queue.
118
+ * @returns The `clone()` method is returning a new instance of the `Queue` class.
119
+ */
120
+ clone(): Queue<E>;
121
+ [Symbol.iterator](): Generator<E, void, unknown>;
122
+ }