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,880 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LinkedHashMap = exports.HashMap = void 0;
4
- const base_1 = require("../base");
5
- const utils_1 = require("../../utils");
6
- /**
7
- * 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key map to a value.
8
- * 2. Fast Lookup: It's used when you need to quickly find, insert, or delete entries based on a key.
9
- * 3. Unique Keys: Keys are unique.
10
- * If you try to insert another entry with the same key, the new one will replace the old entry.
11
- * 4. Unordered Collection: HashMap does not guarantee the order of entries, and the order may change over time.
12
- * @example
13
- * // should maintain insertion order
14
- * const linkedHashMap = new LinkedHashMap<number, string>();
15
- * linkedHashMap.set(1, 'A');
16
- * linkedHashMap.set(2, 'B');
17
- * linkedHashMap.set(3, 'C');
18
- *
19
- * const result = Array.from(linkedHashMap);
20
- * console.log(result); // [
21
- * // [1, 'A'],
22
- * // [2, 'B'],
23
- * // [3, 'C']
24
- * // ]
25
- * @example
26
- * // fast lookup of values by key
27
- * const hashMap = new HashMap<number, string>();
28
- * hashMap.set(1, 'A');
29
- * hashMap.set(2, 'B');
30
- * hashMap.set(3, 'C');
31
- *
32
- * console.log(hashMap.get(1)); // 'A'
33
- * console.log(hashMap.get(2)); // 'B'
34
- * console.log(hashMap.get(3)); // 'C'
35
- * console.log(hashMap.get(99)); // undefined
36
- * @example
37
- * // remove duplicates when adding multiple entries
38
- * const hashMap = new HashMap<number, string>();
39
- * hashMap.set(1, 'A');
40
- * hashMap.set(2, 'B');
41
- * hashMap.set(1, 'C'); // Update value for key 1
42
- *
43
- * console.log(hashMap.size); // 2
44
- * console.log(hashMap.get(1)); // 'C'
45
- * console.log(hashMap.get(2)); // 'B'
46
- * @example
47
- * // count occurrences of keys
48
- * const data = [1, 2, 1, 3, 2, 1];
49
- *
50
- * const countMap = new HashMap<number, number>();
51
- * for (const key of data) {
52
- * countMap.set(key, (countMap.get(key) || 0) + 1);
53
- * }
54
- *
55
- * console.log(countMap.get(1)); // 3
56
- * console.log(countMap.get(2)); // 2
57
- * console.log(countMap.get(3)); // 1
58
- */
59
- class HashMap extends base_1.IterableEntryBase {
60
- /**
61
- * The constructor function initializes a HashMap object with an optional initial collection and
62
- * options.
63
- * @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
64
- * `T`. It is an optional parameter and its default value is an empty array `[]`.
65
- * @param [options] - The `options` parameter is an optional object that can contain two properties:
66
- */
67
- constructor(entryOrRawElements = [], options) {
68
- super();
69
- this._store = {};
70
- this._objMap = new Map();
71
- this._size = 0;
72
- this._hashFn = (key) => String(key);
73
- if (options) {
74
- const { hashFn, toEntryFn } = options;
75
- if (hashFn)
76
- this._hashFn = hashFn;
77
- if (toEntryFn)
78
- this._toEntryFn = toEntryFn;
79
- }
80
- if (entryOrRawElements) {
81
- this.setMany(entryOrRawElements);
82
- }
83
- }
84
- /**
85
- * The function returns the store object, which is a dictionary of HashMapStoreItem objects.
86
- * @returns The store property is being returned. It is a dictionary-like object with string keys and
87
- * values of type HashMapStoreItem<K, V>.
88
- */
89
- get store() {
90
- return this._store;
91
- }
92
- /**
93
- * The function returns the object map.
94
- * @returns The `objMap` property is being returned, which is a `Map` object with keys of type
95
- * `object` and values of type `V`.
96
- */
97
- get objMap() {
98
- return this._objMap;
99
- }
100
- /**
101
- * The function returns the value of the _toEntryFn property.
102
- * @returns The function being returned is `this._toEntryFn`.
103
- */
104
- get toEntryFn() {
105
- return this._toEntryFn;
106
- }
107
- /**
108
- * The function returns the size of an object.
109
- * @returns The size of the object, which is a number.
110
- */
111
- get size() {
112
- return this._size;
113
- }
114
- /**
115
- * The hasFn function is a function that takes in an item and returns a boolean
116
- * indicating whether the item is contained within the hash table.
117
- *
118
- * @return The hash function
119
- */
120
- get hashFn() {
121
- return this._hashFn;
122
- }
123
- /**
124
- * Time Complexity: O(1)
125
- * Space Complexity: O(1)
126
- *
127
- * The function checks if a given element is an array with exactly two elements.
128
- * @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
129
- * data type.
130
- * @returns a boolean value.
131
- */
132
- isEntry(rawElement) {
133
- return Array.isArray(rawElement) && rawElement.length === 2;
134
- }
135
- /**
136
- * Time Complexity: O(1)
137
- * Space Complexity: O(1)
138
- *
139
- * The function checks if the size of an object is equal to zero and returns a boolean value.
140
- * @returns A boolean value indicating whether the size of the object is 0 or not.
141
- */
142
- isEmpty() {
143
- return this._size === 0;
144
- }
145
- /**
146
- * Time Complexity: O(1)
147
- * Space Complexity: O(1)
148
- *
149
- * The clear() function resets the state of an object by clearing its internal store, object map, and
150
- * size.
151
- */
152
- clear() {
153
- this._store = {};
154
- this._objMap.clear();
155
- this._size = 0;
156
- }
157
- /**
158
- * Time Complexity: O(1)
159
- * Space Complexity: O(1)
160
- *
161
- * The `set` function adds a key-value pair to a map-like data structure, incrementing the size if
162
- * the key is not already present.
163
- * @param {K} key - The key parameter is the key used to identify the value in the data structure. It
164
- * can be of any type, but if it is an object, it will be stored in a Map, otherwise it will be
165
- * stored in a regular JavaScript object.
166
- * @param {V} value - The value parameter represents the value that you want to associate with the
167
- * key in the data structure.
168
- */
169
- set(key, value) {
170
- if (this._isObjKey(key)) {
171
- if (!this.objMap.has(key)) {
172
- this._size++;
173
- }
174
- this.objMap.set(key, value);
175
- }
176
- else {
177
- const strKey = this._getNoObjKey(key);
178
- if (this.store[strKey] === undefined) {
179
- this._size++;
180
- }
181
- this._store[strKey] = { key, value };
182
- }
183
- return true;
184
- }
185
- /**
186
- * Time Complexity: O(k)
187
- * Space Complexity: O(k)
188
- *
189
- * The function `setMany` takes an iterable collection of objects, maps each object to a key-value
190
- * pair using a mapping function, and sets each key-value pair in the current object.
191
- * @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements of a type
192
- * `T`.
193
- * @returns The `setMany` function is returning an array of booleans.
194
- */
195
- setMany(entryOrRawElements) {
196
- const results = [];
197
- for (const rawEle of entryOrRawElements) {
198
- let key, value;
199
- if (this.isEntry(rawEle)) {
200
- key = rawEle[0];
201
- value = rawEle[1];
202
- }
203
- else if (this._toEntryFn) {
204
- const item = this._toEntryFn(rawEle);
205
- key = item[0];
206
- value = item[1];
207
- }
208
- if (key !== undefined && value !== undefined)
209
- results.push(this.set(key, value));
210
- }
211
- return results;
212
- }
213
- /**
214
- * Time Complexity: O(1)
215
- * Space Complexity: O(1)
216
- *
217
- * The `get` function retrieves a value from a map based on a given key, either from an object map or
218
- * a string map.
219
- * @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
220
- * of any type, but it should be compatible with the key type used when the map was created.
221
- * @returns The method `get(key: K)` returns a value of type `V` if the key exists in the `_objMap`
222
- * or `_store`, otherwise it returns `undefined`.
223
- */
224
- get(key) {
225
- var _a;
226
- if (this._isObjKey(key)) {
227
- return this.objMap.get(key);
228
- }
229
- else {
230
- const strKey = this._getNoObjKey(key);
231
- return (_a = this._store[strKey]) === null || _a === void 0 ? void 0 : _a.value;
232
- }
233
- }
234
- /**
235
- * Time Complexity: O(1)
236
- * Space Complexity: O(1)
237
- *
238
- * The `has` function checks if a given key exists in the `_objMap` or `_store` based on whether it
239
- * is an object key or not.
240
- * @param {K} key - The parameter "key" is of type K, which means it can be any type.
241
- * @returns The `has` method is returning a boolean value.
242
- */
243
- has(key) {
244
- if (this._isObjKey(key)) {
245
- return this.objMap.has(key);
246
- }
247
- else {
248
- const strKey = this._getNoObjKey(key);
249
- return strKey in this.store;
250
- }
251
- }
252
- /**
253
- * Time Complexity: O(1)
254
- * Space Complexity: O(1)
255
- *
256
- * The `delete` function removes an element from a map-like data structure based on the provided key.
257
- * @param {K} key - The `key` parameter is the key of the element that you want to delete from the
258
- * data structure.
259
- * @returns The `delete` method returns a boolean value. It returns `true` if the key was
260
- * successfully deleted from the map, and `false` if the key was not found in the map.
261
- */
262
- delete(key) {
263
- if (this._isObjKey(key)) {
264
- if (this.objMap.has(key)) {
265
- this._size--;
266
- }
267
- return this.objMap.delete(key);
268
- }
269
- else {
270
- const strKey = this._getNoObjKey(key);
271
- if (strKey in this.store) {
272
- delete this.store[strKey];
273
- this._size--;
274
- return true;
275
- }
276
- return false;
277
- }
278
- }
279
- /**
280
- * Time Complexity: O(n)
281
- * Space Complexity: O(n)
282
- *
283
- * The clone function creates a new HashMap with the same key-value pairs as
284
- * this one. The clone function is useful for creating a copy of an existing
285
- * HashMap, and then modifying that copy without affecting the original.
286
- *
287
- * @return A new hashmap with the same values as this one
288
- */
289
- clone() {
290
- return new HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
291
- }
292
- /**
293
- * Time Complexity: O(n)
294
- * Space Complexity: O(n)
295
- *
296
- * The `map` function in TypeScript creates a new HashMap by applying a callback function to each
297
- * key-value pair in the original HashMap.
298
- * @param callbackfn - The callback function that will be called for each key-value pair in the
299
- * HashMap. It takes four parameters:
300
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
301
- * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
302
- * be passed as the `this` value to the `callbackfn` function. If `thisArg
303
- * @returns The `map` method is returning a new `HashMap` object with the transformed values based on
304
- * the provided callback function.
305
- */
306
- map(callbackfn, thisArg) {
307
- const resultMap = new HashMap();
308
- let index = 0;
309
- for (const [key, value] of this) {
310
- resultMap.set(key, callbackfn.call(thisArg, key, value, index++, this));
311
- }
312
- return resultMap;
313
- }
314
- /**
315
- * Time Complexity: O(n)
316
- * Space Complexity: O(n)
317
- *
318
- * The `filter` function creates a new HashMap containing key-value pairs from the original HashMap
319
- * that satisfy a given predicate function.
320
- * @param predicate - The predicate parameter is a function that takes four arguments: value, key,
321
- * index, and map. It is used to determine whether an element should be included in the filtered map
322
- * or not. The function should return a boolean value - true if the element should be included, and
323
- * false otherwise.
324
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
325
- * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
326
- * passed as the `this` value to the `predicate` function. If `thisArg` is
327
- * @returns The `filter` method is returning a new `HashMap` object that contains the key-value pairs
328
- * from the original `HashMap` that pass the provided `predicate` function.
329
- */
330
- filter(predicate, thisArg) {
331
- const filteredMap = new HashMap();
332
- let index = 0;
333
- for (const [key, value] of this) {
334
- if (predicate.call(thisArg, key, value, index++, this)) {
335
- filteredMap.set(key, value);
336
- }
337
- }
338
- return filteredMap;
339
- }
340
- /**
341
- * The function returns an iterator that yields key-value pairs from both an object store and an
342
- * object map.
343
- */
344
- *_getIterator() {
345
- for (const node of Object.values(this.store)) {
346
- yield [node.key, node.value];
347
- }
348
- for (const node of this.objMap) {
349
- yield node;
350
- }
351
- }
352
- /**
353
- * The function checks if a given key is an object or a function.
354
- * @param {any} key - The parameter "key" can be of any type.
355
- * @returns a boolean value.
356
- */
357
- _isObjKey(key) {
358
- const keyType = typeof key;
359
- return (keyType === 'object' || keyType === 'function') && key !== null;
360
- }
361
- /**
362
- * The function `_getNoObjKey` takes a key and returns a string representation of the key, handling
363
- * different types of keys.
364
- * @param {K} key - The `key` parameter is of type `K`, which represents the type of the key being
365
- * passed to the `_getNoObjKey` function.
366
- * @returns a string value.
367
- */
368
- _getNoObjKey(key) {
369
- const keyType = typeof key;
370
- let strKey;
371
- if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
372
- strKey = this._hashFn(key);
373
- }
374
- else {
375
- if (keyType === 'number') {
376
- // TODO numeric key should has its own hash
377
- strKey = key;
378
- }
379
- else {
380
- strKey = key;
381
- }
382
- }
383
- return strKey;
384
- }
385
- }
386
- exports.HashMap = HashMap;
387
- /**
388
- * 1. Maintaining the Order of Element Insertion: Unlike HashMap, LinkedHashMap maintains the order in which entries are inserted. Therefore, when you traverse it, entries will be returned in the order they were inserted into the map.
389
- * 2. Based on Hash Table and Linked List: It combines the structures of a hash table and a linked list, using the hash table to ensure fast access, while maintaining the order of entries through the linked list.
390
- * 3. Time Complexity: Similar to HashMap, LinkedHashMap offers constant-time performance for get and put operations in most cases.
391
- */
392
- class LinkedHashMap extends base_1.IterableEntryBase {
393
- /**
394
- * The constructor initializes a LinkedHashMap object with an optional raw collection and options.
395
- * @param entryOrRawElements - The `entryOrRawElements` parameter is an iterable collection of elements. It is
396
- * used to initialize the HashMapLinked instance with key-value pairs. Each element in the
397
- * `entryOrRawElements` is converted to a key-value pair using the `toEntryFn` function (if provided) and
398
- * then added to the HashMap
399
- * @param [options] - The `options` parameter is an optional object that can contain the following
400
- * properties:
401
- */
402
- constructor(entryOrRawElements = [], options) {
403
- super();
404
- this._hashFn = (key) => String(key);
405
- this._objHashFn = (key) => key;
406
- this._noObjMap = {};
407
- this._objMap = new WeakMap();
408
- this._toEntryFn = (rawElement) => {
409
- if (this.isEntry(rawElement)) {
410
- // TODO, For performance optimization, it may be necessary to only inspect the first element traversed.
411
- return rawElement;
412
- }
413
- else {
414
- throw new Error("If the provided entryOrRawElements does not adhere to the [key, value] type format, the toEntryFn in the constructor's options parameter needs to specified.");
415
- }
416
- };
417
- this._size = 0;
418
- this._sentinel = {};
419
- this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
420
- if (options) {
421
- const { hashFn, objHashFn, toEntryFn } = options;
422
- if (hashFn)
423
- this._hashFn = hashFn;
424
- if (objHashFn)
425
- this._objHashFn = objHashFn;
426
- if (toEntryFn) {
427
- this._toEntryFn = toEntryFn;
428
- }
429
- }
430
- if (entryOrRawElements) {
431
- this.setMany(entryOrRawElements);
432
- }
433
- }
434
- /**
435
- * The function returns the hash function used for generating a hash value for a given key.
436
- * @returns The hash function that takes a key of type K and returns a string.
437
- */
438
- get hashFn() {
439
- return this._hashFn;
440
- }
441
- /**
442
- * The function returns the object hash function.
443
- * @returns The function `objHashFn` is being returned.
444
- */
445
- get objHashFn() {
446
- return this._objHashFn;
447
- }
448
- /**
449
- * The function returns a record of HashMapLinkedNode objects with string keys.
450
- * @returns The method is returning a Record object, which is a TypeScript type that represents an
451
- * object with string keys and values that are HashMapLinkedNode objects with keys of type K and
452
- * values of type V or undefined.
453
- */
454
- get noObjMap() {
455
- return this._noObjMap;
456
- }
457
- /**
458
- * The function returns the WeakMap object used to map objects to HashMapLinkedNode instances.
459
- * @returns The `objMap` property is being returned.
460
- */
461
- get objMap() {
462
- return this._objMap;
463
- }
464
- /**
465
- * The function returns the head node of a HashMapLinkedNode.
466
- * @returns The method `getHead()` is returning a `HashMapLinkedNode` object with key type `K` and
467
- * a value type `V | undefined`.
468
- */
469
- get head() {
470
- return this._head;
471
- }
472
- /**
473
- * The function returns the tail node of a HashMapLinkedNode.
474
- * @returns The `_tail` property of type `HashMapLinkedNode<K, V | undefined>` is being returned.
475
- */
476
- get tail() {
477
- return this._tail;
478
- }
479
- /**
480
- * The function returns the value of the _toEntryFn property.
481
- * @returns The function being returned is `this._toEntryFn`.
482
- */
483
- get toEntryFn() {
484
- return this._toEntryFn;
485
- }
486
- /**
487
- * The function returns the size of an object.
488
- * @returns The size of the object.
489
- */
490
- get size() {
491
- return this._size;
492
- }
493
- /**
494
- * Time Complexity: O(1)
495
- * Space Complexity: O(1)
496
- *
497
- * The function returns the key-value pair at the front of a data structure.
498
- * @returns The front element of the data structure, represented as a tuple with a key (K) and a
499
- * value (V).
500
- */
501
- get first() {
502
- if (this._size === 0)
503
- return;
504
- return [this.head.key, this.head.value];
505
- }
506
- /**
507
- * Time Complexity: O(1)
508
- * Space Complexity: O(1)
509
- *
510
- * The function returns the key-value pair at the end of a data structure.
511
- * @returns The method is returning an array containing the key-value pair of the tail element in the
512
- * data structure.
513
- */
514
- get last() {
515
- if (this._size === 0)
516
- return;
517
- return [this.tail.key, this.tail.value];
518
- }
519
- /**
520
- * The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
521
- */
522
- *begin() {
523
- let node = this.head;
524
- while (node !== this._sentinel) {
525
- yield [node.key, node.value];
526
- node = node.next;
527
- }
528
- }
529
- /**
530
- * The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
531
- * key and value.
532
- */
533
- *reverseBegin() {
534
- let node = this.tail;
535
- while (node !== this._sentinel) {
536
- yield [node.key, node.value];
537
- node = node.prev;
538
- }
539
- }
540
- /**
541
- * Time Complexity: O(1)
542
- * Space Complexity: O(1)
543
- *
544
- * The `set` function adds a new key-value pair to a data structure, either using an object key or a
545
- * string key.
546
- * @param {K} key - The `key` parameter is the key to be set in the data structure. It can be of any
547
- * type, but typically it is a string or symbol.
548
- * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
549
- * value associated with the key being set in the data structure.
550
- * @returns the size of the data structure after the key-value pair has been set.
551
- */
552
- set(key, value) {
553
- let node;
554
- const isNewKey = !this.has(key); // Check if the key is new
555
- if ((0, utils_1.isWeakKey)(key)) {
556
- const hash = this._objHashFn(key);
557
- node = this.objMap.get(hash);
558
- if (!node && isNewKey) {
559
- // Create a new node
560
- node = { key: hash, value, prev: this.tail, next: this._sentinel };
561
- this.objMap.set(hash, node);
562
- }
563
- else if (node) {
564
- // Update the value of an existing node
565
- node.value = value;
566
- }
567
- }
568
- else {
569
- const hash = this._hashFn(key);
570
- node = this.noObjMap[hash];
571
- if (!node && isNewKey) {
572
- this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
573
- }
574
- else if (node) {
575
- // Update the value of an existing node
576
- node.value = value;
577
- }
578
- }
579
- if (node && isNewKey) {
580
- // Update the head and tail of the linked list
581
- if (this._size === 0) {
582
- this._head = node;
583
- this._sentinel.next = node;
584
- }
585
- else {
586
- this.tail.next = node;
587
- node.prev = this.tail; // Make sure that the prev of the new node points to the current tail node
588
- }
589
- this._tail = node;
590
- this._sentinel.prev = node;
591
- this._size++;
592
- }
593
- return true;
594
- }
595
- /**
596
- * Time Complexity: O(k)
597
- * Space Complexity: O(k)
598
- *
599
- * The function `setMany` takes an iterable collection, converts each element into a key-value pair
600
- * using a provided function, and sets each key-value pair in the current object, returning an array
601
- * of booleans indicating the success of each set operation.
602
- * @param entryOrRawElements - The entryOrRawElements parameter is an iterable collection of elements of type
603
- * R.
604
- * @returns The `setMany` function returns an array of booleans.
605
- */
606
- setMany(entryOrRawElements) {
607
- const results = [];
608
- for (const rawEle of entryOrRawElements) {
609
- let key, value;
610
- if (this.isEntry(rawEle)) {
611
- key = rawEle[0];
612
- value = rawEle[1];
613
- }
614
- else if (this._toEntryFn) {
615
- const item = this._toEntryFn(rawEle);
616
- key = item[0];
617
- value = item[1];
618
- }
619
- if (key !== undefined && value !== undefined)
620
- results.push(this.set(key, value));
621
- }
622
- return results;
623
- }
624
- /**
625
- * Time Complexity: O(1)
626
- * Space Complexity: O(1)
627
- *
628
- * The function checks if a given key exists in a map, using different logic depending on whether the
629
- * key is a weak key or not.
630
- * @param {K} key - The `key` parameter is the key that is being checked for existence in the map.
631
- * @returns The method `has` is returning a boolean value.
632
- */
633
- has(key) {
634
- if ((0, utils_1.isWeakKey)(key)) {
635
- const hash = this._objHashFn(key);
636
- return this.objMap.has(hash);
637
- }
638
- else {
639
- const hash = this._hashFn(key);
640
- return hash in this.noObjMap;
641
- }
642
- }
643
- /**
644
- * Time Complexity: O(1)
645
- * Space Complexity: O(1)
646
- *
647
- * The function `get` retrieves the value associated with a given key from a map, either by using the
648
- * key directly or by using an index stored in the key object.
649
- * @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
650
- * of any type, but typically it is a string or symbol.
651
- * @returns The value associated with the given key is being returned. If the key is an object key,
652
- * the value is retrieved from the `_nodes` array using the index stored in the `OBJ_KEY_INDEX`
653
- * property of the key. If the key is a string key, the value is retrieved from the `_noObjMap` object
654
- * using the key itself. If the key is not found, `undefined` is
655
- */
656
- get(key) {
657
- if ((0, utils_1.isWeakKey)(key)) {
658
- const hash = this._objHashFn(key);
659
- const node = this.objMap.get(hash);
660
- return node ? node.value : undefined;
661
- }
662
- else {
663
- const hash = this._hashFn(key);
664
- const node = this.noObjMap[hash];
665
- return node ? node.value : undefined;
666
- }
667
- }
668
- /**
669
- * Time Complexity: O(n)
670
- * Space Complexity: O(1)
671
- *
672
- * The function `at` retrieves the key-value pair at a specified index in a linked list.
673
- * @param {number} index - The index parameter is a number that represents the position of the
674
- * element we want to retrieve from the data structure.
675
- * @returns The method `at(index: number)` is returning an array containing the key-value pair at
676
- * the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
677
- * where `K` is the key and `V` is the value.
678
- */
679
- at(index) {
680
- (0, utils_1.rangeCheck)(index, 0, this._size - 1);
681
- let node = this.head;
682
- while (index--) {
683
- node = node.next;
684
- }
685
- return node.value;
686
- }
687
- /**
688
- * Time Complexity: O(1)
689
- * Space Complexity: O(1)
690
- *
691
- * The `delete` function removes a key-value pair from a map-like data structure.
692
- * @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
693
- * It can be of any type, but typically it is a string or an object.
694
- * @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
695
- * was not found.
696
- */
697
- delete(key) {
698
- let node;
699
- if ((0, utils_1.isWeakKey)(key)) {
700
- const hash = this._objHashFn(key);
701
- // Get nodes from WeakMap
702
- node = this.objMap.get(hash);
703
- if (!node) {
704
- return false; // If the node does not exist, return false
705
- }
706
- // Remove nodes from WeakMap
707
- this.objMap.delete(hash);
708
- }
709
- else {
710
- const hash = this._hashFn(key);
711
- // Get nodes from noObjMap
712
- node = this.noObjMap[hash];
713
- if (!node) {
714
- return false; // If the node does not exist, return false
715
- }
716
- // Remove nodes from orgMap
717
- delete this.noObjMap[hash];
718
- }
719
- // Remove node from doubly linked list
720
- this._deleteNode(node);
721
- return true;
722
- }
723
- /**
724
- * Time Complexity: O(n)
725
- * Space Complexity: O(1)
726
- *
727
- * The `deleteAt` function deletes a node at a specified index in a linked list.
728
- * @param {number} index - The index parameter represents the position at which the node should be
729
- * deleted in the linked list.
730
- * @returns The size of the list after deleting the element at the specified index.
731
- */
732
- deleteAt(index) {
733
- (0, utils_1.rangeCheck)(index, 0, this._size - 1);
734
- let node = this.head;
735
- while (index--) {
736
- node = node.next;
737
- }
738
- return this._deleteNode(node);
739
- }
740
- /**
741
- * Time Complexity: O(1)
742
- * Space Complexity: O(1)
743
- *
744
- * The function checks if a data structure is empty by comparing its size to zero.
745
- * @returns The method is returning a boolean value indicating whether the size of the object is 0 or
746
- * not.
747
- */
748
- isEmpty() {
749
- return this._size === 0;
750
- }
751
- /**
752
- * The function checks if a given element is an array with exactly two elements.
753
- * @param {any} rawElement - The `rawElement` parameter is of type `any`, which means it can be any
754
- * data type.
755
- * @returns a boolean value.
756
- */
757
- isEntry(rawElement) {
758
- return Array.isArray(rawElement) && rawElement.length === 2;
759
- }
760
- /**
761
- * Time Complexity: O(1)
762
- * Space Complexity: O(1)
763
- *
764
- * The `clear` function clears all the entries in a data structure and resets its properties.
765
- */
766
- clear() {
767
- this._noObjMap = {};
768
- this._size = 0;
769
- this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
770
- }
771
- /**
772
- * Time Complexity: O(n)
773
- * Space Complexity: O(n)
774
- *
775
- * The `clone` function creates a new instance of a `LinkedHashMap` with the same key-value pairs as
776
- * the original.
777
- * @returns The `clone()` method is returning a new instance of `LinkedHashMap<K, V>` that is a clone
778
- * of the original `LinkedHashMap` object.
779
- */
780
- clone() {
781
- const cloned = new LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
782
- for (const entry of this) {
783
- const [key, value] = entry;
784
- cloned.set(key, value);
785
- }
786
- return cloned;
787
- }
788
- /**
789
- * Time Complexity: O(n)
790
- * Space Complexity: O(n)
791
- *
792
- * The `filter` function creates a new `LinkedHashMap` containing key-value pairs from the original
793
- * map that satisfy a given predicate function.
794
- * @param predicate - The `predicate` parameter is a callback function that takes four arguments:
795
- * `value`, `key`, `index`, and `this`. It should return a boolean value indicating whether the
796
- * current element should be included in the filtered map or not.
797
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
798
- * specify the value of `this` within the `predicate` function. It is used when you want to bind a
799
- * specific object as the context for the `predicate` function. If `thisArg` is not provided, `this
800
- * @returns a new `LinkedHashMap` object that contains the key-value pairs from the original
801
- * `LinkedHashMap` object that satisfy the given predicate function.
802
- */
803
- filter(predicate, thisArg) {
804
- const filteredMap = new LinkedHashMap();
805
- let index = 0;
806
- for (const [key, value] of this) {
807
- if (predicate.call(thisArg, key, value, index, this)) {
808
- filteredMap.set(key, value);
809
- }
810
- index++;
811
- }
812
- return filteredMap;
813
- }
814
- /**
815
- * Time Complexity: O(n)
816
- * Space Complexity: O(n)
817
- *
818
- * The `map` function in TypeScript creates a new `LinkedHashMap` by applying a callback function to
819
- * each key-value pair in the original map.
820
- * @param callback - The callback parameter is a function that will be called for each key-value pair
821
- * in the map. It takes four arguments: the value of the current key-value pair, the key of the
822
- * current key-value pair, the index of the current key-value pair, and the map itself. The callback
823
- * function should
824
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
825
- * specify the value of `this` within the callback function. If provided, the callback function will
826
- * be called with `thisArg` as its `this` value. If not provided, `this` will refer to the current
827
- * map
828
- * @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
829
- * function.
830
- */
831
- map(callback, thisArg) {
832
- const mappedMap = new LinkedHashMap();
833
- let index = 0;
834
- for (const [key, value] of this) {
835
- const [newKey, newValue] = callback.call(thisArg, key, value, index, this);
836
- mappedMap.set(newKey, newValue);
837
- index++;
838
- }
839
- return mappedMap;
840
- }
841
- /**
842
- * Time Complexity: O(n)
843
- * Space Complexity: O(1)
844
- * where n is the number of entries in the LinkedHashMap.
845
- *
846
- * The above function is an iterator that yields key-value pairs from a linked list.
847
- */
848
- *_getIterator() {
849
- let node = this.head;
850
- while (node !== this._sentinel) {
851
- yield [node.key, node.value];
852
- node = node.next;
853
- }
854
- }
855
- /**
856
- * Time Complexity: O(1)
857
- * Space Complexity: O(1)
858
- *
859
- * The `_deleteNode` function removes a node from a doubly linked list and updates the head and tail
860
- * pointers if necessary.
861
- * @param node - The `node` parameter is an instance of the `HashMapLinkedNode` class, which
862
- * represents a node in a linked list. It contains a key-value pair and references to the previous
863
- * and next nodes in the list.
864
- */
865
- _deleteNode(node) {
866
- const { prev, next } = node;
867
- prev.next = next;
868
- next.prev = prev;
869
- if (node === this.head) {
870
- this._head = next;
871
- }
872
- if (node === this.tail) {
873
- this._tail = prev;
874
- }
875
- this._size -= 1;
876
- return true;
877
- }
878
- }
879
- exports.LinkedHashMap = LinkedHashMap;
880
- //# sourceMappingURL=hash-map.js.map