data-structure-typed 2.0.5 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (785) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/COMMANDS.md +27 -0
  3. package/README.md +5 -34
  4. package/benchmark/report.html +13 -77
  5. package/benchmark/report.json +152 -184
  6. package/dist/cjs/index.cjs +13062 -0
  7. package/dist/cjs/index.cjs.map +1 -0
  8. package/dist/esm/index.mjs +12984 -0
  9. package/dist/esm/index.mjs.map +1 -0
  10. package/dist/index.cjs +13091 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.js +13013 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
  15. package/dist/types/data-structures/base/iterable-entry-base.d.ts +144 -0
  16. package/dist/types/data-structures/base/linear-base.d.ts +335 -0
  17. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -0
  18. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -0
  19. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -0
  20. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -0
  21. package/dist/types/data-structures/binary-tree/bst.d.ts +413 -0
  22. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -0
  23. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -0
  24. package/dist/{esm → types}/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  25. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
  26. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -0
  27. package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
  28. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -0
  29. package/dist/types/data-structures/hash/hash-map.d.ts +345 -0
  30. package/dist/types/data-structures/heap/heap.d.ts +503 -0
  31. package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
  32. package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
  33. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -0
  34. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -0
  35. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
  36. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
  37. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
  38. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
  39. package/dist/types/data-structures/queue/deque.d.ts +431 -0
  40. package/dist/types/data-structures/queue/queue.d.ts +308 -0
  41. package/dist/{cjs → types}/data-structures/stack/stack.d.ts +124 -102
  42. package/dist/types/data-structures/trie/trie.d.ts +350 -0
  43. package/dist/types/interfaces/binary-tree.d.ts +59 -0
  44. package/dist/types/interfaces/graph.d.ts +21 -0
  45. package/dist/{cjs → types}/types/data-structures/base/base.d.ts +1 -1
  46. package/dist/{esm → types}/types/data-structures/graph/abstract-graph.d.ts +4 -0
  47. package/dist/{cjs → types}/types/utils/utils.d.ts +1 -0
  48. package/dist/{esm → types}/utils/utils.d.ts +1 -1
  49. package/dist/umd/data-structure-typed.js +4693 -6484
  50. package/dist/umd/data-structure-typed.js.map +1 -0
  51. package/dist/umd/data-structure-typed.min.js +8 -6
  52. package/dist/umd/data-structure-typed.min.js.map +1 -1
  53. package/jest.integration.config.js +3 -0
  54. package/package.json +13 -12
  55. package/src/data-structures/base/iterable-element-base.ts +238 -115
  56. package/src/data-structures/base/iterable-entry-base.ts +96 -120
  57. package/src/data-structures/base/linear-base.ts +271 -277
  58. package/src/data-structures/binary-tree/avl-tree-counter.ts +196 -217
  59. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +188 -102
  60. package/src/data-structures/binary-tree/avl-tree.ts +237 -206
  61. package/src/data-structures/binary-tree/binary-tree.ts +665 -896
  62. package/src/data-structures/binary-tree/bst.ts +565 -572
  63. package/src/data-structures/binary-tree/red-black-tree.ts +157 -223
  64. package/src/data-structures/binary-tree/tree-counter.ts +195 -219
  65. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -98
  66. package/src/data-structures/graph/abstract-graph.ts +339 -264
  67. package/src/data-structures/graph/directed-graph.ts +146 -236
  68. package/src/data-structures/graph/map-graph.ts +63 -60
  69. package/src/data-structures/graph/undirected-graph.ts +129 -152
  70. package/src/data-structures/hash/hash-map.ts +274 -496
  71. package/src/data-structures/heap/heap.ts +389 -402
  72. package/src/data-structures/heap/max-heap.ts +12 -76
  73. package/src/data-structures/heap/min-heap.ts +13 -76
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
  75. package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
  76. package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
  78. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
  79. package/src/data-structures/priority-queue/priority-queue.ts +3 -92
  80. package/src/data-structures/queue/deque.ts +381 -357
  81. package/src/data-structures/queue/queue.ts +310 -264
  82. package/src/data-structures/stack/stack.ts +217 -131
  83. package/src/data-structures/trie/trie.ts +240 -175
  84. package/src/interfaces/binary-tree.ts +240 -6
  85. package/src/interfaces/graph.ts +37 -0
  86. package/src/types/data-structures/base/base.ts +5 -5
  87. package/src/types/data-structures/graph/abstract-graph.ts +5 -0
  88. package/src/types/utils/utils.ts +2 -0
  89. package/src/utils/utils.ts +9 -14
  90. package/test/integration/all-in-one.test.ts +1 -1
  91. package/test/integration/index.html +1 -1
  92. package/test/performance/benchmark-runner.ts +528 -0
  93. package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
  94. package/test/performance/reportor.mjs +43 -43
  95. package/test/performance/runner-config.json +39 -0
  96. package/test/performance/single-suite-runner.ts +69 -0
  97. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +3 -3
  98. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +5 -5
  99. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
  100. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +350 -90
  101. package/test/unit/data-structures/binary-tree/bst.test.ts +12 -9
  102. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +2 -2
  103. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +25 -24
  104. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +112 -4
  105. package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -4
  106. package/test/unit/data-structures/graph/directed-graph.test.ts +1 -1
  107. package/test/unit/data-structures/heap/heap.test.ts +14 -21
  108. package/test/unit/data-structures/heap/max-heap.test.ts +5 -9
  109. package/test/unit/data-structures/heap/min-heap.test.ts +1 -4
  110. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +14 -14
  111. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -7
  112. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +8 -11
  113. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -4
  114. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +1 -4
  115. package/test/unit/data-structures/queue/queue.test.ts +4 -5
  116. package/test/unit/utils/utils.test.ts +0 -1
  117. package/tsconfig-base.json +20 -20
  118. package/tsconfig-types.json +17 -0
  119. package/tsconfig.test.json +8 -0
  120. package/tsup.config.js +11 -22
  121. package/tsup.node.config.ts +37 -0
  122. package/dist/cjs/common/index.js +0 -29
  123. package/dist/cjs/common/index.js.map +0 -1
  124. package/dist/cjs/data-structures/base/index.js +0 -19
  125. package/dist/cjs/data-structures/base/index.js.map +0 -1
  126. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +0 -116
  127. package/dist/cjs/data-structures/base/iterable-element-base.js +0 -202
  128. package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
  129. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +0 -168
  130. package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -241
  131. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
  132. package/dist/cjs/data-structures/base/linear-base.d.ts +0 -277
  133. package/dist/cjs/data-structures/base/linear-base.js +0 -553
  134. package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
  135. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +0 -214
  136. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -409
  137. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  138. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -104
  139. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -203
  140. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  141. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -302
  142. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -599
  143. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  144. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
  145. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  146. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -910
  147. package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -2197
  148. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  149. package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -461
  150. package/dist/cjs/data-structures/binary-tree/bst.js +0 -880
  151. package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
  152. package/dist/cjs/data-structures/binary-tree/index.js +0 -27
  153. package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
  154. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -280
  155. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -642
  156. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  157. package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
  158. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
  159. package/dist/cjs/data-structures/binary-tree/tree-counter.d.ts +0 -212
  160. package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -445
  161. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
  162. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -267
  163. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -365
  164. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  165. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -335
  166. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -867
  167. package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
  168. package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -323
  169. package/dist/cjs/data-structures/graph/directed-graph.js +0 -613
  170. package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
  171. package/dist/cjs/data-structures/graph/index.js +0 -21
  172. package/dist/cjs/data-structures/graph/index.js.map +0 -1
  173. package/dist/cjs/data-structures/graph/map-graph.d.ts +0 -84
  174. package/dist/cjs/data-structures/graph/map-graph.js +0 -111
  175. package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
  176. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -231
  177. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -445
  178. package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
  179. package/dist/cjs/data-structures/hash/hash-map.d.ts +0 -519
  180. package/dist/cjs/data-structures/hash/hash-map.js +0 -880
  181. package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
  182. package/dist/cjs/data-structures/hash/index.js +0 -18
  183. package/dist/cjs/data-structures/hash/index.js.map +0 -1
  184. package/dist/cjs/data-structures/heap/heap.d.ts +0 -578
  185. package/dist/cjs/data-structures/heap/heap.js +0 -911
  186. package/dist/cjs/data-structures/heap/heap.js.map +0 -1
  187. package/dist/cjs/data-structures/heap/index.js +0 -20
  188. package/dist/cjs/data-structures/heap/index.js.map +0 -1
  189. package/dist/cjs/data-structures/heap/max-heap.d.ts +0 -68
  190. package/dist/cjs/data-structures/heap/max-heap.js +0 -96
  191. package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
  192. package/dist/cjs/data-structures/heap/min-heap.d.ts +0 -68
  193. package/dist/cjs/data-structures/heap/min-heap.js +0 -87
  194. package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
  195. package/dist/cjs/data-structures/index.js +0 -29
  196. package/dist/cjs/data-structures/index.js.map +0 -1
  197. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +0 -885
  198. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1238
  199. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  200. package/dist/cjs/data-structures/linked-list/index.js +0 -20
  201. package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
  202. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +0 -500
  203. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -870
  204. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  205. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +0 -134
  206. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -245
  207. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  208. package/dist/cjs/data-structures/matrix/index.js +0 -19
  209. package/dist/cjs/data-structures/matrix/index.js.map +0 -1
  210. package/dist/cjs/data-structures/matrix/matrix.js +0 -449
  211. package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
  212. package/dist/cjs/data-structures/matrix/navigator.js +0 -112
  213. package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
  214. package/dist/cjs/data-structures/priority-queue/index.js +0 -20
  215. package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
  216. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +0 -71
  217. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -102
  218. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  219. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +0 -72
  220. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -94
  221. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  222. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +0 -74
  223. package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -96
  224. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
  225. package/dist/cjs/data-structures/queue/deque.d.ts +0 -458
  226. package/dist/cjs/data-structures/queue/deque.js +0 -919
  227. package/dist/cjs/data-structures/queue/deque.js.map +0 -1
  228. package/dist/cjs/data-structures/queue/index.js +0 -19
  229. package/dist/cjs/data-structures/queue/index.js.map +0 -1
  230. package/dist/cjs/data-structures/queue/queue.d.ts +0 -329
  231. package/dist/cjs/data-structures/queue/queue.js +0 -457
  232. package/dist/cjs/data-structures/queue/queue.js.map +0 -1
  233. package/dist/cjs/data-structures/stack/index.js +0 -18
  234. package/dist/cjs/data-structures/stack/index.js.map +0 -1
  235. package/dist/cjs/data-structures/stack/stack.js +0 -346
  236. package/dist/cjs/data-structures/stack/stack.js.map +0 -1
  237. package/dist/cjs/data-structures/tree/index.js +0 -18
  238. package/dist/cjs/data-structures/tree/index.js.map +0 -1
  239. package/dist/cjs/data-structures/tree/tree.js +0 -108
  240. package/dist/cjs/data-structures/tree/tree.js.map +0 -1
  241. package/dist/cjs/data-structures/trie/index.js +0 -18
  242. package/dist/cjs/data-structures/trie/index.js.map +0 -1
  243. package/dist/cjs/data-structures/trie/trie.d.ts +0 -351
  244. package/dist/cjs/data-structures/trie/trie.js +0 -594
  245. package/dist/cjs/data-structures/trie/trie.js.map +0 -1
  246. package/dist/cjs/index.js +0 -22
  247. package/dist/cjs/index.js.map +0 -1
  248. package/dist/cjs/interfaces/binary-tree.d.ts +0 -9
  249. package/dist/cjs/interfaces/binary-tree.js +0 -3
  250. package/dist/cjs/interfaces/binary-tree.js.map +0 -1
  251. package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
  252. package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
  253. package/dist/cjs/interfaces/graph.d.ts +0 -5
  254. package/dist/cjs/interfaces/graph.js +0 -3
  255. package/dist/cjs/interfaces/graph.js.map +0 -1
  256. package/dist/cjs/interfaces/heap.js +0 -3
  257. package/dist/cjs/interfaces/heap.js.map +0 -1
  258. package/dist/cjs/interfaces/index.js +0 -25
  259. package/dist/cjs/interfaces/index.js.map +0 -1
  260. package/dist/cjs/interfaces/navigator.js +0 -3
  261. package/dist/cjs/interfaces/navigator.js.map +0 -1
  262. package/dist/cjs/interfaces/priority-queue.js +0 -3
  263. package/dist/cjs/interfaces/priority-queue.js.map +0 -1
  264. package/dist/cjs/interfaces/segment-tree.js +0 -3
  265. package/dist/cjs/interfaces/segment-tree.js.map +0 -1
  266. package/dist/cjs/interfaces/singly-linked-list.js +0 -3
  267. package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
  268. package/dist/cjs/types/common.js +0 -3
  269. package/dist/cjs/types/common.js.map +0 -1
  270. package/dist/cjs/types/data-structures/base/base.js +0 -3
  271. package/dist/cjs/types/data-structures/base/base.js.map +0 -1
  272. package/dist/cjs/types/data-structures/base/index.js +0 -18
  273. package/dist/cjs/types/data-structures/base/index.js.map +0 -1
  274. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
  275. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  276. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
  277. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  278. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
  279. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  280. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +0 -3
  281. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  282. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -3
  283. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  284. package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
  285. package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
  286. package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
  287. package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
  288. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
  289. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  290. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
  291. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  292. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
  293. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  294. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
  295. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  296. package/dist/cjs/types/data-structures/graph/abstract-graph.d.ts +0 -10
  297. package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
  298. package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
  299. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
  300. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
  301. package/dist/cjs/types/data-structures/graph/index.js +0 -20
  302. package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
  303. package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
  304. package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
  305. package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
  306. package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
  307. package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
  308. package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
  309. package/dist/cjs/types/data-structures/hash/index.js +0 -18
  310. package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
  311. package/dist/cjs/types/data-structures/heap/heap.js +0 -3
  312. package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
  313. package/dist/cjs/types/data-structures/heap/index.js +0 -18
  314. package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
  315. package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
  316. package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
  317. package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
  318. package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
  319. package/dist/cjs/types/data-structures/index.js +0 -29
  320. package/dist/cjs/types/data-structures/index.js.map +0 -1
  321. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
  322. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  323. package/dist/cjs/types/data-structures/linked-list/index.js +0 -20
  324. package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
  325. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js +0 -3
  326. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  327. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +0 -3
  328. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  329. package/dist/cjs/types/data-structures/matrix/index.js +0 -19
  330. package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
  331. package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
  332. package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
  333. package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
  334. package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
  335. package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
  336. package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
  337. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +0 -3
  338. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  339. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +0 -3
  340. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  341. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js +0 -3
  342. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  343. package/dist/cjs/types/data-structures/queue/deque.js +0 -3
  344. package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
  345. package/dist/cjs/types/data-structures/queue/index.js +0 -19
  346. package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
  347. package/dist/cjs/types/data-structures/queue/queue.js +0 -3
  348. package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
  349. package/dist/cjs/types/data-structures/stack/index.js +0 -18
  350. package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
  351. package/dist/cjs/types/data-structures/stack/stack.js +0 -3
  352. package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
  353. package/dist/cjs/types/data-structures/tree/index.js +0 -18
  354. package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
  355. package/dist/cjs/types/data-structures/tree/tree.js +0 -3
  356. package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
  357. package/dist/cjs/types/data-structures/trie/index.js +0 -18
  358. package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
  359. package/dist/cjs/types/data-structures/trie/trie.js +0 -3
  360. package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
  361. package/dist/cjs/types/index.js +0 -20
  362. package/dist/cjs/types/index.js.map +0 -1
  363. package/dist/cjs/types/utils/index.js +0 -19
  364. package/dist/cjs/types/utils/index.js.map +0 -1
  365. package/dist/cjs/types/utils/utils.js +0 -3
  366. package/dist/cjs/types/utils/utils.js.map +0 -1
  367. package/dist/cjs/types/utils/validate-type.js +0 -3
  368. package/dist/cjs/types/utils/validate-type.js.map +0 -1
  369. package/dist/cjs/utils/index.js +0 -19
  370. package/dist/cjs/utils/index.js.map +0 -1
  371. package/dist/cjs/utils/number.js +0 -24
  372. package/dist/cjs/utils/number.js.map +0 -1
  373. package/dist/cjs/utils/utils.d.ts +0 -209
  374. package/dist/cjs/utils/utils.js +0 -353
  375. package/dist/cjs/utils/utils.js.map +0 -1
  376. package/dist/esm/common/index.d.ts +0 -12
  377. package/dist/esm/common/index.js +0 -29
  378. package/dist/esm/common/index.js.map +0 -1
  379. package/dist/esm/data-structures/base/index.d.ts +0 -2
  380. package/dist/esm/data-structures/base/index.js +0 -3
  381. package/dist/esm/data-structures/base/index.js.map +0 -1
  382. package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -116
  383. package/dist/esm/data-structures/base/iterable-element-base.js +0 -199
  384. package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
  385. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -168
  386. package/dist/esm/data-structures/base/iterable-entry-base.js +0 -237
  387. package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
  388. package/dist/esm/data-structures/base/linear-base.d.ts +0 -277
  389. package/dist/esm/data-structures/base/linear-base.js +0 -549
  390. package/dist/esm/data-structures/base/linear-base.js.map +0 -1
  391. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -214
  392. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -410
  393. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  394. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -104
  395. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -205
  396. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  397. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +0 -302
  398. package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -601
  399. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
  400. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  401. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
  402. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  403. package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +0 -910
  404. package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -2198
  405. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
  406. package/dist/esm/data-structures/binary-tree/bst.d.ts +0 -461
  407. package/dist/esm/data-structures/binary-tree/bst.js +0 -881
  408. package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
  409. package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
  410. package/dist/esm/data-structures/binary-tree/index.js +0 -11
  411. package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
  412. package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +0 -280
  413. package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -641
  414. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
  415. package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
  416. package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
  417. package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
  418. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -212
  419. package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -446
  420. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
  421. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -367
  422. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  423. package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -335
  424. package/dist/esm/data-structures/graph/abstract-graph.js +0 -862
  425. package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
  426. package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -323
  427. package/dist/esm/data-structures/graph/directed-graph.js +0 -609
  428. package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
  429. package/dist/esm/data-structures/graph/index.d.ts +0 -4
  430. package/dist/esm/data-structures/graph/index.js +0 -5
  431. package/dist/esm/data-structures/graph/index.js.map +0 -1
  432. package/dist/esm/data-structures/graph/map-graph.d.ts +0 -84
  433. package/dist/esm/data-structures/graph/map-graph.js +0 -108
  434. package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
  435. package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -231
  436. package/dist/esm/data-structures/graph/undirected-graph.js +0 -439
  437. package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
  438. package/dist/esm/data-structures/hash/hash-map.d.ts +0 -519
  439. package/dist/esm/data-structures/hash/hash-map.js +0 -878
  440. package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
  441. package/dist/esm/data-structures/hash/index.d.ts +0 -1
  442. package/dist/esm/data-structures/hash/index.js +0 -2
  443. package/dist/esm/data-structures/hash/index.js.map +0 -1
  444. package/dist/esm/data-structures/heap/heap.d.ts +0 -578
  445. package/dist/esm/data-structures/heap/heap.js +0 -914
  446. package/dist/esm/data-structures/heap/heap.js.map +0 -1
  447. package/dist/esm/data-structures/heap/index.d.ts +0 -3
  448. package/dist/esm/data-structures/heap/index.js +0 -4
  449. package/dist/esm/data-structures/heap/index.js.map +0 -1
  450. package/dist/esm/data-structures/heap/max-heap.d.ts +0 -68
  451. package/dist/esm/data-structures/heap/max-heap.js +0 -95
  452. package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
  453. package/dist/esm/data-structures/heap/min-heap.d.ts +0 -68
  454. package/dist/esm/data-structures/heap/min-heap.js +0 -83
  455. package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
  456. package/dist/esm/data-structures/index.d.ts +0 -12
  457. package/dist/esm/data-structures/index.js +0 -13
  458. package/dist/esm/data-structures/index.js.map +0 -1
  459. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -885
  460. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1236
  461. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  462. package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
  463. package/dist/esm/data-structures/linked-list/index.js +0 -4
  464. package/dist/esm/data-structures/linked-list/index.js.map +0 -1
  465. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +0 -500
  466. package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -866
  467. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
  468. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -134
  469. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -243
  470. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
  471. package/dist/esm/data-structures/matrix/index.d.ts +0 -2
  472. package/dist/esm/data-structures/matrix/index.js +0 -3
  473. package/dist/esm/data-structures/matrix/index.js.map +0 -1
  474. package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
  475. package/dist/esm/data-structures/matrix/matrix.js +0 -444
  476. package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
  477. package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
  478. package/dist/esm/data-structures/matrix/navigator.js +0 -114
  479. package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
  480. package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
  481. package/dist/esm/data-structures/priority-queue/index.js +0 -4
  482. package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
  483. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -71
  484. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -101
  485. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  486. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -72
  487. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -90
  488. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  489. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -74
  490. package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -92
  491. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
  492. package/dist/esm/data-structures/queue/deque.d.ts +0 -458
  493. package/dist/esm/data-structures/queue/deque.js +0 -915
  494. package/dist/esm/data-structures/queue/deque.js.map +0 -1
  495. package/dist/esm/data-structures/queue/index.d.ts +0 -2
  496. package/dist/esm/data-structures/queue/index.js +0 -3
  497. package/dist/esm/data-structures/queue/index.js.map +0 -1
  498. package/dist/esm/data-structures/queue/queue.d.ts +0 -329
  499. package/dist/esm/data-structures/queue/queue.js +0 -452
  500. package/dist/esm/data-structures/queue/queue.js.map +0 -1
  501. package/dist/esm/data-structures/stack/index.d.ts +0 -1
  502. package/dist/esm/data-structures/stack/index.js +0 -2
  503. package/dist/esm/data-structures/stack/index.js.map +0 -1
  504. package/dist/esm/data-structures/stack/stack.d.ts +0 -284
  505. package/dist/esm/data-structures/stack/stack.js +0 -342
  506. package/dist/esm/data-structures/stack/stack.js.map +0 -1
  507. package/dist/esm/data-structures/tree/index.d.ts +0 -1
  508. package/dist/esm/data-structures/tree/index.js +0 -2
  509. package/dist/esm/data-structures/tree/index.js.map +0 -1
  510. package/dist/esm/data-structures/tree/tree.d.ts +0 -62
  511. package/dist/esm/data-structures/tree/tree.js +0 -107
  512. package/dist/esm/data-structures/tree/tree.js.map +0 -1
  513. package/dist/esm/data-structures/trie/index.d.ts +0 -1
  514. package/dist/esm/data-structures/trie/index.js +0 -2
  515. package/dist/esm/data-structures/trie/index.js.map +0 -1
  516. package/dist/esm/data-structures/trie/trie.d.ts +0 -351
  517. package/dist/esm/data-structures/trie/trie.js +0 -592
  518. package/dist/esm/data-structures/trie/trie.js.map +0 -1
  519. package/dist/esm/index.d.ts +0 -5
  520. package/dist/esm/index.js +0 -6
  521. package/dist/esm/index.js.map +0 -1
  522. package/dist/esm/interfaces/binary-tree.d.ts +0 -9
  523. package/dist/esm/interfaces/binary-tree.js +0 -2
  524. package/dist/esm/interfaces/binary-tree.js.map +0 -1
  525. package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
  526. package/dist/esm/interfaces/doubly-linked-list.js +0 -2
  527. package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
  528. package/dist/esm/interfaces/graph.d.ts +0 -5
  529. package/dist/esm/interfaces/graph.js +0 -2
  530. package/dist/esm/interfaces/graph.js.map +0 -1
  531. package/dist/esm/interfaces/heap.d.ts +0 -1
  532. package/dist/esm/interfaces/heap.js +0 -2
  533. package/dist/esm/interfaces/heap.js.map +0 -1
  534. package/dist/esm/interfaces/index.d.ts +0 -8
  535. package/dist/esm/interfaces/index.js +0 -9
  536. package/dist/esm/interfaces/index.js.map +0 -1
  537. package/dist/esm/interfaces/navigator.d.ts +0 -1
  538. package/dist/esm/interfaces/navigator.js +0 -2
  539. package/dist/esm/interfaces/navigator.js.map +0 -1
  540. package/dist/esm/interfaces/priority-queue.d.ts +0 -1
  541. package/dist/esm/interfaces/priority-queue.js +0 -2
  542. package/dist/esm/interfaces/priority-queue.js.map +0 -1
  543. package/dist/esm/interfaces/segment-tree.d.ts +0 -1
  544. package/dist/esm/interfaces/segment-tree.js +0 -2
  545. package/dist/esm/interfaces/segment-tree.js.map +0 -1
  546. package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
  547. package/dist/esm/interfaces/singly-linked-list.js +0 -2
  548. package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
  549. package/dist/esm/types/common.d.ts +0 -15
  550. package/dist/esm/types/common.js +0 -2
  551. package/dist/esm/types/common.js.map +0 -1
  552. package/dist/esm/types/data-structures/base/base.d.ts +0 -13
  553. package/dist/esm/types/data-structures/base/base.js +0 -2
  554. package/dist/esm/types/data-structures/base/base.js.map +0 -1
  555. package/dist/esm/types/data-structures/base/index.d.ts +0 -1
  556. package/dist/esm/types/data-structures/base/index.js +0 -2
  557. package/dist/esm/types/data-structures/base/index.js.map +0 -1
  558. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  559. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  560. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  561. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  562. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  563. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  564. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  565. package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
  566. package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  567. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
  568. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  569. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  570. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
  571. package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
  572. package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  573. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
  574. package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
  575. package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
  576. package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
  577. package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
  578. package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
  579. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
  580. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
  581. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  582. package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
  583. package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
  584. package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  585. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  586. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
  587. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  588. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
  589. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  590. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  591. package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
  592. package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
  593. package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
  594. package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
  595. package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
  596. package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
  597. package/dist/esm/types/data-structures/graph/index.js +0 -4
  598. package/dist/esm/types/data-structures/graph/index.js.map +0 -1
  599. package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
  600. package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
  601. package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
  602. package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
  603. package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
  604. package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
  605. package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
  606. package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
  607. package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
  608. package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
  609. package/dist/esm/types/data-structures/hash/index.js +0 -2
  610. package/dist/esm/types/data-structures/hash/index.js.map +0 -1
  611. package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
  612. package/dist/esm/types/data-structures/heap/heap.js +0 -2
  613. package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
  614. package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
  615. package/dist/esm/types/data-structures/heap/index.js +0 -2
  616. package/dist/esm/types/data-structures/heap/index.js.map +0 -1
  617. package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
  618. package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
  619. package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
  620. package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
  621. package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
  622. package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
  623. package/dist/esm/types/data-structures/index.d.ts +0 -12
  624. package/dist/esm/types/data-structures/index.js +0 -13
  625. package/dist/esm/types/data-structures/index.js.map +0 -1
  626. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
  627. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  628. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  629. package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
  630. package/dist/esm/types/data-structures/linked-list/index.js +0 -4
  631. package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
  632. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
  633. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
  634. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  635. package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
  636. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
  637. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  638. package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
  639. package/dist/esm/types/data-structures/matrix/index.js +0 -3
  640. package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
  641. package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
  642. package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
  643. package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
  644. package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
  645. package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
  646. package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
  647. package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
  648. package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
  649. package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
  650. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
  651. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  652. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  653. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
  654. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  655. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  656. package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
  657. package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
  658. package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  659. package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
  660. package/dist/esm/types/data-structures/queue/deque.js +0 -2
  661. package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
  662. package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
  663. package/dist/esm/types/data-structures/queue/index.js +0 -3
  664. package/dist/esm/types/data-structures/queue/index.js.map +0 -1
  665. package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
  666. package/dist/esm/types/data-structures/queue/queue.js +0 -2
  667. package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
  668. package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
  669. package/dist/esm/types/data-structures/stack/index.js +0 -2
  670. package/dist/esm/types/data-structures/stack/index.js.map +0 -1
  671. package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
  672. package/dist/esm/types/data-structures/stack/stack.js +0 -2
  673. package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
  674. package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
  675. package/dist/esm/types/data-structures/tree/index.js +0 -2
  676. package/dist/esm/types/data-structures/tree/index.js.map +0 -1
  677. package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
  678. package/dist/esm/types/data-structures/tree/tree.js +0 -2
  679. package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
  680. package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
  681. package/dist/esm/types/data-structures/trie/index.js +0 -2
  682. package/dist/esm/types/data-structures/trie/index.js.map +0 -1
  683. package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
  684. package/dist/esm/types/data-structures/trie/trie.js +0 -2
  685. package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
  686. package/dist/esm/types/index.d.ts +0 -3
  687. package/dist/esm/types/index.js +0 -4
  688. package/dist/esm/types/index.js.map +0 -1
  689. package/dist/esm/types/utils/index.d.ts +0 -2
  690. package/dist/esm/types/utils/index.js +0 -3
  691. package/dist/esm/types/utils/index.js.map +0 -1
  692. package/dist/esm/types/utils/utils.d.ts +0 -21
  693. package/dist/esm/types/utils/utils.js +0 -2
  694. package/dist/esm/types/utils/utils.js.map +0 -1
  695. package/dist/esm/types/utils/validate-type.d.ts +0 -19
  696. package/dist/esm/types/utils/validate-type.js +0 -2
  697. package/dist/esm/types/utils/validate-type.js.map +0 -1
  698. package/dist/esm/utils/index.d.ts +0 -2
  699. package/dist/esm/utils/index.js +0 -3
  700. package/dist/esm/utils/index.js.map +0 -1
  701. package/dist/esm/utils/number.d.ts +0 -14
  702. package/dist/esm/utils/number.js +0 -21
  703. package/dist/esm/utils/number.js.map +0 -1
  704. package/dist/esm/utils/utils.js +0 -324
  705. package/dist/esm/utils/utils.js.map +0 -1
  706. package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +0 -71
  707. package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +0 -81
  708. package/tsconfig-cjs.json +0 -14
  709. package/tsconfig-esm.json +0 -14
  710. /package/dist/{cjs → types}/common/index.d.ts +0 -0
  711. /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
  712. /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  713. /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
  714. /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  715. /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
  716. /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
  717. /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
  718. /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
  719. /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
  720. /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
  721. /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
  722. /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
  723. /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
  724. /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
  725. /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
  726. /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
  727. /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
  728. /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
  729. /package/dist/{cjs → types}/index.d.ts +0 -0
  730. /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
  731. /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
  732. /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
  733. /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
  734. /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
  735. /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
  736. /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
  737. /package/dist/{cjs → types}/types/common.d.ts +0 -0
  738. /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
  739. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
  740. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
  741. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
  742. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  743. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
  744. /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
  745. /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
  746. /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
  747. /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  748. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
  749. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
  750. /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
  751. /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
  752. /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
  753. /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  754. /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
  755. /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
  756. /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
  757. /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
  758. /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
  759. /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
  760. /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
  761. /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  762. /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
  763. /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  764. /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  765. /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
  766. /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
  767. /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
  768. /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
  769. /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  770. /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  771. /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  772. /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
  773. /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
  774. /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
  775. /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
  776. /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
  777. /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
  778. /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
  779. /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
  780. /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
  781. /package/dist/{cjs → types}/types/index.d.ts +0 -0
  782. /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
  783. /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
  784. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  785. /package/dist/{cjs → types}/utils/number.d.ts +0 -0
@@ -1,914 +0,0 @@
1
- /**
2
- * data-structure-typed
3
- * @author Kirk Qi
4
- * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
5
- * @license MIT License
6
- */
7
- import { IterableElementBase } from '../base';
8
- /**
9
- * 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
10
- * 2. Heap Properties: Each node in a heap follows a specific order property, which varies depending on the type of heap:
11
- * Max Heap: The value of each parent node is greater than or equal to the value of its children.
12
- * Min Heap: The value of each parent node is less than or equal to the value of its children.
13
- * 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
14
- * 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
15
- * 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
16
- * 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
17
- * 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
18
- * 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prime's minimum-spanning tree algorithm, which use heaps to improve performance.
19
- * @example
20
- * // Use Heap to sort an array
21
- * function heapSort(arr: number[]): number[] {
22
- * const heap = new Heap<number>(arr, { comparator: (a, b) => a - b });
23
- * const sorted: number[] = [];
24
- * while (!heap.isEmpty()) {
25
- * sorted.push(heap.poll()!); // Poll minimum element
26
- * }
27
- * return sorted;
28
- * }
29
- *
30
- * const array = [5, 3, 8, 4, 1, 2];
31
- * console.log(heapSort(array)); // [1, 2, 3, 4, 5, 8]
32
- * @example
33
- * // Use Heap to solve top k problems
34
- * function topKElements(arr: number[], k: number): number[] {
35
- * const heap = new Heap<number>([], { comparator: (a, b) => b - a }); // Max heap
36
- * arr.forEach(num => {
37
- * heap.add(num);
38
- * if (heap.size > k) heap.poll(); // Keep the heap size at K
39
- * });
40
- * return heap.toArray();
41
- * }
42
- *
43
- * const numbers = [10, 30, 20, 5, 15, 25];
44
- * console.log(topKElements(numbers, 3)); // [15, 10, 5]
45
- * @example
46
- * // Use Heap to merge sorted sequences
47
- * function mergeSortedSequences(sequences: number[][]): number[] {
48
- * const heap = new Heap<{ value: number; seqIndex: number; itemIndex: number }>([], {
49
- * comparator: (a, b) => a.value - b.value // Min heap
50
- * });
51
- *
52
- * // Initialize heap
53
- * sequences.forEach((seq, seqIndex) => {
54
- * if (seq.length) {
55
- * heap.add({ value: seq[0], seqIndex, itemIndex: 0 });
56
- * }
57
- * });
58
- *
59
- * const merged: number[] = [];
60
- * while (!heap.isEmpty()) {
61
- * const { value, seqIndex, itemIndex } = heap.poll()!;
62
- * merged.push(value);
63
- *
64
- * if (itemIndex + 1 < sequences[seqIndex].length) {
65
- * heap.add({
66
- * value: sequences[seqIndex][itemIndex + 1],
67
- * seqIndex,
68
- * itemIndex: itemIndex + 1
69
- * });
70
- * }
71
- * }
72
- *
73
- * return merged;
74
- * }
75
- *
76
- * const sequences = [
77
- * [1, 4, 7],
78
- * [2, 5, 8],
79
- * [3, 6, 9]
80
- * ];
81
- * console.log(mergeSortedSequences(sequences)); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
82
- * @example
83
- * // Use Heap to dynamically maintain the median
84
- * class MedianFinder {
85
- * private low: MaxHeap<number>; // Max heap, stores the smaller half
86
- * private high: MinHeap<number>; // Min heap, stores the larger half
87
- *
88
- * constructor() {
89
- * this.low = new MaxHeap<number>([]);
90
- * this.high = new MinHeap<number>([]);
91
- * }
92
- *
93
- * addNum(num: number): void {
94
- * if (this.low.isEmpty() || num <= this.low.peek()!) this.low.add(num);
95
- * else this.high.add(num);
96
- *
97
- * // Balance heaps
98
- * if (this.low.size > this.high.size + 1) this.high.add(this.low.poll()!);
99
- * else if (this.high.size > this.low.size) this.low.add(this.high.poll()!);
100
- * }
101
- *
102
- * findMedian(): number {
103
- * if (this.low.size === this.high.size) return (this.low.peek()! + this.high.peek()!) / 2;
104
- * return this.low.peek()!;
105
- * }
106
- * }
107
- *
108
- * const medianFinder = new MedianFinder();
109
- * medianFinder.addNum(10);
110
- * console.log(medianFinder.findMedian()); // 10
111
- * medianFinder.addNum(20);
112
- * console.log(medianFinder.findMedian()); // 15
113
- * medianFinder.addNum(30);
114
- * console.log(medianFinder.findMedian()); // 20
115
- * medianFinder.addNum(40);
116
- * console.log(medianFinder.findMedian()); // 25
117
- * medianFinder.addNum(50);
118
- * console.log(medianFinder.findMedian()); // 30
119
- * @example
120
- * // Use Heap for load balancing
121
- * function loadBalance(requests: number[], servers: number): number[] {
122
- * const serverHeap = new Heap<{ id: number; load: number }>([], { comparator: (a, b) => a.load - b.load }); // min heap
123
- * const serverLoads = new Array(servers).fill(0);
124
- *
125
- * for (let i = 0; i < servers; i++) {
126
- * serverHeap.add({ id: i, load: 0 });
127
- * }
128
- *
129
- * requests.forEach(req => {
130
- * const server = serverHeap.poll()!;
131
- * serverLoads[server.id] += req;
132
- * server.load += req;
133
- * serverHeap.add(server); // The server after updating the load is re-entered into the heap
134
- * });
135
- *
136
- * return serverLoads;
137
- * }
138
- *
139
- * const requests = [5, 2, 8, 3, 7];
140
- * console.log(loadBalance(requests, 3)); // [12, 8, 5]
141
- * @example
142
- * // Use Heap to schedule tasks
143
- * type Task = [string, number];
144
- *
145
- * function scheduleTasks(tasks: Task[], machines: number): Map<number, Task[]> {
146
- * const machineHeap = new Heap<{ id: number; load: number }>([], { comparator: (a, b) => a.load - b.load }); // Min heap
147
- * const allocation = new Map<number, Task[]>();
148
- *
149
- * // Initialize the load on each machine
150
- * for (let i = 0; i < machines; i++) {
151
- * machineHeap.add({ id: i, load: 0 });
152
- * allocation.set(i, []);
153
- * }
154
- *
155
- * // Assign tasks
156
- * tasks.forEach(([task, load]) => {
157
- * const machine = machineHeap.poll()!;
158
- * allocation.get(machine.id)!.push([task, load]);
159
- * machine.load += load;
160
- * machineHeap.add(machine); // The machine after updating the load is re-entered into the heap
161
- * });
162
- *
163
- * return allocation;
164
- * }
165
- *
166
- * const tasks: Task[] = [
167
- * ['Task1', 3],
168
- * ['Task2', 1],
169
- * ['Task3', 2],
170
- * ['Task4', 5],
171
- * ['Task5', 4]
172
- * ];
173
- * const expectedMap = new Map<number, Task[]>();
174
- * expectedMap.set(0, [
175
- * ['Task1', 3],
176
- * ['Task4', 5]
177
- * ]);
178
- * expectedMap.set(1, [
179
- * ['Task2', 1],
180
- * ['Task3', 2],
181
- * ['Task5', 4]
182
- * ]);
183
- * console.log(scheduleTasks(tasks, 2)); // expectedMap
184
- */
185
- export class Heap extends IterableElementBase {
186
- /**
187
- * The constructor initializes a heap data structure with optional elements and options.
188
- * @param elements - The `elements` parameter is an iterable object that contains the initial
189
- * elements to be added to the heap.
190
- * It is an optional parameter, and if not provided, the heap will
191
- * be initialized as empty.
192
- * @param [options] - The `options` parameter is an optional object that can contain additional
193
- * configuration options for the heap.
194
- * In this case, it is used to specify a custom comparator
195
- * function for comparing elements in the heap.
196
- * The comparator function is used to determine the
197
- * order of elements in the heap.
198
- */
199
- constructor(elements = [], options) {
200
- super(options);
201
- if (options) {
202
- const { comparator } = options;
203
- if (comparator)
204
- this._comparator = comparator;
205
- }
206
- this.addMany(elements);
207
- }
208
- _elements = [];
209
- /**
210
- * The function returns an array of elements.
211
- * @returns The element array is being returned.
212
- */
213
- get elements() {
214
- return this._elements;
215
- }
216
- /**
217
- * Get the size (number of elements) of the heap.
218
- */
219
- get size() {
220
- return this.elements.length;
221
- }
222
- /**
223
- * Get the last element in the heap, which is not necessarily a leaf node.
224
- * @returns The last element or undefined if the heap is empty.
225
- */
226
- get leaf() {
227
- return this.elements[this.size - 1] ?? undefined;
228
- }
229
- /**
230
- * Static method that creates a binary heap from an array of elements and a comparison function.
231
- * @returns A new Heap instance.
232
- * @param elements
233
- * @param options
234
- */
235
- static heapify(elements, options) {
236
- return new Heap(elements, options);
237
- }
238
- /**
239
- * Time Complexity: O(log n)
240
- * Space Complexity: O(1)
241
- *
242
- * The add function pushes an element into an array and then triggers a bubble-up operation.
243
- * @param {E} element - The `element` parameter represents the element that you want to add to the
244
- * data structure.
245
- * @returns The `add` method is returning a boolean value, which is the result of calling the
246
- * `_bubbleUp` method with the index `this.elements.length - 1` as an argument.
247
- */
248
- add(element) {
249
- this._elements.push(element);
250
- return this._bubbleUp(this.elements.length - 1);
251
- }
252
- /**
253
- * Time Complexity: O(k log n)
254
- * Space Complexity: O(1)
255
- *
256
- * The `addMany` function iterates over elements and adds them to a collection, returning an array of
257
- * boolean values indicating success or failure.
258
- * @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `addMany` method is
259
- * an iterable containing elements of type `E` or `R`. The method iterates over each element in the
260
- * iterable and adds them to the data structure. If a transformation function `_toElementFn` is
261
- * provided, it transforms the element
262
- * @returns The `addMany` method returns an array of boolean values indicating whether each element
263
- * in the input iterable was successfully added to the data structure.
264
- */
265
- addMany(elements) {
266
- const ans = [];
267
- for (const el of elements) {
268
- if (this._toElementFn) {
269
- ans.push(this.add(this._toElementFn(el)));
270
- continue;
271
- }
272
- ans.push(this.add(el));
273
- }
274
- return ans;
275
- }
276
- /**
277
- * Time Complexity: O(log n)
278
- * Space Complexity: O(1)
279
- *
280
- * Remove and return the top element (the smallest or largest element) from the heap.
281
- * @returns The top element or undefined if the heap is empty.
282
- */
283
- poll() {
284
- if (this.elements.length === 0)
285
- return;
286
- const value = this.elements[0];
287
- const last = this.elements.pop();
288
- if (this.elements.length) {
289
- this.elements[0] = last;
290
- this._sinkDown(0, this.elements.length >> 1);
291
- }
292
- return value;
293
- }
294
- /**
295
- * Time Complexity: O(1)
296
- * Space Complexity: O(1)
297
- *
298
- * Peek at the top element of the heap without removing it.
299
- * @returns The top element or undefined if the heap is empty.
300
- */
301
- peek() {
302
- return this.elements[0];
303
- }
304
- /**
305
- * Check if the heap is empty.
306
- * @returns True if the heap is empty, otherwise false.
307
- */
308
- isEmpty() {
309
- return this.size === 0;
310
- }
311
- /**
312
- * Reset the elements of the heap. Make the elements empty.
313
- */
314
- clear() {
315
- this._elements = [];
316
- }
317
- /**
318
- * Time Complexity: O(n)
319
- * Space Complexity: O(n)
320
- *
321
- * Clear and add elements of the heap
322
- * @param elements
323
- */
324
- refill(elements) {
325
- this._elements = elements;
326
- return this.fix();
327
- }
328
- /**
329
- * Time Complexity: O(n)
330
- * Space Complexity: O(1)
331
- *
332
- * Use a comparison function to check whether a binary heap contains a specific element.
333
- * @param element - the element to check.
334
- * @returns Returns true if the specified element is contained; otherwise, returns false.
335
- */
336
- has(element) {
337
- return this.elements.includes(element);
338
- }
339
- /**
340
- * Time Complexity: O(n)
341
- * Space Complexity: O(1)
342
- *
343
- * The `delete` function removes an element from an array-like data structure, maintaining the order
344
- * and structure of the remaining elements.
345
- * @param {E} element - The `element` parameter represents the element that you want to delete from
346
- * the array `this.elements`.
347
- * @returns The `delete` function is returning a boolean value. It returns `true` if the element was
348
- * successfully deleted from the array, and `false` if the element was not found in the array.
349
- */
350
- delete(element) {
351
- const index = this.elements.indexOf(element);
352
- if (index < 0)
353
- return false;
354
- if (index === 0) {
355
- this.poll();
356
- }
357
- else if (index === this.elements.length - 1) {
358
- this.elements.pop();
359
- }
360
- else {
361
- this.elements.splice(index, 1, this.elements.pop());
362
- this._bubbleUp(index);
363
- this._sinkDown(index, this.elements.length >> 1);
364
- }
365
- return true;
366
- }
367
- /**
368
- * Time Complexity: O(n)
369
- * Space Complexity: O(log n)
370
- *
371
- * Depth-first search (DFS) method, different traversal orders can be selected。
372
- * @param order - Traverse order parameter: 'IN' (in-order), 'PRE' (pre-order) or 'POST' (post-order).
373
- * @returns An array containing elements traversed in the specified order.
374
- */
375
- dfs(order = 'PRE') {
376
- const result = [];
377
- // Auxiliary recursive function, traverses the binary heap according to the traversal order
378
- const _dfs = (index) => {
379
- const left = 2 * index + 1, right = left + 1;
380
- if (index < this.size) {
381
- if (order === 'IN') {
382
- _dfs(left);
383
- result.push(this.elements[index]);
384
- _dfs(right);
385
- }
386
- else if (order === 'PRE') {
387
- result.push(this.elements[index]);
388
- _dfs(left);
389
- _dfs(right);
390
- }
391
- else if (order === 'POST') {
392
- _dfs(left);
393
- _dfs(right);
394
- result.push(this.elements[index]);
395
- }
396
- }
397
- };
398
- _dfs(0); // Traverse starting from the root node
399
- return result;
400
- }
401
- /**
402
- * Time Complexity: O(n)
403
- * Space Complexity: O(n)
404
- *
405
- * Clone the heap, creating a new heap with the same elements.
406
- * @returns A new Heap instance containing the same elements.
407
- */
408
- clone() {
409
- return new Heap(this, { comparator: this.comparator, toElementFn: this.toElementFn });
410
- }
411
- /**
412
- * Time Complexity: O(n log n)
413
- * Space Complexity: O(n)
414
- *
415
- * Sort the elements in the heap and return them as an array.
416
- * @returns An array containing the elements sorted in ascending order.
417
- */
418
- sort() {
419
- const visitedNode = [];
420
- const cloned = new Heap(this, { comparator: this.comparator });
421
- while (cloned.size !== 0) {
422
- const top = cloned.poll();
423
- if (top !== undefined)
424
- visitedNode.push(top);
425
- }
426
- return visitedNode;
427
- }
428
- /**
429
- * Time Complexity: O(n log n)
430
- * Space Complexity: O(n)
431
- *
432
- * Fix the entire heap to maintain heap properties.
433
- */
434
- fix() {
435
- const results = [];
436
- for (let i = Math.floor(this.size / 2); i >= 0; i--)
437
- results.push(this._sinkDown(i, this.elements.length >> 1));
438
- return results;
439
- }
440
- /**
441
- * Time Complexity: O(n)
442
- * Space Complexity: O(n)
443
- *
444
- * The `filter` function creates a new Heap object containing elements that pass a given callback
445
- * function.
446
- * @param callback - The `callback` parameter is a function that will be called for each element in
447
- * the heap. It takes three arguments: the current element, the index of the current element, and the
448
- * heap itself. The callback function should return a boolean value indicating whether the current
449
- * element should be included in the filtered list
450
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
451
- * to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
452
- * passed as the `this` value to the `callback` function. If `thisArg` is
453
- * @returns The `filter` method is returning a new `Heap` object that contains the elements that pass
454
- * the filter condition specified by the `callback` function.
455
- */
456
- filter(callback, thisArg) {
457
- const filteredList = new Heap([], { toElementFn: this.toElementFn, comparator: this.comparator });
458
- let index = 0;
459
- for (const current of this) {
460
- if (callback.call(thisArg, current, index, this)) {
461
- filteredList.add(current);
462
- }
463
- index++;
464
- }
465
- return filteredList;
466
- }
467
- /**
468
- * Time Complexity: O(n)
469
- * Space Complexity: O(n)
470
- *
471
- * The `map` function creates a new heap by applying a callback function to each element of the
472
- * original heap.
473
- * @param callback - The `callback` parameter is a function that will be called for each element in
474
- * the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
475
- * element), and `this` (the heap itself). The callback function should return a value of
476
- * @param comparator - The `comparator` parameter is a function that defines the order of the
477
- * elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
478
- * if `a` should be placed before `b`, a positive number if `a` should be placed after
479
- * @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
480
- * element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
481
- * returns a value of type `T`. This function is used to transform the elements of the original
482
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
483
- * specify the value of `this` within the callback function. It is used to set the context or scope
484
- * in which the callback function will be executed. If `thisArg` is provided, it will be used as the
485
- * value of
486
- * @returns a new instance of the `Heap` class with the mapped elements.
487
- */
488
- map(callback, comparator, toElementFn, thisArg) {
489
- const mappedHeap = new Heap([], { comparator, toElementFn });
490
- let index = 0;
491
- for (const el of this) {
492
- mappedHeap.add(callback.call(thisArg, el, index, this));
493
- index++;
494
- }
495
- return mappedHeap;
496
- }
497
- _DEFAULT_COMPARATOR = (a, b) => {
498
- if (typeof a === 'object' || typeof b === 'object') {
499
- throw TypeError(`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`);
500
- }
501
- if (a > b)
502
- return 1;
503
- if (a < b)
504
- return -1;
505
- return 0;
506
- };
507
- _comparator = this._DEFAULT_COMPARATOR;
508
- /**
509
- * The function returns the value of the _comparator property.
510
- * @returns The `_comparator` property is being returned.
511
- */
512
- get comparator() {
513
- return this._comparator;
514
- }
515
- /**
516
- * The function `_getIterator` returns an iterable iterator for the elements in the class.
517
- */
518
- *_getIterator() {
519
- for (const element of this.elements) {
520
- yield element;
521
- }
522
- }
523
- /**
524
- * Time Complexity: O(log n)
525
- * Space Complexity: O(1)
526
- *
527
- * Float operation to maintain heap properties after adding an element.
528
- * @param index - The index of the newly added element.
529
- */
530
- _bubbleUp(index) {
531
- const element = this.elements[index];
532
- while (index > 0) {
533
- const parent = (index - 1) >> 1;
534
- const parentItem = this.elements[parent];
535
- if (this.comparator(parentItem, element) <= 0)
536
- break;
537
- this.elements[index] = parentItem;
538
- index = parent;
539
- }
540
- this.elements[index] = element;
541
- return true;
542
- }
543
- /**
544
- * Time Complexity: O(log n)
545
- * Space Complexity: O(1)
546
- *
547
- * Sinking operation to maintain heap properties after removing the top element.
548
- * @param index - The index from which to start sinking.
549
- * @param halfLength
550
- */
551
- _sinkDown(index, halfLength) {
552
- const element = this.elements[index];
553
- while (index < halfLength) {
554
- let left = (index << 1) | 1;
555
- const right = left + 1;
556
- let minItem = this.elements[left];
557
- if (right < this.elements.length && this.comparator(minItem, this.elements[right]) > 0) {
558
- left = right;
559
- minItem = this.elements[right];
560
- }
561
- if (this.comparator(minItem, element) >= 0)
562
- break;
563
- this.elements[index] = minItem;
564
- index = left;
565
- }
566
- this.elements[index] = element;
567
- return true;
568
- }
569
- }
570
- export class FibonacciHeapNode {
571
- element;
572
- degree;
573
- left;
574
- right;
575
- child;
576
- parent;
577
- marked;
578
- /**
579
- * The constructor function initializes an object with an element and a degree, and sets the marked
580
- * property to false.
581
- * @param {E} element - The "element" parameter represents the value or data that will be stored in
582
- * the node of a data structure. It can be any type of data, such as a number, string, object, or
583
- * even another data structure.
584
- * @param [degree=0] - The degree parameter represents the degree of the element in a data structure
585
- * called a Fibonacci heap. The degree of a node is the number of children it has. By default, the
586
- * degree is set to 0 when a new node is created.
587
- */
588
- constructor(element, degree = 0) {
589
- this.element = element;
590
- this.degree = degree;
591
- this.marked = false;
592
- }
593
- }
594
- export class FibonacciHeap {
595
- /**
596
- * The constructor function initializes a FibonacciHeap object with an optional comparator function.
597
- * @param [comparator] - The `comparator` parameter is an optional argument that represents a
598
- * function used to compare elements in the FibonacciHeap. If a comparator function is provided, it
599
- * will be used to determine the order of elements in the heap. If no comparator function is
600
- * provided, a default comparator function will be used.
601
- */
602
- constructor(comparator) {
603
- this.clear();
604
- this._comparator = comparator || this._defaultComparator;
605
- if (typeof this.comparator !== 'function') {
606
- throw new Error('FibonacciHeap constructor: given comparator should be a function.');
607
- }
608
- }
609
- _root;
610
- /**
611
- * The function returns the root node of a Fibonacci heap.
612
- * @returns The method is returning either a FibonacciHeapNode object or undefined.
613
- */
614
- get root() {
615
- return this._root;
616
- }
617
- _size = 0;
618
- /**
619
- * The function returns the size of an object.
620
- * @returns The size of the object, which is a number.
621
- */
622
- get size() {
623
- return this._size;
624
- }
625
- _min;
626
- /**
627
- * The function returns the minimum node in a Fibonacci heap.
628
- * @returns The method is returning the minimum node of the Fibonacci heap, which is of type
629
- * `FibonacciHeapNode<E>`. If there is no minimum node, it will return `undefined`.
630
- */
631
- get min() {
632
- return this._min;
633
- }
634
- _comparator;
635
- /**
636
- * The function returns the comparator used for comparing elements.
637
- * @returns The `_comparator` property of the object.
638
- */
639
- get comparator() {
640
- return this._comparator;
641
- }
642
- /**
643
- * Get the size (number of elements) of the heap.
644
- * @returns {number} The size of the heap. Returns 0 if the heap is empty. Returns -1 if the heap is invalid.
645
- */
646
- clear() {
647
- this._root = undefined;
648
- this._min = undefined;
649
- this._size = 0;
650
- }
651
- /**
652
- * Time Complexity: O(1)
653
- * Space Complexity: O(1)
654
- *
655
- * Insert an element into the heap and maintain the heap properties.
656
- * @param element
657
- * @returns {FibonacciHeap<E>} FibonacciHeap<E> - The heap itself.
658
- */
659
- add(element) {
660
- return this.push(element);
661
- }
662
- /**
663
- * Time Complexity: O(1)
664
- * Space Complexity: O(1)
665
- *
666
- * Insert an element into the heap and maintain the heap properties.
667
- * @param element
668
- * @returns {FibonacciHeap<E>} FibonacciHeap<E> - The heap itself.
669
- */
670
- push(element) {
671
- const node = this.createNode(element);
672
- node.left = node;
673
- node.right = node;
674
- this.mergeWithRoot(node);
675
- if (!this.min || this.comparator(node.element, this.min.element) <= 0) {
676
- this._min = node;
677
- }
678
- this._size++;
679
- return this;
680
- }
681
- /**
682
- * Time Complexity: O(1)
683
- * Space Complexity: O(1)
684
- *
685
- * Peek at the top element of the heap without removing it.
686
- * @returns The top element or undefined if the heap is empty.
687
- * @protected
688
- */
689
- peek() {
690
- return this.min ? this.min.element : undefined;
691
- }
692
- /**
693
- * Time Complexity: O(n), where n is the number of elements in the linked list.
694
- * Space Complexity: O(1)
695
- *
696
- * Get the size (number of elements) of the heap.
697
- * @param {FibonacciHeapNode<E>} head - The head of the linked list.
698
- * @protected
699
- * @returns FibonacciHeapNode<E>[] - An array containing the elements of the linked list.
700
- */
701
- consumeLinkedList(head) {
702
- const elements = [];
703
- if (!head)
704
- return elements;
705
- let node = head;
706
- let flag = false;
707
- while (true) {
708
- if (node === head && flag)
709
- break;
710
- else if (node === head)
711
- flag = true;
712
- if (node) {
713
- elements.push(node);
714
- node = node.right;
715
- }
716
- }
717
- return elements;
718
- }
719
- /**
720
- * Time Complexity: O(1)
721
- * Space Complexity: O(1)
722
- *
723
- * @param parent
724
- * @param node
725
- */
726
- mergeWithChild(parent, node) {
727
- if (!parent.child) {
728
- parent.child = node;
729
- }
730
- else {
731
- node.right = parent.child.right;
732
- node.left = parent.child;
733
- parent.child.right.left = node;
734
- parent.child.right = node;
735
- }
736
- }
737
- /**
738
- * Time Complexity: O(log n)
739
- * Space Complexity: O(1)
740
- *
741
- * Remove and return the top element (the smallest or largest element) from the heap.
742
- * @returns The top element or undefined if the heap is empty.
743
- */
744
- poll() {
745
- return this.pop();
746
- }
747
- /**
748
- * Time Complexity: O(log n)
749
- * Space Complexity: O(1)
750
- *
751
- * Remove and return the top element (the smallest or largest element) from the heap.
752
- * @returns The top element or undefined if the heap is empty.
753
- */
754
- pop() {
755
- if (this._size === 0)
756
- return undefined;
757
- const z = this.min;
758
- if (z.child) {
759
- const elements = this.consumeLinkedList(z.child);
760
- for (const node of elements) {
761
- this.mergeWithRoot(node);
762
- node.parent = undefined;
763
- }
764
- }
765
- this.removeFromRoot(z);
766
- if (z === z.right) {
767
- this._min = undefined;
768
- this._root = undefined;
769
- }
770
- else {
771
- this._min = z.right;
772
- this._consolidate();
773
- }
774
- this._size--;
775
- return z.element;
776
- }
777
- /**
778
- * Time Complexity: O(1)
779
- * Space Complexity: O(1)
780
- *
781
- * merge two heaps. The heap that is merged will be cleared. The heap that is merged into will remain.
782
- * @param heapToMerge
783
- */
784
- merge(heapToMerge) {
785
- if (heapToMerge.size === 0) {
786
- return; // Nothing to merge
787
- }
788
- // Merge the root lists of the two heaps
789
- if (this.root && heapToMerge.root) {
790
- const thisRoot = this.root;
791
- const otherRoot = heapToMerge.root;
792
- const thisRootRight = thisRoot.right;
793
- const otherRootLeft = otherRoot.left;
794
- thisRoot.right = otherRoot;
795
- otherRoot.left = thisRoot;
796
- thisRootRight.left = otherRootLeft;
797
- otherRootLeft.right = thisRootRight;
798
- }
799
- // Update the minimum node
800
- if (!this.min || (heapToMerge.min && this.comparator(heapToMerge.min.element, this.min.element) < 0)) {
801
- this._min = heapToMerge.min;
802
- }
803
- // Update the size
804
- this._size += heapToMerge.size;
805
- // Clear the heap that was merged
806
- heapToMerge.clear();
807
- }
808
- /**
809
- * Create a new node.
810
- * @param element
811
- * @protected
812
- */
813
- createNode(element) {
814
- return new FibonacciHeapNode(element);
815
- }
816
- /**
817
- * Default comparator function used by the heap.
818
- * @param {E} a
819
- * @param {E} b
820
- * @protected
821
- */
822
- _defaultComparator(a, b) {
823
- if (a < b)
824
- return -1;
825
- if (a > b)
826
- return 1;
827
- return 0;
828
- }
829
- /**
830
- * Time Complexity: O(1)
831
- * Space Complexity: O(1)
832
- *
833
- * Merge the given node with the root list.
834
- * @param node - The node to be merged.
835
- */
836
- mergeWithRoot(node) {
837
- if (!this.root) {
838
- this._root = node;
839
- }
840
- else {
841
- node.right = this.root.right;
842
- node.left = this.root;
843
- this.root.right.left = node;
844
- this.root.right = node;
845
- }
846
- }
847
- /**
848
- * Time Complexity: O(1)
849
- * Space Complexity: O(1)
850
- *
851
- * Remove and return the top element (the smallest or largest element) from the heap.
852
- * @param node - The node to be removed.
853
- * @protected
854
- */
855
- removeFromRoot(node) {
856
- if (this.root === node)
857
- this._root = node.right;
858
- if (node.left)
859
- node.left.right = node.right;
860
- if (node.right)
861
- node.right.left = node.left;
862
- }
863
- /**
864
- * Time Complexity: O(1)
865
- * Space Complexity: O(1)
866
- *
867
- * Remove and return the top element (the smallest or largest element) from the heap.
868
- * @param y
869
- * @param x
870
- * @protected
871
- */
872
- _link(y, x) {
873
- this.removeFromRoot(y);
874
- y.left = y;
875
- y.right = y;
876
- this.mergeWithChild(x, y);
877
- x.degree++;
878
- y.parent = x;
879
- }
880
- /**
881
- * Time Complexity: O(n log n)
882
- * Space Complexity: O(n)
883
- *
884
- * Remove and return the top element (the smallest or largest element) from the heap.
885
- * @protected
886
- */
887
- _consolidate() {
888
- const A = new Array(this._size);
889
- const elements = this.consumeLinkedList(this.root);
890
- let x, y, d, t;
891
- for (const node of elements) {
892
- x = node;
893
- d = x.degree;
894
- while (A[d]) {
895
- y = A[d];
896
- if (this.comparator(x.element, y.element) > 0) {
897
- t = x;
898
- x = y;
899
- y = t;
900
- }
901
- this._link(y, x);
902
- A[d] = undefined;
903
- d++;
904
- }
905
- A[d] = x;
906
- }
907
- for (let i = 0; i < this._size; i++) {
908
- if (A[i] && this.comparator(A[i].element, this.min.element) <= 0) {
909
- this._min = A[i];
910
- }
911
- }
912
- }
913
- }
914
- //# sourceMappingURL=heap.js.map