priority-queue-typed 1.40.0-rc → 1.41.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 +23 -3
  5. package/coverage/clover.xml +11 -7
  6. package/coverage/coverage-final.json +130 -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 +38 -36
  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 +363 -0
  17. package/dist/data-structures/binary-tree/binary-tree.js +1135 -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 +97 -0
  23. package/dist/data-structures/binary-tree/rb-tree.js +388 -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 -5
  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 +4 -0
  137. package/dist/types/data-structures/binary-tree/rb-tree.js +13 -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 +1284 -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 +426 -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
@@ -1,63 +1,63 @@
1
-
2
1
  <!doctype html>
3
2
  <html lang="en">
4
3
 
5
4
  <head>
6
5
  <title>Code coverage report for index.ts</title>
7
- <meta charset="utf-8" />
8
- <link rel="stylesheet" href="prettify.css" />
9
- <link rel="stylesheet" href="base.css" />
10
- <link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
11
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta charset="utf-8"/>
7
+ <link href="prettify.css" rel="stylesheet"/>
8
+ <link href="base.css" rel="stylesheet"/>
9
+ <link href="favicon.png" rel="shortcut icon" type="image/x-icon"/>
10
+ <meta content="width=device-width, initial-scale=1" name="viewport"/>
12
11
  <style type='text/css'>
13
12
  .coverage-summary .sorter {
14
13
  background-image: url(sort-arrow-sprite.png);
15
14
  }
16
15
  </style>
17
16
  </head>
18
-
17
+
19
18
  <body>
20
19
  <div class='wrapper'>
21
20
  <div class='pad1'>
22
21
  <h1><a href="index.html">All files</a> index.ts</h1>
23
22
  <div class='clearfix'>
24
-
23
+
25
24
  <div class='fl pad1y space-right2'>
26
25
  <span class="strong">100% </span>
27
26
  <span class="quiet">Statements</span>
28
27
  <span class='fraction'>4/4</span>
29
28
  </div>
30
-
31
-
29
+
30
+
32
31
  <div class='fl pad1y space-right2'>
33
32
  <span class="strong">100% </span>
34
33
  <span class="quiet">Branches</span>
35
34
  <span class='fraction'>0/0</span>
36
35
  </div>
37
-
38
-
36
+
37
+
39
38
  <div class='fl pad1y space-right2'>
40
39
  <span class="strong">33.33% </span>
41
40
  <span class="quiet">Functions</span>
42
41
  <span class='fraction'>1/3</span>
43
42
  </div>
44
-
45
-
43
+
44
+
46
45
  <div class='fl pad1y space-right2'>
47
46
  <span class="strong">100% </span>
48
47
  <span class="quiet">Lines</span>
49
48
  <span class='fraction'>1/1</span>
50
49
  </div>
51
-
52
-
50
+
51
+
53
52
  </div>
54
53
  <p class="quiet">
55
- Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
54
+ Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for
55
+ the previous block.
56
56
  </p>
57
57
  <template id="filterTemplate">
58
58
  <div class="quiet">
59
59
  Filter:
60
- <input oninput="onInput()" type="search" id="fileSearch">
60
+ <input id="fileSearch" oninput="onInput()" type="search">
61
61
  </div>
62
62
  </template>
63
63
  </div>
@@ -71,7 +71,8 @@
71
71
  <a name='L6'></a><a href='#L6'>6</a>
72
72
  <a name='L7'></a><a href='#L7'>7</a>
73
73
  <a name='L8'></a><a href='#L8'>8</a>
74
- <a name='L9'></a><a href='#L9'>9</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
74
+ <a name='L9'></a><a href='#L9'>9</a></td><td class="line-coverage quiet"><span
75
+ class="cline-any cline-neutral">&nbsp;</span>
75
76
  <span class="cline-any cline-neutral">&nbsp;</span>
76
77
  <span class="cline-any cline-neutral">&nbsp;</span>
77
78
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -86,24 +87,25 @@
86
87
  * @copyright Copyright (c) 2022 Tyler Zeng &lt;zrwusa@gmail.com&gt;
87
88
  * @license MIT License
88
89
  */
89
- export { PriorityQueue, <span class="fstat-no" title="function not covered" >MaxPriorityQueue,</span> <span class="fstat-no" title="function not covered" >MinPriorityQueue </span>} from 'data-structure-typed';
90
+ export { PriorityQueue, <span class="fstat-no" title="function not covered">MaxPriorityQueue,</span> <span
91
+ class="fstat-no" title="function not covered">MinPriorityQueue </span>} from 'data-structure-typed';
90
92
  &nbsp;</pre></td></tr></table></pre>
91
93
 
92
- <div class='push'></div><!-- for sticky footer -->
93
- </div><!-- /wrapper -->
94
- <div class='footer quiet pad2 space-top1 center small'>
95
- Code coverage generated by
96
- <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
97
- at 2023-10-08T10:23:29.918Z
98
- </div>
99
- <script src="prettify.js"></script>
100
- <script>
101
- window.onload = function () {
102
- prettyPrint();
103
- };
104
- </script>
105
- <script src="sorter.js"></script>
106
- <script src="block-navigation.js"></script>
107
- </body>
94
+ <div class='push'></div><!-- for sticky footer -->
95
+ </div><!-- /wrapper -->
96
+ <div class='footer quiet pad2 space-top1 center small'>
97
+ Code coverage generated by
98
+ <a href="https://istanbul.js.org/" rel="noopener noreferrer" target="_blank">istanbul</a>
99
+ at 2023-10-08T10:23:29.918Z
100
+ </div>
101
+ <script src="prettify.js"></script>
102
+ <script>
103
+ window.onload = function () {
104
+ prettyPrint();
105
+ };
106
+ </script>
107
+ <script src="sorter.js"></script>
108
+ <script src="block-navigation.js"></script>
109
+ </body>
108
110
  </html>
109
111
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- var addSorting = (function() {
2
+ var addSorting = (function () {
3
3
  'use strict';
4
4
  var cols,
5
5
  currentSort = {
@@ -11,14 +11,17 @@ var addSorting = (function() {
11
11
  function getTable() {
12
12
  return document.querySelector('.coverage-summary');
13
13
  }
14
+
14
15
  // returns the thead element of the summary table
15
16
  function getTableHeader() {
16
17
  return getTable().querySelector('thead tr');
17
18
  }
19
+
18
20
  // returns the tbody element of the summary table
19
21
  function getTableBody() {
20
22
  return getTable().querySelector('tbody');
21
23
  }
24
+
22
25
  // returns the th element for nth column
23
26
  function getNthColumn(n) {
24
27
  return getTableHeader().querySelectorAll('th')[n];
@@ -73,6 +76,7 @@ var addSorting = (function() {
73
76
  }
74
77
  return cols;
75
78
  }
79
+
76
80
  // attaches a data attribute to every tr element with an object
77
81
  // of data values keyed by column name
78
82
  function loadRowData(tableRow) {
@@ -93,6 +97,7 @@ var addSorting = (function() {
93
97
  }
94
98
  return data;
95
99
  }
100
+
96
101
  // loads all row data
97
102
  function loadData() {
98
103
  var rows = getTableBody().querySelectorAll('tr'),
@@ -102,10 +107,11 @@ var addSorting = (function() {
102
107
  rows[i].data = loadRowData(rows[i]);
103
108
  }
104
109
  }
110
+
105
111
  // sorts the table using the data for the ith column
106
112
  function sortByIndex(index, desc) {
107
113
  var key = cols[index].key,
108
- sorter = function(a, b) {
114
+ sorter = function (a, b) {
109
115
  a = a.data[key];
110
116
  b = b.data[key];
111
117
  return a < b ? -1 : a > b ? 1 : 0;
@@ -117,7 +123,7 @@ var addSorting = (function() {
117
123
  i;
118
124
 
119
125
  if (desc) {
120
- finalSorter = function(a, b) {
126
+ finalSorter = function (a, b) {
121
127
  return -1 * sorter(a, b);
122
128
  };
123
129
  }
@@ -133,6 +139,7 @@ var addSorting = (function() {
133
139
  tableBody.appendChild(rows[i]);
134
140
  }
135
141
  }
142
+
136
143
  // removes sort indicators for current column being sorted
137
144
  function removeSortIndicators() {
138
145
  var col = getNthColumn(currentSort.index),
@@ -141,12 +148,14 @@ var addSorting = (function() {
141
148
  cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
142
149
  col.className = cls;
143
150
  }
151
+
144
152
  // adds sort indicators for current column being sorted
145
153
  function addSortIndicators() {
146
154
  getNthColumn(currentSort.index).className += currentSort.desc
147
155
  ? ' sorted-desc'
148
156
  : ' sorted';
149
157
  }
158
+
150
159
  // adds event listeners for all sorter widgets
151
160
  function enableUI() {
152
161
  var i,
@@ -154,7 +163,7 @@ var addSorting = (function() {
154
163
  ithSorter = function ithSorter(i) {
155
164
  var col = cols[i];
156
165
 
157
- return function() {
166
+ return function () {
158
167
  var desc = col.defaultDescSort;
159
168
 
160
169
  if (currentSort.index === i) {
@@ -180,8 +189,9 @@ var addSorting = (function() {
180
189
  }
181
190
  }
182
191
  }
192
+
183
193
  // adds sorting functionality to the UI
184
- return function() {
194
+ return function () {
185
195
  if (!getTable()) {
186
196
  return;
187
197
  }
@@ -0,0 +1,106 @@
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 { BST, BSTNode } from './bst';
9
+ import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BTNKey } from '../../types';
10
+ import { BTNCallback } from '../../types';
11
+ import { IBinaryTree } from '../../interfaces';
12
+ export declare class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNested<V>> extends BSTNode<V, N> {
13
+ height: number;
14
+ constructor(key: BTNKey, value?: V);
15
+ }
16
+ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
17
+ /**
18
+ * This is a constructor function for an AVL tree data structure in TypeScript.
19
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
20
+ * constructor of the AVLTree class. It allows you to customize the behavior of the AVL tree by providing different
21
+ * options.
22
+ */
23
+ constructor(options?: AVLTreeOptions);
24
+ /**
25
+ * The function creates a new AVL tree node with the specified key and value.
26
+ * @param {BTNKey} key - The key parameter is the key value that will be associated with
27
+ * the new node. It is used to determine the position of the node in the binary search tree.
28
+ * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
29
+ * type `V`, which means it can be any value that is assignable to the `value` property of the
30
+ * node type `N`.
31
+ * @returns a new AVLTreeNode object with the specified key and value.
32
+ */
33
+ createNode(key: BTNKey, value?: V): N;
34
+ /**
35
+ * The function overrides the add method of a binary tree node and balances the tree after inserting
36
+ * a new node.
37
+ * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
38
+ * `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
39
+ * @param [value] - The `value` parameter is the value that you want to assign to the new node that you
40
+ * are adding to the binary search tree.
41
+ * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
42
+ */
43
+ add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
44
+ /**
45
+ * The function overrides the delete method of a binary tree and balances the tree after deleting a
46
+ * node if necessary.
47
+ * @param {ReturnType<C>} identifier - The `identifier` parameter is either a
48
+ * `BTNKey` or a generic type `N`. It represents the property of the node that we are
49
+ * searching for. It can be a specific key value or any other property of the node.
50
+ * @param callback - The `callback` parameter is a function that takes a node as input and returns a
51
+ * value. This value is compared with the `identifier` parameter to determine if the node should be
52
+ * included in the result. The `callback` parameter has a default value of
53
+ * `((node: N) => node.key)`
54
+ * @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
55
+ */
56
+ delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeletedResult<N>[];
57
+ /**
58
+ * The function swaps the key, value, and height properties between two nodes in a binary tree.
59
+ * @param {N} srcNode - The `srcNode` parameter represents the source node that needs to be swapped
60
+ * with the `destNode`.
61
+ * @param {N} destNode - The `destNode` parameter represents the destination node where the values
62
+ * from the source node (`srcNode`) will be swapped to.
63
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
64
+ */
65
+ protected _swap(srcNode: N, destNode: N): N;
66
+ /**
67
+ * The function calculates the balance factor of a node in a binary tree.
68
+ * @param {N} node - The parameter "node" represents a node in a binary tree data structure.
69
+ * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
70
+ * height of the left subtree from the height of the right subtree.
71
+ */
72
+ protected _balanceFactor(node: N): number;
73
+ /**
74
+ * The function updates the height of a node in a binary tree based on the heights of its left and
75
+ * right children.
76
+ * @param {N} node - The parameter "node" represents a node in a binary tree data structure.
77
+ */
78
+ protected _updateHeight(node: N): void;
79
+ /**
80
+ * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
81
+ * to restore balance in an AVL tree after inserting a node.
82
+ * @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
83
+ * AVL tree that needs to be balanced.
84
+ */
85
+ protected _balancePath(node: N): void;
86
+ /**
87
+ * The function `_balanceLL` performs a left-left rotation to balance a binary tree.
88
+ * @param {N} A - A is a node in a binary tree.
89
+ */
90
+ protected _balanceLL(A: N): void;
91
+ /**
92
+ * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
93
+ * @param {N} A - A is a node in a binary tree.
94
+ */
95
+ protected _balanceLR(A: N): void;
96
+ /**
97
+ * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
98
+ * @param {N} A - A is a node in a binary tree.
99
+ */
100
+ protected _balanceRR(A: N): void;
101
+ /**
102
+ * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
103
+ * @param {N} A - A is a node in a binary tree.
104
+ */
105
+ protected _balanceRL(A: N): void;
106
+ }