data-structure-typed 1.54.0 → 1.54.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 (488) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -0
  3. package/benchmark/report.html +1 -28
  4. package/benchmark/report.json +17 -326
  5. package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts → cjs/data-structures/binary-tree/avl-tree-counter.d.ts} +54 -47
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +408 -0
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  8. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -177
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +135 -340
  10. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +102 -57
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js +110 -47
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +240 -190
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js +269 -240
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/bst.d.ts +145 -112
  21. package/dist/cjs/data-structures/binary-tree/bst.js +180 -129
  22. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -0
  24. package/dist/cjs/data-structures/binary-tree/index.js +2 -0
  25. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  27. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +115 -79
  28. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  29. package/dist/{mjs/data-structures/binary-tree/tree-multi-map.d.ts → cjs/data-structures/binary-tree/tree-counter.d.ts} +74 -64
  30. package/dist/cjs/data-structures/binary-tree/tree-counter.js +445 -0
  31. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -0
  32. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +78 -174
  33. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +142 -377
  34. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  35. package/dist/cjs/data-structures/graph/directed-graph.d.ts +3 -0
  36. package/dist/cjs/data-structures/graph/directed-graph.js +3 -0
  37. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  38. package/dist/cjs/data-structures/graph/map-graph.d.ts +3 -0
  39. package/dist/cjs/data-structures/graph/map-graph.js +3 -0
  40. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +3 -0
  42. package/dist/cjs/data-structures/graph/undirected-graph.js +3 -0
  43. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  44. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  45. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +3 -0
  46. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  48. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +3 -0
  49. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/matrix/matrix.d.ts +3 -0
  51. package/dist/cjs/data-structures/matrix/matrix.js +3 -0
  52. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  53. package/dist/cjs/data-structures/matrix/navigator.d.ts +3 -0
  54. package/dist/cjs/data-structures/matrix/navigator.js +3 -0
  55. package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  57. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +3 -0
  58. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  60. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +3 -0
  61. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/trie/trie.d.ts +0 -4
  63. package/dist/cjs/data-structures/trie/trie.js +0 -4
  64. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  65. package/dist/cjs/interfaces/binary-tree.d.ts +8 -8
  66. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  67. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +3 -0
  68. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  69. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  70. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  71. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  72. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -3
  73. package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -0
  74. package/dist/cjs/types/data-structures/binary-tree/index.js +2 -0
  75. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  76. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -4
  77. package/dist/cjs/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  78. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +3 -0
  79. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  80. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -4
  81. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  82. package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.js → esm/data-structures/binary-tree/avl-tree-counter.js} +73 -60
  83. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  84. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -0
  85. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +191 -0
  86. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  87. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +234 -0
  88. package/dist/{mjs → esm}/data-structures/binary-tree/avl-tree.js +110 -47
  89. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -0
  90. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  91. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  92. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  93. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.d.ts +240 -190
  94. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.js +272 -245
  95. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -0
  96. package/dist/{mjs → esm}/data-structures/binary-tree/bst.d.ts +145 -112
  97. package/dist/{mjs → esm}/data-structures/binary-tree/bst.js +201 -155
  98. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -0
  99. package/dist/{mjs → esm}/data-structures/binary-tree/index.d.ts +2 -0
  100. package/dist/{mjs → esm}/data-structures/binary-tree/index.js +2 -0
  101. package/dist/{mjs → esm}/data-structures/binary-tree/index.js.map +1 -1
  102. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  103. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.js +115 -79
  104. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -0
  105. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +212 -0
  106. package/dist/{mjs/data-structures/binary-tree/tree-multi-map.js → esm/data-structures/binary-tree/tree-counter.js} +111 -96
  107. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -0
  108. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +106 -0
  109. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +196 -0
  110. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  111. package/dist/{mjs → esm}/data-structures/graph/directed-graph.d.ts +3 -0
  112. package/dist/{mjs → esm}/data-structures/graph/directed-graph.js +3 -0
  113. package/dist/esm/data-structures/graph/directed-graph.js.map +1 -0
  114. package/dist/{mjs → esm}/data-structures/graph/map-graph.d.ts +3 -0
  115. package/dist/{mjs → esm}/data-structures/graph/map-graph.js +3 -0
  116. package/dist/esm/data-structures/graph/map-graph.js.map +1 -0
  117. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.d.ts +3 -0
  118. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.js +3 -0
  119. package/dist/esm/data-structures/graph/undirected-graph.js.map +1 -0
  120. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  121. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.js +3 -0
  122. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -0
  123. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  124. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.js +3 -0
  125. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +1 -0
  126. package/dist/{mjs → esm}/data-structures/matrix/matrix.d.ts +3 -0
  127. package/dist/{mjs → esm}/data-structures/matrix/matrix.js +3 -0
  128. package/dist/esm/data-structures/matrix/matrix.js.map +1 -0
  129. package/dist/{mjs → esm}/data-structures/matrix/navigator.d.ts +3 -0
  130. package/dist/{mjs → esm}/data-structures/matrix/navigator.js +3 -0
  131. package/dist/esm/data-structures/matrix/navigator.js.map +1 -0
  132. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  133. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.js +3 -0
  134. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  135. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  136. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.js +3 -0
  137. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  138. package/dist/{mjs → esm}/data-structures/trie/trie.d.ts +0 -4
  139. package/dist/{mjs → esm}/data-structures/trie/trie.js +0 -4
  140. package/dist/esm/data-structures/trie/trie.js.map +1 -0
  141. package/dist/esm/interfaces/binary-tree.d.ts +9 -0
  142. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  143. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  144. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  145. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  146. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  147. package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  148. package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.d.ts +3 -3
  149. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.d.ts +2 -0
  150. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js +2 -0
  151. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js.map +1 -1
  152. package/dist/esm/types/data-structures/binary-tree/rb-tree.d.ts +3 -0
  153. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  154. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +2 -0
  155. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  156. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  157. package/dist/umd/data-structure-typed.js +1464 -895
  158. package/dist/umd/data-structure-typed.min.js +5 -5
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +14 -14
  161. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  162. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +155 -393
  163. package/src/data-structures/binary-tree/avl-tree.ts +144 -93
  164. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  165. package/src/data-structures/binary-tree/binary-tree.ts +433 -405
  166. package/src/data-structures/binary-tree/bst.ts +261 -239
  167. package/src/data-structures/binary-tree/index.ts +2 -0
  168. package/src/data-structures/binary-tree/red-black-tree.ts +163 -134
  169. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  170. package/src/data-structures/binary-tree/tree-multi-map.ts +161 -429
  171. package/src/data-structures/graph/directed-graph.ts +3 -0
  172. package/src/data-structures/graph/map-graph.ts +3 -0
  173. package/src/data-structures/graph/undirected-graph.ts +3 -0
  174. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  175. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  176. package/src/data-structures/matrix/matrix.ts +3 -0
  177. package/src/data-structures/matrix/navigator.ts +3 -0
  178. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  179. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  180. package/src/data-structures/trie/trie.ts +0 -4
  181. package/src/interfaces/binary-tree.ts +10 -24
  182. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  183. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  184. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  185. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  186. package/src/types/data-structures/binary-tree/bst.ts +5 -5
  187. package/src/types/data-structures/binary-tree/index.ts +2 -0
  188. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -6
  189. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  190. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -6
  191. package/test/integration/all-in-one.test.ts +1 -1
  192. package/test/integration/avl-tree.test.ts +1 -1
  193. package/test/integration/bst.test.ts +2 -2
  194. package/test/integration/compile.js +144 -0
  195. package/test/integration/compile.ts +171 -0
  196. package/test/integration/index.html +48 -48
  197. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
  198. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +5 -4
  199. package/test/performance/data-structures/comparison/comparison.test.ts +2 -2
  200. package/test/performance/reportor.ts +5 -3
  201. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +877 -0
  202. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +459 -761
  203. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +223 -223
  204. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +474 -492
  205. package/test/unit/data-structures/binary-tree/bst.test.ts +1 -1
  206. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -3
  207. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +87 -90
  208. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +975 -0
  209. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +729 -857
  210. package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
  211. package/{tsconfig-mjs.json → tsconfig-esm.json} +1 -1
  212. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  213. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -189
  214. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  215. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  216. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  217. package/dist/mjs/data-structures/binary-tree/bst.js.map +0 -1
  218. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  219. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  220. package/dist/mjs/data-structures/graph/directed-graph.js.map +0 -1
  221. package/dist/mjs/data-structures/graph/map-graph.js.map +0 -1
  222. package/dist/mjs/data-structures/graph/undirected-graph.js.map +0 -1
  223. package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  224. package/dist/mjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  225. package/dist/mjs/data-structures/matrix/matrix.js.map +0 -1
  226. package/dist/mjs/data-structures/matrix/navigator.js.map +0 -1
  227. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  228. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  229. package/dist/mjs/data-structures/trie/trie.js.map +0 -1
  230. package/dist/mjs/interfaces/binary-tree.d.ts +0 -9
  231. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -5
  232. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -5
  233. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  234. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -5
  235. /package/dist/{mjs → esm}/common/index.d.ts +0 -0
  236. /package/dist/{mjs → esm}/common/index.js +0 -0
  237. /package/dist/{mjs → esm}/common/index.js.map +0 -0
  238. /package/dist/{mjs → esm}/data-structures/base/index.d.ts +0 -0
  239. /package/dist/{mjs → esm}/data-structures/base/index.js +0 -0
  240. /package/dist/{mjs → esm}/data-structures/base/index.js.map +0 -0
  241. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.d.ts +0 -0
  242. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js +0 -0
  243. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js.map +0 -0
  244. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.d.ts +0 -0
  245. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js +0 -0
  246. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js.map +0 -0
  247. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  248. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js +0 -0
  249. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js.map +0 -0
  250. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.d.ts +0 -0
  251. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js +0 -0
  252. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js.map +0 -0
  253. /package/dist/{mjs → esm}/data-structures/graph/index.d.ts +0 -0
  254. /package/dist/{mjs → esm}/data-structures/graph/index.js +0 -0
  255. /package/dist/{mjs → esm}/data-structures/graph/index.js.map +0 -0
  256. /package/dist/{mjs → esm}/data-structures/hash/hash-map.d.ts +0 -0
  257. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js +0 -0
  258. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js.map +0 -0
  259. /package/dist/{mjs → esm}/data-structures/hash/index.d.ts +0 -0
  260. /package/dist/{mjs → esm}/data-structures/hash/index.js +0 -0
  261. /package/dist/{mjs → esm}/data-structures/hash/index.js.map +0 -0
  262. /package/dist/{mjs → esm}/data-structures/heap/heap.d.ts +0 -0
  263. /package/dist/{mjs → esm}/data-structures/heap/heap.js +0 -0
  264. /package/dist/{mjs → esm}/data-structures/heap/heap.js.map +0 -0
  265. /package/dist/{mjs → esm}/data-structures/heap/index.d.ts +0 -0
  266. /package/dist/{mjs → esm}/data-structures/heap/index.js +0 -0
  267. /package/dist/{mjs → esm}/data-structures/heap/index.js.map +0 -0
  268. /package/dist/{mjs → esm}/data-structures/heap/max-heap.d.ts +0 -0
  269. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js +0 -0
  270. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js.map +0 -0
  271. /package/dist/{mjs → esm}/data-structures/heap/min-heap.d.ts +0 -0
  272. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js +0 -0
  273. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js.map +0 -0
  274. /package/dist/{mjs → esm}/data-structures/index.d.ts +0 -0
  275. /package/dist/{mjs → esm}/data-structures/index.js +0 -0
  276. /package/dist/{mjs → esm}/data-structures/index.js.map +0 -0
  277. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  278. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js +0 -0
  279. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  280. /package/dist/{mjs → esm}/data-structures/linked-list/index.d.ts +0 -0
  281. /package/dist/{mjs → esm}/data-structures/linked-list/index.js +0 -0
  282. /package/dist/{mjs → esm}/data-structures/linked-list/index.js.map +0 -0
  283. /package/dist/{mjs → esm}/data-structures/matrix/index.d.ts +0 -0
  284. /package/dist/{mjs → esm}/data-structures/matrix/index.js +0 -0
  285. /package/dist/{mjs → esm}/data-structures/matrix/index.js.map +0 -0
  286. /package/dist/{mjs → esm}/data-structures/priority-queue/index.d.ts +0 -0
  287. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js +0 -0
  288. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js.map +0 -0
  289. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  290. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js +0 -0
  291. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js.map +0 -0
  292. /package/dist/{mjs → esm}/data-structures/queue/deque.d.ts +0 -0
  293. /package/dist/{mjs → esm}/data-structures/queue/deque.js +0 -0
  294. /package/dist/{mjs → esm}/data-structures/queue/deque.js.map +0 -0
  295. /package/dist/{mjs → esm}/data-structures/queue/index.d.ts +0 -0
  296. /package/dist/{mjs → esm}/data-structures/queue/index.js +0 -0
  297. /package/dist/{mjs → esm}/data-structures/queue/index.js.map +0 -0
  298. /package/dist/{mjs → esm}/data-structures/queue/queue.d.ts +0 -0
  299. /package/dist/{mjs → esm}/data-structures/queue/queue.js +0 -0
  300. /package/dist/{mjs → esm}/data-structures/queue/queue.js.map +0 -0
  301. /package/dist/{mjs → esm}/data-structures/stack/index.d.ts +0 -0
  302. /package/dist/{mjs → esm}/data-structures/stack/index.js +0 -0
  303. /package/dist/{mjs → esm}/data-structures/stack/index.js.map +0 -0
  304. /package/dist/{mjs → esm}/data-structures/stack/stack.d.ts +0 -0
  305. /package/dist/{mjs → esm}/data-structures/stack/stack.js +0 -0
  306. /package/dist/{mjs → esm}/data-structures/stack/stack.js.map +0 -0
  307. /package/dist/{mjs → esm}/data-structures/tree/index.d.ts +0 -0
  308. /package/dist/{mjs → esm}/data-structures/tree/index.js +0 -0
  309. /package/dist/{mjs → esm}/data-structures/tree/index.js.map +0 -0
  310. /package/dist/{mjs → esm}/data-structures/tree/tree.d.ts +0 -0
  311. /package/dist/{mjs → esm}/data-structures/tree/tree.js +0 -0
  312. /package/dist/{mjs → esm}/data-structures/tree/tree.js.map +0 -0
  313. /package/dist/{mjs → esm}/data-structures/trie/index.d.ts +0 -0
  314. /package/dist/{mjs → esm}/data-structures/trie/index.js +0 -0
  315. /package/dist/{mjs → esm}/data-structures/trie/index.js.map +0 -0
  316. /package/dist/{mjs → esm}/index.d.ts +0 -0
  317. /package/dist/{mjs → esm}/index.js +0 -0
  318. /package/dist/{mjs → esm}/index.js.map +0 -0
  319. /package/dist/{mjs → esm}/interfaces/binary-tree.js +0 -0
  320. /package/dist/{mjs → esm}/interfaces/binary-tree.js.map +0 -0
  321. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.d.ts +0 -0
  322. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js +0 -0
  323. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js.map +0 -0
  324. /package/dist/{mjs → esm}/interfaces/graph.d.ts +0 -0
  325. /package/dist/{mjs → esm}/interfaces/graph.js +0 -0
  326. /package/dist/{mjs → esm}/interfaces/graph.js.map +0 -0
  327. /package/dist/{mjs → esm}/interfaces/heap.d.ts +0 -0
  328. /package/dist/{mjs → esm}/interfaces/heap.js +0 -0
  329. /package/dist/{mjs → esm}/interfaces/heap.js.map +0 -0
  330. /package/dist/{mjs → esm}/interfaces/index.d.ts +0 -0
  331. /package/dist/{mjs → esm}/interfaces/index.js +0 -0
  332. /package/dist/{mjs → esm}/interfaces/index.js.map +0 -0
  333. /package/dist/{mjs → esm}/interfaces/navigator.d.ts +0 -0
  334. /package/dist/{mjs → esm}/interfaces/navigator.js +0 -0
  335. /package/dist/{mjs → esm}/interfaces/navigator.js.map +0 -0
  336. /package/dist/{mjs → esm}/interfaces/priority-queue.d.ts +0 -0
  337. /package/dist/{mjs → esm}/interfaces/priority-queue.js +0 -0
  338. /package/dist/{mjs → esm}/interfaces/priority-queue.js.map +0 -0
  339. /package/dist/{mjs → esm}/interfaces/segment-tree.d.ts +0 -0
  340. /package/dist/{mjs → esm}/interfaces/segment-tree.js +0 -0
  341. /package/dist/{mjs → esm}/interfaces/segment-tree.js.map +0 -0
  342. /package/dist/{mjs → esm}/interfaces/singly-linked-list.d.ts +0 -0
  343. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js +0 -0
  344. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js.map +0 -0
  345. /package/dist/{mjs → esm}/types/common.d.ts +0 -0
  346. /package/dist/{mjs → esm}/types/common.js +0 -0
  347. /package/dist/{mjs → esm}/types/common.js.map +0 -0
  348. /package/dist/{mjs → esm}/types/data-structures/base/base.d.ts +0 -0
  349. /package/dist/{mjs → esm}/types/data-structures/base/base.js +0 -0
  350. /package/dist/{mjs → esm}/types/data-structures/base/base.js.map +0 -0
  351. /package/dist/{mjs → esm}/types/data-structures/base/index.d.ts +0 -0
  352. /package/dist/{mjs → esm}/types/data-structures/base/index.js +0 -0
  353. /package/dist/{mjs → esm}/types/data-structures/base/index.js.map +0 -0
  354. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -0
  355. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -0
  356. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js +0 -0
  357. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js.map +0 -0
  358. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  359. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js +0 -0
  360. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -0
  361. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js +0 -0
  362. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js.map +0 -0
  363. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js +0 -0
  364. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js.map +0 -0
  365. /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js +0 -0
  366. /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js.map +0 -0
  367. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  368. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js +0 -0
  369. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js.map +0 -0
  370. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js +0 -0
  371. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js.map +0 -0
  372. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  373. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js +0 -0
  374. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js.map +0 -0
  375. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.d.ts +0 -0
  376. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js +0 -0
  377. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js.map +0 -0
  378. /package/dist/{mjs → esm}/types/data-structures/graph/index.d.ts +0 -0
  379. /package/dist/{mjs → esm}/types/data-structures/graph/index.js +0 -0
  380. /package/dist/{mjs → esm}/types/data-structures/graph/index.js.map +0 -0
  381. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.d.ts +0 -0
  382. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js +0 -0
  383. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js.map +0 -0
  384. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  385. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js +0 -0
  386. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js.map +0 -0
  387. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.d.ts +0 -0
  388. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js +0 -0
  389. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js.map +0 -0
  390. /package/dist/{mjs → esm}/types/data-structures/hash/index.d.ts +0 -0
  391. /package/dist/{mjs → esm}/types/data-structures/hash/index.js +0 -0
  392. /package/dist/{mjs → esm}/types/data-structures/hash/index.js.map +0 -0
  393. /package/dist/{mjs → esm}/types/data-structures/heap/heap.d.ts +0 -0
  394. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js +0 -0
  395. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js.map +0 -0
  396. /package/dist/{mjs → esm}/types/data-structures/heap/index.d.ts +0 -0
  397. /package/dist/{mjs → esm}/types/data-structures/heap/index.js +0 -0
  398. /package/dist/{mjs → esm}/types/data-structures/heap/index.js.map +0 -0
  399. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.d.ts +0 -0
  400. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js +0 -0
  401. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js.map +0 -0
  402. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.d.ts +0 -0
  403. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js +0 -0
  404. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js.map +0 -0
  405. /package/dist/{mjs → esm}/types/data-structures/index.d.ts +0 -0
  406. /package/dist/{mjs → esm}/types/data-structures/index.js +0 -0
  407. /package/dist/{mjs → esm}/types/data-structures/index.js.map +0 -0
  408. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  409. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js +0 -0
  410. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  411. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.d.ts +0 -0
  412. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js +0 -0
  413. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js.map +0 -0
  414. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  415. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js +0 -0
  416. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js.map +0 -0
  417. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  418. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js +0 -0
  419. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js.map +0 -0
  420. /package/dist/{mjs → esm}/types/data-structures/matrix/index.d.ts +0 -0
  421. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js +0 -0
  422. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js.map +0 -0
  423. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.d.ts +0 -0
  424. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js +0 -0
  425. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js.map +0 -0
  426. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.d.ts +0 -0
  427. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js +0 -0
  428. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js.map +0 -0
  429. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.d.ts +0 -0
  430. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js +0 -0
  431. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js.map +0 -0
  432. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  433. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js +0 -0
  434. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js.map +0 -0
  435. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  436. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js +0 -0
  437. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js.map +0 -0
  438. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  439. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js +0 -0
  440. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js.map +0 -0
  441. /package/dist/{mjs → esm}/types/data-structures/queue/deque.d.ts +0 -0
  442. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js +0 -0
  443. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js.map +0 -0
  444. /package/dist/{mjs → esm}/types/data-structures/queue/index.d.ts +0 -0
  445. /package/dist/{mjs → esm}/types/data-structures/queue/index.js +0 -0
  446. /package/dist/{mjs → esm}/types/data-structures/queue/index.js.map +0 -0
  447. /package/dist/{mjs → esm}/types/data-structures/queue/queue.d.ts +0 -0
  448. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js +0 -0
  449. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js.map +0 -0
  450. /package/dist/{mjs → esm}/types/data-structures/stack/index.d.ts +0 -0
  451. /package/dist/{mjs → esm}/types/data-structures/stack/index.js +0 -0
  452. /package/dist/{mjs → esm}/types/data-structures/stack/index.js.map +0 -0
  453. /package/dist/{mjs → esm}/types/data-structures/stack/stack.d.ts +0 -0
  454. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js +0 -0
  455. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js.map +0 -0
  456. /package/dist/{mjs → esm}/types/data-structures/tree/index.d.ts +0 -0
  457. /package/dist/{mjs → esm}/types/data-structures/tree/index.js +0 -0
  458. /package/dist/{mjs → esm}/types/data-structures/tree/index.js.map +0 -0
  459. /package/dist/{mjs → esm}/types/data-structures/tree/tree.d.ts +0 -0
  460. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js +0 -0
  461. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js.map +0 -0
  462. /package/dist/{mjs → esm}/types/data-structures/trie/index.d.ts +0 -0
  463. /package/dist/{mjs → esm}/types/data-structures/trie/index.js +0 -0
  464. /package/dist/{mjs → esm}/types/data-structures/trie/index.js.map +0 -0
  465. /package/dist/{mjs → esm}/types/data-structures/trie/trie.d.ts +0 -0
  466. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js +0 -0
  467. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js.map +0 -0
  468. /package/dist/{mjs → esm}/types/index.d.ts +0 -0
  469. /package/dist/{mjs → esm}/types/index.js +0 -0
  470. /package/dist/{mjs → esm}/types/index.js.map +0 -0
  471. /package/dist/{mjs → esm}/types/utils/index.d.ts +0 -0
  472. /package/dist/{mjs → esm}/types/utils/index.js +0 -0
  473. /package/dist/{mjs → esm}/types/utils/index.js.map +0 -0
  474. /package/dist/{mjs → esm}/types/utils/utils.d.ts +0 -0
  475. /package/dist/{mjs → esm}/types/utils/utils.js +0 -0
  476. /package/dist/{mjs → esm}/types/utils/utils.js.map +0 -0
  477. /package/dist/{mjs → esm}/types/utils/validate-type.d.ts +0 -0
  478. /package/dist/{mjs → esm}/types/utils/validate-type.js +0 -0
  479. /package/dist/{mjs → esm}/types/utils/validate-type.js.map +0 -0
  480. /package/dist/{mjs → esm}/utils/index.d.ts +0 -0
  481. /package/dist/{mjs → esm}/utils/index.js +0 -0
  482. /package/dist/{mjs → esm}/utils/index.js.map +0 -0
  483. /package/dist/{mjs → esm}/utils/number.d.ts +0 -0
  484. /package/dist/{mjs → esm}/utils/number.js +0 -0
  485. /package/dist/{mjs → esm}/utils/number.js.map +0 -0
  486. /package/dist/{mjs → esm}/utils/utils.d.ts +0 -0
  487. /package/dist/{mjs → esm}/utils/utils.js +0 -0
  488. /package/dist/{mjs → esm}/utils/utils.js.map +0 -0
@@ -1,5 +1,5 @@
1
1
  import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
2
- export class TreeMultiMapNode extends RedBlackTreeNode {
2
+ export class TreeCounterNode extends RedBlackTreeNode {
3
3
  /**
4
4
  * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
5
5
  * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
@@ -16,15 +16,39 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
16
16
  super(key, value, color);
17
17
  this.count = count;
18
18
  }
19
+ parent = undefined;
20
+ _left = undefined;
21
+ get left() {
22
+ return this._left;
23
+ }
24
+ set left(v) {
25
+ if (v) {
26
+ v.parent = this;
27
+ }
28
+ this._left = v;
29
+ }
30
+ _right = undefined;
31
+ get right() {
32
+ return this._right;
33
+ }
34
+ set right(v) {
35
+ if (v) {
36
+ v.parent = this;
37
+ }
38
+ this._right = v;
39
+ }
19
40
  }
20
- export class TreeMultiMap extends RedBlackTree {
41
+ /**
42
+ *
43
+ */
44
+ export class TreeCounter extends RedBlackTree {
21
45
  /**
22
- * The constructor function initializes a TreeMultiMap object with optional initial data.
46
+ * The constructor function initializes a TreeCounter object with optional initial data.
23
47
  * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
24
48
  * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
25
- * TreeMultiMap with initial data.
49
+ * TreeCounter with initial data.
26
50
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
27
- * behavior of the `TreeMultiMap` constructor. It can include properties such as `compareKeys` and
51
+ * behavior of the `TreeCounter` constructor. It can include properties such as `compareKeys` and
28
52
  * `compareValues`, which are functions used to compare keys and values respectively.
29
53
  */
30
54
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -55,7 +79,7 @@ export class TreeMultiMap extends RedBlackTree {
55
79
  return sum;
56
80
  }
57
81
  /**
58
- * The function creates a new TreeMultiMapNode with the specified key, value, color, and count.
82
+ * The function creates a new TreeCounterNode with the specified key, value, color, and count.
59
83
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
60
84
  * which is a generic type representing the type of keys in the tree.
61
85
  * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
@@ -65,72 +89,37 @@ export class TreeMultiMap extends RedBlackTree {
65
89
  * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
66
90
  * the tree. It is an optional parameter and is used to keep track of the number of values associated
67
91
  * with a key in the tree.
68
- * @returns A new instance of the TreeMultiMapNode class, casted as NODE.
92
+ * @returns A new instance of the TreeCounterNode class, casted as TreeCounterNode<K, V>.
69
93
  */
70
94
  createNode(key, value, color = 'BLACK', count) {
71
- return new TreeMultiMapNode(key, this._isMapMode ? undefined : value, count, color);
95
+ return new TreeCounterNode(key, this._isMapMode ? undefined : value, count, color);
72
96
  }
73
97
  /**
74
- * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
98
+ * The function creates a new instance of a TreeCounter with the specified options and returns it.
75
99
  * @param [options] - The `options` parameter is an optional object that contains additional
76
- * configuration options for creating the `TreeMultiMap`. It is of type `TreeMultiMapOptions<K, V,
100
+ * configuration options for creating the `TreeCounter`. It is of type `TreeCounterOptions<K, V,
77
101
  * R>`.
78
- * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
102
+ * @returns a new instance of the `TreeCounter` class, with the provided options merged with the
79
103
  * existing `iterationType` property. The returned value is casted as `TREE`.
80
104
  */
81
105
  createTree(options) {
82
- return new TreeMultiMap([], {
106
+ return new TreeCounter([], {
83
107
  iterationType: this.iterationType,
84
- isMapMode: this._isMapMode,
85
108
  specifyComparable: this._specifyComparable,
109
+ isMapMode: this._isMapMode,
86
110
  toEntryFn: this._toEntryFn,
87
111
  ...options
88
112
  });
89
113
  }
90
114
  /**
91
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
92
- * node based on the input.
93
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
94
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
95
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
96
- * associated with the key in the node. It is used when creating a new node or updating the value of
97
- * an existing node.
98
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
99
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
100
- * @returns either a NODE object or undefined.
101
- */
102
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
103
- if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
104
- return [undefined, undefined];
105
- if (this.isNode(keyNodeEntryOrRaw))
106
- return [keyNodeEntryOrRaw, value];
107
- if (this.isEntry(keyNodeEntryOrRaw)) {
108
- const [key, entryValue] = keyNodeEntryOrRaw;
109
- if (key === undefined || key === null)
110
- return [undefined, undefined];
111
- const finalValue = value ?? entryValue;
112
- if (this.isKey(key))
113
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
114
- }
115
- if (this.isRaw(keyNodeEntryOrRaw)) {
116
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
117
- const finalValue = value ?? entryValue;
118
- if (this.isKey(key))
119
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
120
- }
121
- if (this.isKey(keyNodeEntryOrRaw))
122
- return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
123
- return [undefined, undefined];
124
- }
125
- /**
126
- * The function checks if the input is an instance of the TreeMultiMapNode class.
127
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
128
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
129
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
130
- * an instance of the `TreeMultiMapNode` class.
115
+ * The function checks if the input is an instance of the TreeCounterNode class.
116
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
117
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
118
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
119
+ * an instance of the `TreeCounterNode` class.
131
120
  */
132
- isNode(keyNodeEntryOrRaw) {
133
- return keyNodeEntryOrRaw instanceof TreeMultiMapNode;
121
+ isNode(keyNodeOrEntry) {
122
+ return keyNodeOrEntry instanceof TreeCounterNode;
134
123
  }
135
124
  /**
136
125
  * Time Complexity: O(log n)
@@ -138,8 +127,8 @@ export class TreeMultiMap extends RedBlackTree {
138
127
  *
139
128
  * The function overrides the add method of a class and adds a new node to a data structure, updating
140
129
  * the count and returning a boolean indicating success.
141
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
142
- * `keyNodeEntryOrRaw` parameter can accept one of the following types:
130
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The
131
+ * `keyNodeOrEntry` parameter can accept one of the following types:
143
132
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
144
133
  * data structure. It is an optional parameter, so it can be omitted if not needed.
145
134
  * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
@@ -148,8 +137,8 @@ export class TreeMultiMap extends RedBlackTree {
148
137
  * @returns The method is returning a boolean value. It returns true if the addition of the new node
149
138
  * was successful, and false otherwise.
150
139
  */
151
- add(keyNodeEntryOrRaw, value, count = 1) {
152
- const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count);
140
+ add(keyNodeOrEntry, value, count = 1) {
141
+ const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
153
142
  const orgCount = newNode?.count || 0;
154
143
  const isSuccessAdded = super.add(newNode, newValue);
155
144
  if (isSuccessAdded) {
@@ -166,24 +155,24 @@ export class TreeMultiMap extends RedBlackTree {
166
155
  *
167
156
  * The function `delete` in TypeScript overrides the deletion operation in a binary tree data
168
157
  * structure, handling cases where nodes have children and maintaining balance in the tree.
169
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `predicate`
158
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The `predicate`
170
159
  * parameter in the `delete` method is used to specify the condition or key based on which a node
171
160
  * should be deleted from the binary tree. It can be a key, a node, or an entry.
172
161
  * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
173
162
  * boolean flag that determines whether to ignore the count of nodes when performing deletion. If
174
163
  * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
175
164
  * `ignoreCount` is `false
176
- * @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<NODE>` objects.
165
+ * @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<TreeCounterNode<K, V>>` objects.
177
166
  */
178
- delete(keyNodeEntryOrRaw, ignoreCount = false) {
179
- if (keyNodeEntryOrRaw === null)
167
+ delete(keyNodeOrEntry, ignoreCount = false) {
168
+ if (keyNodeOrEntry === null)
180
169
  return [];
181
170
  const results = [];
182
171
  let nodeToDelete;
183
- if (this._isPredicate(keyNodeEntryOrRaw))
184
- nodeToDelete = this.getNode(keyNodeEntryOrRaw);
172
+ if (this._isPredicate(keyNodeOrEntry))
173
+ nodeToDelete = this.getNode(keyNodeOrEntry);
185
174
  else
186
- nodeToDelete = this.isRealNode(keyNodeEntryOrRaw) ? keyNodeEntryOrRaw : this.getNode(keyNodeEntryOrRaw);
175
+ nodeToDelete = this.isRealNode(keyNodeOrEntry) ? keyNodeOrEntry : this.getNode(keyNodeOrEntry);
187
176
  if (!nodeToDelete) {
188
177
  return results;
189
178
  }
@@ -352,16 +341,65 @@ export class TreeMultiMap extends RedBlackTree {
352
341
  cloned._store = this._store;
353
342
  return cloned;
354
343
  }
344
+ /**
345
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeCounter with
346
+ * modified entries based on a provided callback.
347
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
348
+ * map. It takes four arguments:
349
+ * @param [options] - The `options` parameter in the `override map` function is of type
350
+ * `TreeCounterOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
351
+ * options when creating a new `TreeCounter` instance within the `map` function. These options could
352
+ * include things like
353
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
354
+ * the value of `this` when executing the `callback` function. It allows you to set the context
355
+ * (value of `this`) for the callback function when it is called within the `map` function. This
356
+ * @returns A new TreeCounter instance is being returned, which is populated with entries generated
357
+ * by the provided callback function.
358
+ */
359
+ map(callback, options, thisArg) {
360
+ const newTree = new TreeCounter([], options);
361
+ let index = 0;
362
+ for (const [key, value] of this) {
363
+ newTree.add(callback.call(thisArg, key, value, index++, this));
364
+ }
365
+ return newTree;
366
+ }
367
+ /**
368
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
369
+ * node based on the input.
370
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
371
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
372
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
373
+ * associated with the key in the node. It is used when creating a new node or updating the value of
374
+ * an existing node.
375
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
376
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
377
+ * @returns either a TreeCounterNode<K, V> object or undefined.
378
+ */
379
+ _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
380
+ if (keyNodeOrEntry === undefined || keyNodeOrEntry === null)
381
+ return [undefined, undefined];
382
+ if (this.isNode(keyNodeOrEntry))
383
+ return [keyNodeOrEntry, value];
384
+ if (this.isEntry(keyNodeOrEntry)) {
385
+ const [key, entryValue] = keyNodeOrEntry;
386
+ if (key === undefined || key === null)
387
+ return [undefined, undefined];
388
+ const finalValue = value ?? entryValue;
389
+ return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
390
+ }
391
+ return [this.createNode(keyNodeOrEntry, value, 'BLACK', count), value];
392
+ }
355
393
  /**
356
394
  * Time Complexity: O(1)
357
395
  * Space Complexity: O(1)
358
396
  *
359
397
  * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
360
398
  * in a binary search tree.
361
- * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
399
+ * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} srcNode - The `srcNode` parameter represents the source node
362
400
  * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
363
- * instance of the `BSTNOptKeyOrNode<K, NODE>` class.
364
- * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
401
+ * instance of the `BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>` class.
402
+ * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} destNode - The `destNode` parameter represents the destination
365
403
  * node where the properties will be swapped with the source node.
366
404
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
367
405
  * If either `srcNode` or `destNode` is undefined, it returns undefined.
@@ -394,38 +432,15 @@ export class TreeMultiMap extends RedBlackTree {
394
432
  * Space Complexity: O(1)
395
433
  *
396
434
  * The function replaces an old node with a new node and updates the count property of the new node.
397
- * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace in the data
435
+ * @param {TreeCounterNode<K, V>} oldNode - The `oldNode` parameter is the node that you want to replace in the data
398
436
  * structure.
399
- * @param {NODE} newNode - The `newNode` parameter is an instance of the `NODE` class.
437
+ * @param {TreeCounterNode<K, V>} newNode - The `newNode` parameter is an instance of the `TreeCounterNode<K, V>` class.
400
438
  * @returns The method is returning the result of calling the `_replaceNode` method from the
401
- * superclass, which is of type `NODE`.
439
+ * superclass, which is of type `TreeCounterNode<K, V>`.
402
440
  */
403
441
  _replaceNode(oldNode, newNode) {
404
442
  newNode.count = oldNode.count + newNode.count;
405
443
  return super._replaceNode(oldNode, newNode);
406
444
  }
407
- /**
408
- * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
409
- * modified entries based on a provided callback.
410
- * @param callback - The `callback` parameter is a function that will be called for each entry in the
411
- * map. It takes four arguments:
412
- * @param [options] - The `options` parameter in the `override map` function is of type
413
- * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
414
- * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
415
- * include things like
416
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
417
- * the value of `this` when executing the `callback` function. It allows you to set the context
418
- * (value of `this`) for the callback function when it is called within the `map` function. This
419
- * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
420
- * by the provided callback function.
421
- */
422
- map(callback, options, thisArg) {
423
- const newTree = new TreeMultiMap([], options);
424
- let index = 0;
425
- for (const [key, value] of this) {
426
- newTree.add(callback.call(thisArg, key, value, index++, this));
427
- }
428
- return newTree;
429
- }
430
445
  }
431
- //# sourceMappingURL=tree-multi-map.js.map
446
+ //# sourceMappingURL=tree-counter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-counter.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-counter.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,eAAkC,SAAQ,gBAAsB;IAC3E;;;;;;;;;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Q,CAAC,GAAG,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBACrD,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC/B,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;YACjC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACgB,YAAY,CAC7B,OAA8B,EAC9B,OAA8B;QAE9B,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import type { BTNRep, OptNodeOrNull, TreeMultiMapOptions } from '../../types';
9
+ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
10
+ import { IBinaryTree } from '../../interfaces';
11
+ export declare class TreeMultiMapNode<K = any, V = any> extends RedBlackTreeNode<K, V[]> {
12
+ /**
13
+ * This TypeScript constructor initializes an object with a key of type K and an array of values of
14
+ * type V.
15
+ * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
16
+ * data being stored in the data structure. It helps in quickly accessing or retrieving the
17
+ * associated value in the data structure.
18
+ * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
19
+ * type `V`.
20
+ */
21
+ constructor(key: K, value: V[]);
22
+ parent?: TreeMultiMapNode<K, V>;
23
+ _left?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
24
+ get left(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
25
+ set left(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
26
+ _right?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
27
+ get right(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
28
+ set right(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
29
+ }
30
+ /**
31
+ *
32
+ * @example
33
+ * // Find elements in a range
34
+ * const tmm = new TreeMultiMap<number>([10, 5, 15, 3, 7, 12, 18]);
35
+ * console.log(tmm.search(new Range(5, 10))); // [5, 10, 7]
36
+ * console.log(tmm.search(new Range(4, 12))); // [5, 10, 12, 7]
37
+ * console.log(tmm.search(new Range(15, 20))); // [15, 18]
38
+ */
39
+ export declare class TreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends RedBlackTree<K, V[], R, MK, MV[], MR> implements IBinaryTree<K, V[], R, MK, MV, MR> {
40
+ /**
41
+ * The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
42
+ * and options.
43
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
44
+ * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
45
+ * TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
46
+ * the RedBlackTreeMulti
47
+ * @param [options] - The `options` parameter in the constructor is of type
48
+ * `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
49
+ * additional options for configuring the TreeMultiMap instance.
50
+ */
51
+ constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V[], TreeMultiMapNode<K, V>> | R>, options?: TreeMultiMapOptions<K, V[], R>);
52
+ /**
53
+ * Time Complexity: O(1)
54
+ * Space Complexity: O(1)
55
+ *
56
+ * The `createTree` function in TypeScript overrides the default implementation to create a new
57
+ * TreeMultiMap with specified options.
58
+ * @param [options] - The `options` parameter in the `createTree` method is of type
59
+ * `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
60
+ * options when creating a new `TreeMultiMap` instance. It includes properties such as
61
+ * `iterationType`, `specifyComparable
62
+ * @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
63
+ * data and the provided options merged with the existing properties of the current object.
64
+ */
65
+ createTree(options?: TreeMultiMapOptions<K, V[], R>): TreeMultiMap<K, V, R, MK, MV, MR>;
66
+ /**
67
+ * Time Complexity: O(1)
68
+ * Space Complexity: O(1)
69
+ *
70
+ * The function `createNode` overrides the method to create a new `TreeMultiMapNode` with a specified
71
+ * key and an empty array of values.
72
+ * @param {K} key - The `key` parameter in the `createNode` method represents the key of the node
73
+ * that will be created in the TreeMultiMap data structure.
74
+ * @returns A new instance of `TreeMultiMapNode<K, V>` is being returned, with the specified key and
75
+ * an empty array as its value.
76
+ */
77
+ createNode(key: K): TreeMultiMapNode<K, V>;
78
+ add(node: BTNRep<K, V[], TreeMultiMapNode<K, V>>): boolean;
79
+ add(key: K, value: V): boolean;
80
+ /**
81
+ * Time Complexity: O(log n)
82
+ * Space Complexity: O(log n)
83
+ *
84
+ * The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
85
+ * and deletes the entire node if no values are left for that key.
86
+ * @param {BTNRep<K, V[], TreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
87
+ * parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
88
+ * array of values, or just a key itself.
89
+ * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
90
+ * value that you want to remove from the multi-map data structure associated with a particular key.
91
+ * The function checks if the value exists in the array of values associated with the key, and if
92
+ * found, removes it from the array.
93
+ * @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
94
+ * successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
95
+ */
96
+ deleteValue(keyNodeOrEntry: BTNRep<K, V[], TreeMultiMapNode<K, V>> | K, value: V): boolean;
97
+ /**
98
+ * Time Complexity: O(n)
99
+ * Space Complexity: O(n)
100
+ *
101
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
102
+ * structure.
103
+ * @returns The `cloned` object is being returned.
104
+ */
105
+ clone(): TreeMultiMap<K, V, R, MK, MV, MR>;
106
+ }
@@ -0,0 +1,196 @@
1
+ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
2
+ export class TreeMultiMapNode extends RedBlackTreeNode {
3
+ /**
4
+ * This TypeScript constructor initializes an object with a key of type K and an array of values of
5
+ * type V.
6
+ * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
7
+ * data being stored in the data structure. It helps in quickly accessing or retrieving the
8
+ * associated value in the data structure.
9
+ * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
10
+ * type `V`.
11
+ */
12
+ constructor(key, value) {
13
+ super(key, value);
14
+ }
15
+ parent = undefined;
16
+ _left = undefined;
17
+ get left() {
18
+ return this._left;
19
+ }
20
+ set left(v) {
21
+ if (v) {
22
+ v.parent = this;
23
+ }
24
+ this._left = v;
25
+ }
26
+ _right = undefined;
27
+ get right() {
28
+ return this._right;
29
+ }
30
+ set right(v) {
31
+ if (v) {
32
+ v.parent = this;
33
+ }
34
+ this._right = v;
35
+ }
36
+ }
37
+ /**
38
+ *
39
+ * @example
40
+ * // Find elements in a range
41
+ * const tmm = new TreeMultiMap<number>([10, 5, 15, 3, 7, 12, 18]);
42
+ * console.log(tmm.search(new Range(5, 10))); // [5, 10, 7]
43
+ * console.log(tmm.search(new Range(4, 12))); // [5, 10, 12, 7]
44
+ * console.log(tmm.search(new Range(15, 20))); // [15, 18]
45
+ */
46
+ export class TreeMultiMap extends RedBlackTree {
47
+ /**
48
+ * The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
49
+ * and options.
50
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
51
+ * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
52
+ * TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
53
+ * the RedBlackTreeMulti
54
+ * @param [options] - The `options` parameter in the constructor is of type
55
+ * `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
56
+ * additional options for configuring the TreeMultiMap instance.
57
+ */
58
+ constructor(keysNodesEntriesOrRaws = [], options) {
59
+ super([], { ...options, isMapMode: true });
60
+ if (keysNodesEntriesOrRaws) {
61
+ this.addMany(keysNodesEntriesOrRaws);
62
+ }
63
+ }
64
+ /**
65
+ * Time Complexity: O(1)
66
+ * Space Complexity: O(1)
67
+ *
68
+ * The `createTree` function in TypeScript overrides the default implementation to create a new
69
+ * TreeMultiMap with specified options.
70
+ * @param [options] - The `options` parameter in the `createTree` method is of type
71
+ * `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
72
+ * options when creating a new `TreeMultiMap` instance. It includes properties such as
73
+ * `iterationType`, `specifyComparable
74
+ * @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
75
+ * data and the provided options merged with the existing properties of the current object.
76
+ */
77
+ createTree(options) {
78
+ return new TreeMultiMap([], {
79
+ iterationType: this.iterationType,
80
+ specifyComparable: this._specifyComparable,
81
+ toEntryFn: this._toEntryFn,
82
+ isReverse: this._isReverse,
83
+ ...options
84
+ });
85
+ }
86
+ /**
87
+ * Time Complexity: O(1)
88
+ * Space Complexity: O(1)
89
+ *
90
+ * The function `createNode` overrides the method to create a new `TreeMultiMapNode` with a specified
91
+ * key and an empty array of values.
92
+ * @param {K} key - The `key` parameter in the `createNode` method represents the key of the node
93
+ * that will be created in the TreeMultiMap data structure.
94
+ * @returns A new instance of `TreeMultiMapNode<K, V>` is being returned, with the specified key and
95
+ * an empty array as its value.
96
+ */
97
+ createNode(key) {
98
+ return new TreeMultiMapNode(key, []);
99
+ }
100
+ /**
101
+ * Time Complexity: O(log n)
102
+ * Space Complexity: O(log n)
103
+ *
104
+ * The function `add` in TypeScript overrides the superclass method to add key-value pairs to a
105
+ * TreeMultiMapNode, handling different input types and scenarios.
106
+ * @param {BTNRep<K, V[], TreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
107
+ * parameter in the `override add` method can be either a `BTNRep` object containing a key, an array
108
+ * of values, and a `TreeMultiMapNode`, or just a key.
109
+ * @param {V} [value] - The `value` parameter in the `override add` method represents the value that
110
+ * you want to add to the TreeMultiMap. If the key is already present in the map, the new value will
111
+ * be added to the existing list of values associated with that key. If the key is not present,
112
+ * @returns The `add` method is returning a boolean value, which indicates whether the operation was
113
+ * successful or not.
114
+ */
115
+ add(keyNodeOrEntry, value) {
116
+ if (this.isRealNode(keyNodeOrEntry))
117
+ return super.add(keyNodeOrEntry);
118
+ const _commonAdd = (key, values) => {
119
+ if (key === undefined || key === null)
120
+ return false;
121
+ const existingValues = this.get(key);
122
+ if (existingValues !== undefined && values !== undefined) {
123
+ for (const value of values)
124
+ existingValues.push(value);
125
+ return true;
126
+ }
127
+ const existingNode = this.getNode(key);
128
+ if (this.isRealNode(existingNode)) {
129
+ if (existingValues === undefined) {
130
+ super.add(key, values);
131
+ return true;
132
+ }
133
+ if (values !== undefined) {
134
+ for (const value of values)
135
+ existingValues.push(value);
136
+ return true;
137
+ }
138
+ else {
139
+ return false;
140
+ }
141
+ }
142
+ else {
143
+ return super.add(key, values);
144
+ }
145
+ };
146
+ if (this.isEntry(keyNodeOrEntry)) {
147
+ const [key, values] = keyNodeOrEntry;
148
+ return _commonAdd(key, value !== undefined ? [value] : values);
149
+ }
150
+ return _commonAdd(keyNodeOrEntry, value !== undefined ? [value] : undefined);
151
+ }
152
+ /**
153
+ * Time Complexity: O(log n)
154
+ * Space Complexity: O(log n)
155
+ *
156
+ * The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
157
+ * and deletes the entire node if no values are left for that key.
158
+ * @param {BTNRep<K, V[], TreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
159
+ * parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
160
+ * array of values, or just a key itself.
161
+ * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
162
+ * value that you want to remove from the multi-map data structure associated with a particular key.
163
+ * The function checks if the value exists in the array of values associated with the key, and if
164
+ * found, removes it from the array.
165
+ * @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
166
+ * successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
167
+ */
168
+ deleteValue(keyNodeOrEntry, value) {
169
+ const values = this.get(keyNodeOrEntry);
170
+ if (Array.isArray(values)) {
171
+ const index = values.indexOf(value);
172
+ if (index === -1)
173
+ return false;
174
+ values.splice(index, 1);
175
+ // If no values left, remove the entire node
176
+ if (values.length === 0)
177
+ this.delete(keyNodeOrEntry);
178
+ return true;
179
+ }
180
+ return false;
181
+ }
182
+ /**
183
+ * Time Complexity: O(n)
184
+ * Space Complexity: O(n)
185
+ *
186
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
187
+ * structure.
188
+ * @returns The `cloned` object is being returned.
189
+ */
190
+ clone() {
191
+ const cloned = this.createTree();
192
+ this._clone(cloned);
193
+ return cloned;
194
+ }
195
+ }
196
+ //# sourceMappingURL=tree-multi-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGlE,MAAM,OAAO,gBAAmC,SAAQ,gBAAwB;IAC9E;;;;;;;;OAQG;IACH,YAAY,GAAM,EAAE,KAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAEQ,MAAM,GAA4B,SAAS,CAAC;IAE5C,KAAK,GAA2C,SAAS,CAAC;IAEnE,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAAwC;QACxD,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,I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,CAAC;QAED,OAAO,UAAU,CAAC,cAAc,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,cAA0D,EAAE,KAAQ;QAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAExB,4CAA4C;YAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YAErD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACM,KAAK;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -34,6 +34,9 @@ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
34
34
  */
35
35
  constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
36
36
  }
37
+ /**
38
+ *
39
+ */
37
40
  export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V> = DirectedVertex<V>, EO extends DirectedEdge<E> = DirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
38
41
  /**
39
42
  * The constructor function initializes an instance of a class.