min-heap-typed 1.38.0 → 1.38.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 (334) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +100 -0
  2. package/dist/data-structures/binary-tree/avl-tree.js +341 -0
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +144 -0
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.js +261 -0
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +409 -0
  6. package/dist/data-structures/binary-tree/binary-tree.js +1065 -0
  7. package/dist/data-structures/binary-tree/bst.d.ts +167 -0
  8. package/dist/data-structures/binary-tree/bst.js +512 -0
  9. package/dist/data-structures/binary-tree/index.d.ts +7 -0
  10. package/dist/data-structures/binary-tree/index.js +23 -0
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
  12. package/dist/data-structures/binary-tree/rb-tree.js +27 -0
  13. package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
  14. package/dist/data-structures/binary-tree/segment-tree.js +228 -0
  15. package/dist/data-structures/binary-tree/tree-multiset.d.ts +122 -0
  16. package/dist/data-structures/binary-tree/tree-multiset.js +351 -0
  17. package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
  18. package/dist/data-structures/graph/abstract-graph.js +923 -0
  19. package/dist/data-structures/graph/directed-graph.d.ts +200 -0
  20. package/dist/data-structures/graph/directed-graph.js +422 -0
  21. package/dist/data-structures/graph/index.d.ts +4 -0
  22. package/dist/data-structures/graph/index.js +20 -0
  23. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  24. package/dist/data-structures/graph/map-graph.js +111 -0
  25. package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
  26. package/dist/data-structures/graph/undirected-graph.js +252 -0
  27. package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
  28. package/dist/data-structures/hash/coordinate-map.js +65 -0
  29. package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
  30. package/dist/data-structures/hash/coordinate-set.js +55 -0
  31. package/dist/data-structures/hash/hash-map.d.ts +56 -0
  32. package/dist/data-structures/hash/hash-map.js +171 -0
  33. package/dist/data-structures/hash/hash-table.d.ts +106 -0
  34. package/dist/data-structures/hash/hash-table.js +245 -0
  35. package/dist/data-structures/hash/index.d.ts +6 -0
  36. package/dist/data-structures/hash/index.js +22 -0
  37. package/dist/data-structures/hash/tree-map.d.ts +2 -0
  38. package/dist/data-structures/hash/tree-map.js +6 -0
  39. package/dist/data-structures/hash/tree-set.d.ts +2 -0
  40. package/dist/data-structures/hash/tree-set.js +6 -0
  41. package/dist/data-structures/heap/heap.d.ts +224 -0
  42. package/dist/data-structures/heap/heap.js +497 -0
  43. package/dist/data-structures/heap/index.d.ts +3 -0
  44. package/dist/data-structures/heap/index.js +19 -0
  45. package/dist/data-structures/heap/max-heap.d.ts +12 -0
  46. package/dist/data-structures/heap/max-heap.js +24 -0
  47. package/dist/data-structures/heap/min-heap.d.ts +12 -0
  48. package/dist/data-structures/heap/min-heap.js +24 -0
  49. package/dist/data-structures/index.d.ts +11 -0
  50. package/dist/data-structures/index.js +27 -0
  51. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
  52. package/dist/data-structures/linked-list/doubly-linked-list.js +583 -0
  53. package/dist/data-structures/linked-list/index.d.ts +3 -0
  54. package/dist/data-structures/linked-list/index.js +19 -0
  55. package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
  56. package/dist/data-structures/linked-list/singly-linked-list.js +448 -0
  57. package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
  58. package/dist/data-structures/linked-list/skip-linked-list.js +142 -0
  59. package/dist/data-structures/matrix/index.d.ts +4 -0
  60. package/dist/data-structures/matrix/index.js +20 -0
  61. package/dist/data-structures/matrix/matrix.d.ts +21 -0
  62. package/dist/data-structures/matrix/matrix.js +28 -0
  63. package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
  64. package/dist/data-structures/matrix/matrix2d.js +203 -0
  65. package/dist/data-structures/matrix/navigator.d.ts +52 -0
  66. package/dist/data-structures/matrix/navigator.js +106 -0
  67. package/dist/data-structures/matrix/vector2d.d.ts +201 -0
  68. package/dist/data-structures/matrix/vector2d.js +291 -0
  69. package/dist/data-structures/priority-queue/index.d.ts +3 -0
  70. package/dist/data-structures/priority-queue/index.js +19 -0
  71. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -0
  72. package/dist/data-structures/priority-queue/max-priority-queue.js +24 -0
  73. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -0
  74. package/dist/data-structures/priority-queue/min-priority-queue.js +24 -0
  75. package/dist/data-structures/priority-queue/priority-queue.d.ts +12 -0
  76. package/dist/data-structures/priority-queue/priority-queue.js +17 -0
  77. package/dist/data-structures/queue/deque.d.ts +165 -0
  78. package/dist/data-structures/queue/deque.js +276 -0
  79. package/dist/data-structures/queue/index.d.ts +2 -0
  80. package/dist/data-structures/queue/index.js +18 -0
  81. package/dist/data-structures/queue/queue.d.ts +107 -0
  82. package/dist/data-structures/queue/queue.js +170 -0
  83. package/dist/data-structures/stack/index.d.ts +1 -0
  84. package/dist/data-structures/stack/index.js +17 -0
  85. package/dist/data-structures/stack/stack.d.ts +63 -0
  86. package/dist/data-structures/stack/stack.js +91 -0
  87. package/dist/data-structures/tree/index.d.ts +1 -0
  88. package/dist/data-structures/tree/index.js +17 -0
  89. package/dist/data-structures/tree/tree.d.ts +14 -0
  90. package/dist/data-structures/tree/tree.js +58 -0
  91. package/dist/data-structures/trie/index.d.ts +1 -0
  92. package/dist/data-structures/trie/index.js +17 -0
  93. package/dist/data-structures/trie/trie.d.ts +84 -0
  94. package/dist/data-structures/trie/trie.js +268 -0
  95. package/dist/index.d.ts +3 -3
  96. package/dist/index.js +3 -3
  97. package/dist/interfaces/binary-tree.d.ts +7 -0
  98. package/dist/interfaces/binary-tree.js +2 -0
  99. package/dist/interfaces/doubly-linked-list.d.ts +1 -0
  100. package/dist/interfaces/doubly-linked-list.js +2 -0
  101. package/dist/interfaces/graph.d.ts +5 -0
  102. package/dist/interfaces/graph.js +2 -0
  103. package/dist/interfaces/heap.d.ts +1 -0
  104. package/dist/interfaces/heap.js +2 -0
  105. package/dist/interfaces/index.d.ts +8 -0
  106. package/dist/interfaces/index.js +24 -0
  107. package/dist/interfaces/navigator.d.ts +1 -0
  108. package/dist/interfaces/navigator.js +2 -0
  109. package/dist/interfaces/priority-queue.d.ts +1 -0
  110. package/dist/interfaces/priority-queue.js +2 -0
  111. package/dist/interfaces/segment-tree.d.ts +1 -0
  112. package/dist/interfaces/segment-tree.js +2 -0
  113. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  114. package/dist/interfaces/singly-linked-list.js +2 -0
  115. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
  116. package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
  117. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  118. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
  119. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +31 -0
  120. package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
  121. package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
  122. package/dist/types/data-structures/binary-tree/bst.js +2 -0
  123. package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
  124. package/dist/types/data-structures/binary-tree/index.js +22 -0
  125. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
  126. package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
  127. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  128. package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
  129. package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
  130. package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
  131. package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
  132. package/dist/types/data-structures/graph/abstract-graph.js +2 -0
  133. package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
  134. package/dist/types/data-structures/graph/directed-graph.js +9 -0
  135. package/dist/types/data-structures/graph/index.d.ts +3 -0
  136. package/dist/types/data-structures/graph/index.js +19 -0
  137. package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
  138. package/dist/types/data-structures/graph/map-graph.js +2 -0
  139. package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
  140. package/dist/types/data-structures/graph/undirected-graph.js +2 -0
  141. package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
  142. package/dist/types/data-structures/hash/coordinate-map.js +2 -0
  143. package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
  144. package/dist/types/data-structures/hash/coordinate-set.js +2 -0
  145. package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
  146. package/dist/types/data-structures/hash/hash-map.js +2 -0
  147. package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
  148. package/dist/types/data-structures/hash/hash-table.js +2 -0
  149. package/dist/types/data-structures/hash/index.d.ts +1 -0
  150. package/dist/types/data-structures/hash/index.js +2 -0
  151. package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
  152. package/dist/types/data-structures/hash/tree-map.js +2 -0
  153. package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
  154. package/dist/types/data-structures/hash/tree-set.js +2 -0
  155. package/dist/types/data-structures/heap/heap.d.ts +1 -0
  156. package/dist/types/data-structures/heap/heap.js +2 -0
  157. package/dist/types/data-structures/heap/index.d.ts +1 -0
  158. package/dist/types/data-structures/heap/index.js +17 -0
  159. package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
  160. package/dist/types/data-structures/heap/max-heap.js +2 -0
  161. package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
  162. package/dist/types/data-structures/heap/min-heap.js +2 -0
  163. package/dist/types/data-structures/index.d.ts +11 -0
  164. package/dist/types/data-structures/index.js +27 -0
  165. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
  166. package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
  167. package/dist/types/data-structures/linked-list/index.d.ts +2 -0
  168. package/dist/types/data-structures/linked-list/index.js +18 -0
  169. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
  170. package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
  171. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
  172. package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
  173. package/dist/types/data-structures/matrix/index.d.ts +1 -0
  174. package/dist/types/data-structures/matrix/index.js +17 -0
  175. package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
  176. package/dist/types/data-structures/matrix/matrix.js +2 -0
  177. package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
  178. package/dist/types/data-structures/matrix/matrix2d.js +2 -0
  179. package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
  180. package/dist/types/data-structures/matrix/navigator.js +2 -0
  181. package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
  182. package/dist/types/data-structures/matrix/vector2d.js +2 -0
  183. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  184. package/dist/types/data-structures/priority-queue/index.js +19 -0
  185. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  186. package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
  187. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  188. package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
  189. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  190. package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
  191. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  192. package/dist/types/data-structures/queue/deque.js +2 -0
  193. package/dist/types/data-structures/queue/index.d.ts +2 -0
  194. package/dist/types/data-structures/queue/index.js +18 -0
  195. package/dist/types/data-structures/queue/queue.d.ts +1 -0
  196. package/dist/types/data-structures/queue/queue.js +2 -0
  197. package/dist/types/data-structures/stack/index.d.ts +1 -0
  198. package/dist/types/data-structures/stack/index.js +17 -0
  199. package/dist/types/data-structures/stack/stack.d.ts +1 -0
  200. package/dist/types/data-structures/stack/stack.js +2 -0
  201. package/dist/types/data-structures/tree/index.d.ts +1 -0
  202. package/dist/types/data-structures/tree/index.js +17 -0
  203. package/dist/types/data-structures/tree/tree.d.ts +1 -0
  204. package/dist/types/data-structures/tree/tree.js +2 -0
  205. package/dist/types/data-structures/trie/index.d.ts +1 -0
  206. package/dist/types/data-structures/trie/index.js +17 -0
  207. package/dist/types/data-structures/trie/trie.d.ts +1 -0
  208. package/dist/types/data-structures/trie/trie.js +2 -0
  209. package/dist/types/helpers.d.ts +9 -0
  210. package/dist/types/helpers.js +9 -0
  211. package/dist/types/index.d.ts +3 -0
  212. package/dist/types/index.js +19 -0
  213. package/dist/types/utils/index.d.ts +2 -0
  214. package/dist/types/utils/index.js +18 -0
  215. package/dist/types/utils/utils.d.ts +7 -0
  216. package/dist/types/utils/utils.js +2 -0
  217. package/dist/types/utils/validate-type.d.ts +19 -0
  218. package/dist/types/utils/validate-type.js +2 -0
  219. package/dist/utils/index.d.ts +1 -0
  220. package/dist/utils/index.js +17 -0
  221. package/dist/utils/utils.d.ts +20 -0
  222. package/dist/utils/utils.js +73 -0
  223. package/package.json +1 -4
  224. package/src/data-structures/binary-tree/avl-tree.ts +342 -0
  225. package/src/data-structures/binary-tree/binary-indexed-tree.ts +298 -0
  226. package/src/data-structures/binary-tree/binary-tree.ts +1141 -0
  227. package/src/data-structures/binary-tree/bst.ts +529 -0
  228. package/src/data-structures/binary-tree/index.ts +7 -0
  229. package/src/data-structures/binary-tree/rb-tree.ts +366 -0
  230. package/src/data-structures/binary-tree/segment-tree.ts +257 -0
  231. package/src/data-structures/binary-tree/tree-multiset.ts +375 -0
  232. package/src/data-structures/graph/abstract-graph.ts +1044 -0
  233. package/src/data-structures/graph/directed-graph.ts +470 -0
  234. package/src/data-structures/graph/index.ts +4 -0
  235. package/src/data-structures/graph/map-graph.ts +134 -0
  236. package/src/data-structures/graph/undirected-graph.ts +274 -0
  237. package/src/data-structures/hash/coordinate-map.ts +67 -0
  238. package/src/data-structures/hash/coordinate-set.ts +56 -0
  239. package/src/data-structures/hash/hash-map.ts +209 -0
  240. package/src/data-structures/hash/hash-table.ts +280 -0
  241. package/src/data-structures/hash/index.ts +6 -0
  242. package/src/data-structures/hash/tree-map.ts +1 -0
  243. package/src/data-structures/hash/tree-set.ts +1 -0
  244. package/src/data-structures/heap/heap.ts +561 -0
  245. package/src/data-structures/heap/index.ts +3 -0
  246. package/src/data-structures/heap/max-heap.ts +24 -0
  247. package/src/data-structures/heap/min-heap.ts +24 -0
  248. package/src/data-structures/index.ts +11 -0
  249. package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
  250. package/src/data-structures/linked-list/index.ts +3 -0
  251. package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
  252. package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
  253. package/src/data-structures/matrix/index.ts +4 -0
  254. package/src/data-structures/matrix/matrix.ts +27 -0
  255. package/src/data-structures/matrix/matrix2d.ts +213 -0
  256. package/src/data-structures/matrix/navigator.ts +121 -0
  257. package/src/data-structures/matrix/vector2d.ts +316 -0
  258. package/src/data-structures/priority-queue/index.ts +3 -0
  259. package/src/data-structures/priority-queue/max-priority-queue.ts +23 -0
  260. package/src/data-structures/priority-queue/min-priority-queue.ts +23 -0
  261. package/src/data-structures/priority-queue/priority-queue.ts +16 -0
  262. package/src/data-structures/queue/deque.ts +297 -0
  263. package/src/data-structures/queue/index.ts +2 -0
  264. package/src/data-structures/queue/queue.ts +191 -0
  265. package/src/data-structures/stack/index.ts +1 -0
  266. package/src/data-structures/stack/stack.ts +98 -0
  267. package/src/data-structures/tree/index.ts +1 -0
  268. package/src/data-structures/tree/tree.ts +67 -0
  269. package/src/data-structures/trie/index.ts +1 -0
  270. package/src/data-structures/trie/trie.ts +286 -0
  271. package/src/index.ts +3 -3
  272. package/src/interfaces/binary-tree.ts +10 -0
  273. package/src/interfaces/doubly-linked-list.ts +1 -0
  274. package/src/interfaces/graph.ts +7 -0
  275. package/src/interfaces/heap.ts +1 -0
  276. package/src/interfaces/index.ts +8 -0
  277. package/src/interfaces/navigator.ts +1 -0
  278. package/src/interfaces/priority-queue.ts +1 -0
  279. package/src/interfaces/segment-tree.ts +1 -0
  280. package/src/interfaces/singly-linked-list.ts +1 -0
  281. package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
  282. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  283. package/src/types/data-structures/binary-tree/binary-tree.ts +35 -0
  284. package/src/types/data-structures/binary-tree/bst.ts +11 -0
  285. package/src/types/data-structures/binary-tree/index.ts +6 -0
  286. package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
  287. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
  288. package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
  289. package/src/types/data-structures/graph/abstract-graph.ts +11 -0
  290. package/src/types/data-structures/graph/directed-graph.ts +8 -0
  291. package/src/types/data-structures/graph/index.ts +3 -0
  292. package/src/types/data-structures/graph/map-graph.ts +1 -0
  293. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  294. package/src/types/data-structures/hash/coordinate-map.ts +1 -0
  295. package/src/types/data-structures/hash/coordinate-set.ts +1 -0
  296. package/src/types/data-structures/hash/hash-map.ts +1 -0
  297. package/src/types/data-structures/hash/hash-table.ts +1 -0
  298. package/src/types/data-structures/hash/index.ts +1 -0
  299. package/src/types/data-structures/hash/tree-map.ts +1 -0
  300. package/src/types/data-structures/hash/tree-set.ts +1 -0
  301. package/src/types/data-structures/heap/heap.ts +1 -0
  302. package/src/types/data-structures/heap/index.ts +1 -0
  303. package/src/types/data-structures/heap/max-heap.ts +1 -0
  304. package/src/types/data-structures/heap/min-heap.ts +1 -0
  305. package/src/types/data-structures/index.ts +11 -0
  306. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
  307. package/src/types/data-structures/linked-list/index.ts +2 -0
  308. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
  309. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  310. package/src/types/data-structures/matrix/index.ts +1 -0
  311. package/src/types/data-structures/matrix/matrix.ts +1 -0
  312. package/src/types/data-structures/matrix/matrix2d.ts +1 -0
  313. package/src/types/data-structures/matrix/navigator.ts +14 -0
  314. package/src/types/data-structures/matrix/vector2d.ts +1 -0
  315. package/src/types/data-structures/priority-queue/index.ts +3 -0
  316. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  317. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  318. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  319. package/src/types/data-structures/queue/deque.ts +1 -0
  320. package/src/types/data-structures/queue/index.ts +2 -0
  321. package/src/types/data-structures/queue/queue.ts +1 -0
  322. package/src/types/data-structures/stack/index.ts +1 -0
  323. package/src/types/data-structures/stack/stack.ts +1 -0
  324. package/src/types/data-structures/tree/index.ts +1 -0
  325. package/src/types/data-structures/tree/tree.ts +1 -0
  326. package/src/types/data-structures/trie/index.ts +1 -0
  327. package/src/types/data-structures/trie/trie.ts +1 -0
  328. package/src/types/helpers.ts +13 -0
  329. package/src/types/index.ts +3 -0
  330. package/src/types/utils/index.ts +2 -0
  331. package/src/types/utils/utils.ts +6 -0
  332. package/src/types/utils/validate-type.ts +35 -0
  333. package/src/utils/index.ts +1 -0
  334. package/src/utils/utils.ts +86 -0
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Queue = exports.LinkedListQueue = void 0;
4
+ /**
5
+ * @license MIT
6
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
7
+ * @class
8
+ */
9
+ const linked_list_1 = require("../linked-list");
10
+ class LinkedListQueue extends linked_list_1.SinglyLinkedList {
11
+ /**
12
+ * The enqueue function adds a value to the end of an array.
13
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
14
+ */
15
+ enqueue(value) {
16
+ this.push(value);
17
+ }
18
+ /**
19
+ * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
20
+ * @returns The method is returning the element at the front of the queue, or null if the queue is empty.
21
+ */
22
+ dequeue() {
23
+ return this.shift();
24
+ }
25
+ /**
26
+ * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
27
+ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
28
+ */
29
+ peek() {
30
+ var _a;
31
+ return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
32
+ }
33
+ }
34
+ exports.LinkedListQueue = LinkedListQueue;
35
+ class Queue {
36
+ /**
37
+ * The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
38
+ * @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
39
+ * will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be
40
+ * initialized as an empty array.
41
+ */
42
+ constructor(elements) {
43
+ this._nodes = elements || [];
44
+ this._offset = 0;
45
+ }
46
+ get nodes() {
47
+ return this._nodes;
48
+ }
49
+ set nodes(value) {
50
+ this._nodes = value;
51
+ }
52
+ get offset() {
53
+ return this._offset;
54
+ }
55
+ set offset(value) {
56
+ this._offset = value;
57
+ }
58
+ /**
59
+ * The size function returns the number of elements in an array.
60
+ * @returns {number} The size of the array, which is the difference between the length of the array and the offset.
61
+ */
62
+ get size() {
63
+ return this.nodes.length - this.offset;
64
+ }
65
+ /**
66
+ * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
67
+ * @public
68
+ * @static
69
+ * @param {E[]} elements - The "elements" parameter is an array of elements of type E.
70
+ * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
71
+ * array.
72
+ */
73
+ static fromArray(elements) {
74
+ return new Queue(elements);
75
+ }
76
+ /**
77
+ * 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.
78
+ * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
79
+ * @returns The `add` method is returning a `Queue<E>` object.
80
+ */
81
+ push(element) {
82
+ this.nodes.push(element);
83
+ return this;
84
+ }
85
+ /**
86
+ * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
87
+ * necessary to optimize performance.
88
+ * @returns The function `shift()` returns either the first element in the queue or `null` if the queue is empty.
89
+ */
90
+ shift() {
91
+ if (this.size === 0)
92
+ return undefined;
93
+ const first = this.peek();
94
+ this.offset += 1;
95
+ if (this.offset * 2 < this.nodes.length)
96
+ return first;
97
+ // only delete dequeued elements when reaching half size
98
+ // to decrease latency of shifting elements.
99
+ this.nodes = this.nodes.slice(this.offset);
100
+ this.offset = 0;
101
+ return first;
102
+ }
103
+ /**
104
+ * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
105
+ * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
106
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
107
+ */
108
+ peek() {
109
+ return this.size > 0 ? this.nodes[this.offset] : undefined;
110
+ }
111
+ /**
112
+ * The `peekLast` function returns the last element in an array-like data structure, or null if the structure is empty.
113
+ * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
114
+ * array is empty, it returns `null`.
115
+ */
116
+ peekLast() {
117
+ return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
118
+ }
119
+ /**
120
+ * The enqueue function adds a value to the end of a queue.
121
+ * @param {E} value - The value parameter represents the value that you want to add to the queue.
122
+ */
123
+ enqueue(value) {
124
+ this.push(value);
125
+ }
126
+ /**
127
+ * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
128
+ * @returns The method is returning a value of type E or null.
129
+ */
130
+ dequeue() {
131
+ return this.shift();
132
+ }
133
+ getAt(index) {
134
+ return this.nodes[index];
135
+ }
136
+ /**
137
+ * The function checks if a data structure is empty by comparing its size to zero.
138
+ * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
139
+ */
140
+ isEmpty() {
141
+ return this.size === 0;
142
+ }
143
+ /**
144
+ * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
145
+ * @returns An array of type E is being returned.
146
+ */
147
+ toArray() {
148
+ return this.nodes.slice(this.offset);
149
+ }
150
+ /**
151
+ * The clear function resets the nodes array and offset to their initial values.
152
+ */
153
+ clear() {
154
+ this.nodes = [];
155
+ this.offset = 0;
156
+ }
157
+ /**
158
+ * The `clone()` function returns a new Queue object with the same elements as the original Queue.
159
+ * @returns The `clone()` method is returning a new instance of the `Queue` class.
160
+ */
161
+ clone() {
162
+ return new Queue(this.nodes.slice(this.offset));
163
+ }
164
+ *[Symbol.iterator]() {
165
+ for (const item of this.nodes) {
166
+ yield item;
167
+ }
168
+ }
169
+ }
170
+ exports.Queue = Queue;
@@ -0,0 +1 @@
1
+ export * from './stack';
@@ -0,0 +1,17 @@
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("./stack"), exports);
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license MIT
3
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
4
+ * @class
5
+ */
6
+ export declare class Stack<E = any> {
7
+ protected _elements: E[];
8
+ /**
9
+ * The constructor initializes an array of elements, which can be provided as an optional parameter.
10
+ * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
11
+ * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
12
+ * is provided and is an array, it is assigned to the `_elements
13
+ */
14
+ constructor(elements?: E[]);
15
+ /**
16
+ * The function "fromArray" creates a new Stack object from an array of elements.
17
+ * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
18
+ * @returns {Stack} The method is returning a new instance of the Stack class, initialized with the elements from the input
19
+ * array.
20
+ */
21
+ static fromArray<E>(elements: E[]): Stack<E>;
22
+ /**
23
+ * The function checks if an array is empty and returns a boolean value.
24
+ * @returns A boolean value indicating whether the `_elements` array is empty or not.
25
+ */
26
+ isEmpty(): boolean;
27
+ /**
28
+ * The size() function returns the number of elements in an array.
29
+ * @returns The size of the elements array.
30
+ */
31
+ size(): number;
32
+ /**
33
+ * The `peek` function returns the last element of an array, or null if the array is empty.
34
+ * @returns The `peek()` function returns the last element of the `_elements` array, or `null` if the array is empty.
35
+ */
36
+ peek(): E | null;
37
+ /**
38
+ * The push function adds an element to the stack and returns the updated stack.
39
+ * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
40
+ * @returns The `push` method is returning the updated `Stack<E>` object.
41
+ */
42
+ push(element: E): Stack<E>;
43
+ /**
44
+ * The `pop` function removes and returns the last element from an array, or returns null if the array is empty.
45
+ * @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
46
+ * array is empty, it returns `null`.
47
+ */
48
+ pop(): E | null;
49
+ /**
50
+ * The toArray function returns a copy of the elements in an array.
51
+ * @returns An array of type E.
52
+ */
53
+ toArray(): E[];
54
+ /**
55
+ * The clear function clears the elements array.
56
+ */
57
+ clear(): void;
58
+ /**
59
+ * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
60
+ * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
61
+ */
62
+ clone(): Stack<E>;
63
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stack = void 0;
4
+ /**
5
+ * @license MIT
6
+ * @copyright Tyler Zeng <zrwusa@gmail.com>
7
+ * @class
8
+ */
9
+ class Stack {
10
+ /**
11
+ * The constructor initializes an array of elements, which can be provided as an optional parameter.
12
+ * @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
13
+ * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
14
+ * is provided and is an array, it is assigned to the `_elements
15
+ */
16
+ constructor(elements) {
17
+ this._elements = Array.isArray(elements) ? elements : [];
18
+ }
19
+ /**
20
+ * The function "fromArray" creates a new Stack object from an array of elements.
21
+ * @param {E[]} elements - The `elements` parameter is an array of elements of type `E`.
22
+ * @returns {Stack} The method is returning a new instance of the Stack class, initialized with the elements from the input
23
+ * array.
24
+ */
25
+ static fromArray(elements) {
26
+ return new Stack(elements);
27
+ }
28
+ /**
29
+ * The function checks if an array is empty and returns a boolean value.
30
+ * @returns A boolean value indicating whether the `_elements` array is empty or not.
31
+ */
32
+ isEmpty() {
33
+ return this._elements.length === 0;
34
+ }
35
+ /**
36
+ * The size() function returns the number of elements in an array.
37
+ * @returns The size of the elements array.
38
+ */
39
+ size() {
40
+ return this._elements.length;
41
+ }
42
+ /**
43
+ * The `peek` function returns the last element of an array, or null if the array is empty.
44
+ * @returns The `peek()` function returns the last element of the `_elements` array, or `null` if the array is empty.
45
+ */
46
+ peek() {
47
+ if (this.isEmpty())
48
+ return null;
49
+ return this._elements[this._elements.length - 1];
50
+ }
51
+ /**
52
+ * The push function adds an element to the stack and returns the updated stack.
53
+ * @param {E} element - The parameter "element" is of type E, which means it can be any data type.
54
+ * @returns The `push` method is returning the updated `Stack<E>` object.
55
+ */
56
+ push(element) {
57
+ this._elements.push(element);
58
+ return this;
59
+ }
60
+ /**
61
+ * The `pop` function removes and returns the last element from an array, or returns null if the array is empty.
62
+ * @returns The `pop()` method is returning the last element of the array `_elements` if the array is not empty. If the
63
+ * array is empty, it returns `null`.
64
+ */
65
+ pop() {
66
+ if (this.isEmpty())
67
+ return null;
68
+ return this._elements.pop() || null;
69
+ }
70
+ /**
71
+ * The toArray function returns a copy of the elements in an array.
72
+ * @returns An array of type E.
73
+ */
74
+ toArray() {
75
+ return this._elements.slice();
76
+ }
77
+ /**
78
+ * The clear function clears the elements array.
79
+ */
80
+ clear() {
81
+ this._elements = [];
82
+ }
83
+ /**
84
+ * The `clone()` function returns a new `Stack` object with the same elements as the original stack.
85
+ * @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
86
+ */
87
+ clone() {
88
+ return new Stack(this._elements.slice());
89
+ }
90
+ }
91
+ exports.Stack = Stack;
@@ -0,0 +1 @@
1
+ export * from './tree';
@@ -0,0 +1,17 @@
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("./tree"), exports);
@@ -0,0 +1,14 @@
1
+ export declare class TreeNode<V = any> {
2
+ constructor(key: string, value?: V, children?: TreeNode<V>[]);
3
+ private _key;
4
+ get key(): string;
5
+ set key(value: string);
6
+ private _value?;
7
+ get value(): V | undefined;
8
+ set value(value: V | undefined);
9
+ private _children?;
10
+ get children(): TreeNode<V>[] | undefined;
11
+ set children(value: TreeNode<V>[] | undefined);
12
+ addChildren(children: TreeNode<V> | TreeNode<V>[]): void;
13
+ getHeight(): number;
14
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TreeNode = void 0;
4
+ class TreeNode {
5
+ constructor(key, value, children) {
6
+ this._key = key;
7
+ this._value = value || undefined;
8
+ this._children = children || [];
9
+ }
10
+ get key() {
11
+ return this._key;
12
+ }
13
+ set key(value) {
14
+ this._key = value;
15
+ }
16
+ get value() {
17
+ return this._value;
18
+ }
19
+ set value(value) {
20
+ this._value = value;
21
+ }
22
+ get children() {
23
+ return this._children;
24
+ }
25
+ set children(value) {
26
+ this._children = value;
27
+ }
28
+ addChildren(children) {
29
+ if (!this.children) {
30
+ this.children = [];
31
+ }
32
+ if (children instanceof TreeNode) {
33
+ this.children.push(children);
34
+ }
35
+ else {
36
+ this.children = this.children.concat(children);
37
+ }
38
+ }
39
+ getHeight() {
40
+ let maxDepth = 0;
41
+ if (this) {
42
+ const bfs = (node, level) => {
43
+ if (level > maxDepth) {
44
+ maxDepth = level;
45
+ }
46
+ const { children } = node;
47
+ if (children) {
48
+ for (let i = 0, len = children.length; i < len; i++) {
49
+ bfs(children[i], level + 1);
50
+ }
51
+ }
52
+ };
53
+ bfs(this, 0);
54
+ }
55
+ return maxDepth;
56
+ }
57
+ }
58
+ exports.TreeNode = TreeNode;
@@ -0,0 +1 @@
1
+ export * from './trie';
@@ -0,0 +1,17 @@
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("./trie"), exports);
@@ -0,0 +1,84 @@
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
+ /**
9
+ * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
10
+ * and a flag indicating whether it's the end of a word.
11
+ */
12
+ export declare class TrieNode {
13
+ constructor(key: string);
14
+ private _key;
15
+ get key(): string;
16
+ set key(v: string);
17
+ protected _children: Map<string, TrieNode>;
18
+ get children(): Map<string, TrieNode>;
19
+ set children(v: Map<string, TrieNode>);
20
+ protected _isEnd: boolean;
21
+ get isEnd(): boolean;
22
+ set isEnd(v: boolean);
23
+ }
24
+ /**
25
+ * Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
26
+ */
27
+ export declare class Trie {
28
+ private readonly _caseSensitive;
29
+ constructor(words?: string[], caseSensitive?: boolean);
30
+ protected _root: TrieNode;
31
+ get root(): TrieNode;
32
+ set root(v: TrieNode);
33
+ /**
34
+ * Add a word to the Trie structure.
35
+ * @param {string} word - The word to add.
36
+ * @returns {boolean} True if the word was successfully added.
37
+ */
38
+ add(word: string): boolean;
39
+ /**
40
+ * Check if the Trie contains a given word.
41
+ * @param {string} word - The word to check for.
42
+ * @returns {boolean} True if the word is present in the Trie.
43
+ */
44
+ has(word: string): boolean;
45
+ /**
46
+ * Remove a word from the Trie structure.
47
+ * @param{string} word - The word to delete.
48
+ * @returns {boolean} True if the word was successfully removed.
49
+ */
50
+ delete(word: string): boolean;
51
+ getHeight(): number;
52
+ /**
53
+ * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
54
+ * @param {string} input - The input string to check.
55
+ * @returns {boolean} True if it's an absolute prefix in the Trie.
56
+ */
57
+ hasPurePrefix(input: string): boolean;
58
+ /**
59
+ * Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
60
+ * @param {string} input - The input string representing the prefix to check.
61
+ * @returns {boolean} True if it's a prefix in the Trie.
62
+ */
63
+ hasPrefix(input: string): boolean;
64
+ /**
65
+ * Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
66
+ * @param {string} input - The input string representing the common prefix to check for.
67
+ * @returns {boolean} True if it's a common prefix in the Trie.
68
+ */
69
+ hasCommonPrefix(input: string): boolean;
70
+ /**
71
+ * Get the longest common prefix among all the words stored in the Trie.
72
+ * @returns {string} The longest common prefix found in the Trie.
73
+ */
74
+ getLongestCommonPrefix(): string;
75
+ /**
76
+ * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
77
+ * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
78
+ * trie. It is an optional parameter, so if no prefix is provided, it will default to an empty string.
79
+ * @param {number} max - The max count of words will be found
80
+ * @returns {string[]} an array of strings.
81
+ */
82
+ getWords(prefix?: string, max?: number): string[];
83
+ private _caseProcess;
84
+ }