data-structure-typed 1.54.0 → 1.54.2

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 (498) 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 +3 -1
  74. package/dist/cjs/types/data-structures/binary-tree/index.js +3 -1
  75. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  76. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  77. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +3 -0
  78. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +1 -0
  79. package/dist/cjs/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  80. package/dist/cjs/types/data-structures/binary-tree/{rb-tree.js → tree-counter.js} +1 -1
  81. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  82. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
  83. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  84. package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.js → esm/data-structures/binary-tree/avl-tree-counter.js} +73 -60
  85. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  86. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -0
  87. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +191 -0
  88. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  89. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +234 -0
  90. package/dist/{mjs → esm}/data-structures/binary-tree/avl-tree.js +110 -47
  91. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -0
  92. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  93. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  94. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  95. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.d.ts +240 -190
  96. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.js +272 -245
  97. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -0
  98. package/dist/{mjs → esm}/data-structures/binary-tree/bst.d.ts +145 -112
  99. package/dist/{mjs → esm}/data-structures/binary-tree/bst.js +201 -155
  100. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -0
  101. package/dist/{mjs → esm}/data-structures/binary-tree/index.d.ts +2 -0
  102. package/dist/{mjs/types/data-structures/binary-tree/index.d.ts → esm/data-structures/binary-tree/index.js} +6 -2
  103. package/dist/{mjs → esm}/data-structures/binary-tree/index.js.map +1 -1
  104. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  105. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.js +115 -79
  106. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -0
  107. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +212 -0
  108. package/dist/{mjs/data-structures/binary-tree/tree-multi-map.js → esm/data-structures/binary-tree/tree-counter.js} +111 -96
  109. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -0
  110. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +106 -0
  111. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +196 -0
  112. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  113. package/dist/{mjs → esm}/data-structures/graph/directed-graph.d.ts +3 -0
  114. package/dist/{mjs → esm}/data-structures/graph/directed-graph.js +3 -0
  115. package/dist/esm/data-structures/graph/directed-graph.js.map +1 -0
  116. package/dist/{mjs → esm}/data-structures/graph/map-graph.d.ts +3 -0
  117. package/dist/{mjs → esm}/data-structures/graph/map-graph.js +3 -0
  118. package/dist/esm/data-structures/graph/map-graph.js.map +1 -0
  119. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.d.ts +3 -0
  120. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.js +3 -0
  121. package/dist/esm/data-structures/graph/undirected-graph.js.map +1 -0
  122. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  123. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.js +3 -0
  124. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -0
  125. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  126. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.js +3 -0
  127. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +1 -0
  128. package/dist/{mjs → esm}/data-structures/matrix/matrix.d.ts +3 -0
  129. package/dist/{mjs → esm}/data-structures/matrix/matrix.js +3 -0
  130. package/dist/esm/data-structures/matrix/matrix.js.map +1 -0
  131. package/dist/{mjs → esm}/data-structures/matrix/navigator.d.ts +3 -0
  132. package/dist/{mjs → esm}/data-structures/matrix/navigator.js +3 -0
  133. package/dist/esm/data-structures/matrix/navigator.js.map +1 -0
  134. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  135. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.js +3 -0
  136. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  137. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  138. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.js +3 -0
  139. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  140. package/dist/{mjs → esm}/data-structures/trie/trie.d.ts +0 -4
  141. package/dist/{mjs → esm}/data-structures/trie/trie.js +0 -4
  142. package/dist/esm/data-structures/trie/trie.js.map +1 -0
  143. package/dist/esm/interfaces/binary-tree.d.ts +9 -0
  144. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  145. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  146. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  147. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  148. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  149. package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  150. package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.d.ts +3 -3
  151. package/dist/{mjs/data-structures/binary-tree/index.js → esm/types/data-structures/binary-tree/index.d.ts} +4 -4
  152. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js +3 -1
  153. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js.map +1 -1
  154. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  155. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +2 -0
  156. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +1 -0
  157. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  158. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +2 -0
  159. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  160. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  161. package/dist/umd/data-structure-typed.js +1464 -895
  162. package/dist/umd/data-structure-typed.min.js +5 -5
  163. package/dist/umd/data-structure-typed.min.js.map +1 -1
  164. package/package.json +14 -19
  165. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  166. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +155 -393
  167. package/src/data-structures/binary-tree/avl-tree.ts +144 -93
  168. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  169. package/src/data-structures/binary-tree/binary-tree.ts +433 -405
  170. package/src/data-structures/binary-tree/bst.ts +261 -239
  171. package/src/data-structures/binary-tree/index.ts +2 -0
  172. package/src/data-structures/binary-tree/red-black-tree.ts +163 -134
  173. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  174. package/src/data-structures/binary-tree/tree-multi-map.ts +161 -429
  175. package/src/data-structures/graph/directed-graph.ts +3 -0
  176. package/src/data-structures/graph/map-graph.ts +3 -0
  177. package/src/data-structures/graph/undirected-graph.ts +3 -0
  178. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  179. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  180. package/src/data-structures/matrix/matrix.ts +3 -0
  181. package/src/data-structures/matrix/navigator.ts +3 -0
  182. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  183. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  184. package/src/data-structures/trie/trie.ts +0 -4
  185. package/src/interfaces/binary-tree.ts +10 -24
  186. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  187. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  188. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  189. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  190. package/src/types/data-structures/binary-tree/bst.ts +5 -5
  191. package/src/types/data-structures/binary-tree/index.ts +3 -1
  192. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  193. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  194. package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
  195. package/test/integration/all-in-one.test.ts +1 -1
  196. package/test/integration/avl-tree.test.ts +1 -1
  197. package/test/integration/bst.test.ts +2 -2
  198. package/test/integration/compile.js +144 -0
  199. package/test/integration/compile.mjs +135 -0
  200. package/test/integration/compile.ts +171 -0
  201. package/test/integration/index.html +48 -48
  202. package/test/performance/data-structures/binary-tree/avl-tree.test.js +45 -0
  203. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
  204. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +5 -4
  205. package/test/performance/data-structures/comparison/comparison.test.ts +2 -2
  206. package/test/performance/reportor.js +249 -0
  207. package/test/performance/reportor.ts +5 -3
  208. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +877 -0
  209. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +459 -761
  210. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +223 -223
  211. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +474 -492
  212. package/test/unit/data-structures/binary-tree/bst.test.ts +1 -1
  213. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -3
  214. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +87 -90
  215. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +975 -0
  216. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +729 -857
  217. package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
  218. package/{tsconfig-mjs.json → tsconfig-esm.json} +1 -1
  219. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  220. package/dist/cjs/types/data-structures/binary-tree/rb-tree.js.map +0 -1
  221. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  222. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -189
  223. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  224. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  225. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  226. package/dist/mjs/data-structures/binary-tree/bst.js.map +0 -1
  227. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  228. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  229. package/dist/mjs/data-structures/graph/directed-graph.js.map +0 -1
  230. package/dist/mjs/data-structures/graph/map-graph.js.map +0 -1
  231. package/dist/mjs/data-structures/graph/undirected-graph.js.map +0 -1
  232. package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  233. package/dist/mjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  234. package/dist/mjs/data-structures/matrix/matrix.js.map +0 -1
  235. package/dist/mjs/data-structures/matrix/navigator.js.map +0 -1
  236. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  237. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  238. package/dist/mjs/data-structures/trie/trie.js.map +0 -1
  239. package/dist/mjs/interfaces/binary-tree.d.ts +0 -9
  240. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -5
  241. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -5
  242. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  243. package/dist/mjs/types/data-structures/binary-tree/rb-tree.js +0 -2
  244. package/dist/mjs/types/data-structures/binary-tree/rb-tree.js.map +0 -1
  245. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -5
  246. package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
  247. /package/dist/{mjs → esm}/common/index.d.ts +0 -0
  248. /package/dist/{mjs → esm}/common/index.js +0 -0
  249. /package/dist/{mjs → esm}/common/index.js.map +0 -0
  250. /package/dist/{mjs → esm}/data-structures/base/index.d.ts +0 -0
  251. /package/dist/{mjs → esm}/data-structures/base/index.js +0 -0
  252. /package/dist/{mjs → esm}/data-structures/base/index.js.map +0 -0
  253. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.d.ts +0 -0
  254. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js +0 -0
  255. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js.map +0 -0
  256. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.d.ts +0 -0
  257. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js +0 -0
  258. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js.map +0 -0
  259. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  260. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js +0 -0
  261. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js.map +0 -0
  262. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.d.ts +0 -0
  263. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js +0 -0
  264. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js.map +0 -0
  265. /package/dist/{mjs → esm}/data-structures/graph/index.d.ts +0 -0
  266. /package/dist/{mjs → esm}/data-structures/graph/index.js +0 -0
  267. /package/dist/{mjs → esm}/data-structures/graph/index.js.map +0 -0
  268. /package/dist/{mjs → esm}/data-structures/hash/hash-map.d.ts +0 -0
  269. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js +0 -0
  270. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js.map +0 -0
  271. /package/dist/{mjs → esm}/data-structures/hash/index.d.ts +0 -0
  272. /package/dist/{mjs → esm}/data-structures/hash/index.js +0 -0
  273. /package/dist/{mjs → esm}/data-structures/hash/index.js.map +0 -0
  274. /package/dist/{mjs → esm}/data-structures/heap/heap.d.ts +0 -0
  275. /package/dist/{mjs → esm}/data-structures/heap/heap.js +0 -0
  276. /package/dist/{mjs → esm}/data-structures/heap/heap.js.map +0 -0
  277. /package/dist/{mjs → esm}/data-structures/heap/index.d.ts +0 -0
  278. /package/dist/{mjs → esm}/data-structures/heap/index.js +0 -0
  279. /package/dist/{mjs → esm}/data-structures/heap/index.js.map +0 -0
  280. /package/dist/{mjs → esm}/data-structures/heap/max-heap.d.ts +0 -0
  281. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js +0 -0
  282. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js.map +0 -0
  283. /package/dist/{mjs → esm}/data-structures/heap/min-heap.d.ts +0 -0
  284. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js +0 -0
  285. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js.map +0 -0
  286. /package/dist/{mjs → esm}/data-structures/index.d.ts +0 -0
  287. /package/dist/{mjs → esm}/data-structures/index.js +0 -0
  288. /package/dist/{mjs → esm}/data-structures/index.js.map +0 -0
  289. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  290. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js +0 -0
  291. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  292. /package/dist/{mjs → esm}/data-structures/linked-list/index.d.ts +0 -0
  293. /package/dist/{mjs → esm}/data-structures/linked-list/index.js +0 -0
  294. /package/dist/{mjs → esm}/data-structures/linked-list/index.js.map +0 -0
  295. /package/dist/{mjs → esm}/data-structures/matrix/index.d.ts +0 -0
  296. /package/dist/{mjs → esm}/data-structures/matrix/index.js +0 -0
  297. /package/dist/{mjs → esm}/data-structures/matrix/index.js.map +0 -0
  298. /package/dist/{mjs → esm}/data-structures/priority-queue/index.d.ts +0 -0
  299. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js +0 -0
  300. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js.map +0 -0
  301. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  302. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js +0 -0
  303. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js.map +0 -0
  304. /package/dist/{mjs → esm}/data-structures/queue/deque.d.ts +0 -0
  305. /package/dist/{mjs → esm}/data-structures/queue/deque.js +0 -0
  306. /package/dist/{mjs → esm}/data-structures/queue/deque.js.map +0 -0
  307. /package/dist/{mjs → esm}/data-structures/queue/index.d.ts +0 -0
  308. /package/dist/{mjs → esm}/data-structures/queue/index.js +0 -0
  309. /package/dist/{mjs → esm}/data-structures/queue/index.js.map +0 -0
  310. /package/dist/{mjs → esm}/data-structures/queue/queue.d.ts +0 -0
  311. /package/dist/{mjs → esm}/data-structures/queue/queue.js +0 -0
  312. /package/dist/{mjs → esm}/data-structures/queue/queue.js.map +0 -0
  313. /package/dist/{mjs → esm}/data-structures/stack/index.d.ts +0 -0
  314. /package/dist/{mjs → esm}/data-structures/stack/index.js +0 -0
  315. /package/dist/{mjs → esm}/data-structures/stack/index.js.map +0 -0
  316. /package/dist/{mjs → esm}/data-structures/stack/stack.d.ts +0 -0
  317. /package/dist/{mjs → esm}/data-structures/stack/stack.js +0 -0
  318. /package/dist/{mjs → esm}/data-structures/stack/stack.js.map +0 -0
  319. /package/dist/{mjs → esm}/data-structures/tree/index.d.ts +0 -0
  320. /package/dist/{mjs → esm}/data-structures/tree/index.js +0 -0
  321. /package/dist/{mjs → esm}/data-structures/tree/index.js.map +0 -0
  322. /package/dist/{mjs → esm}/data-structures/tree/tree.d.ts +0 -0
  323. /package/dist/{mjs → esm}/data-structures/tree/tree.js +0 -0
  324. /package/dist/{mjs → esm}/data-structures/tree/tree.js.map +0 -0
  325. /package/dist/{mjs → esm}/data-structures/trie/index.d.ts +0 -0
  326. /package/dist/{mjs → esm}/data-structures/trie/index.js +0 -0
  327. /package/dist/{mjs → esm}/data-structures/trie/index.js.map +0 -0
  328. /package/dist/{mjs → esm}/index.d.ts +0 -0
  329. /package/dist/{mjs → esm}/index.js +0 -0
  330. /package/dist/{mjs → esm}/index.js.map +0 -0
  331. /package/dist/{mjs → esm}/interfaces/binary-tree.js +0 -0
  332. /package/dist/{mjs → esm}/interfaces/binary-tree.js.map +0 -0
  333. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.d.ts +0 -0
  334. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js +0 -0
  335. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js.map +0 -0
  336. /package/dist/{mjs → esm}/interfaces/graph.d.ts +0 -0
  337. /package/dist/{mjs → esm}/interfaces/graph.js +0 -0
  338. /package/dist/{mjs → esm}/interfaces/graph.js.map +0 -0
  339. /package/dist/{mjs → esm}/interfaces/heap.d.ts +0 -0
  340. /package/dist/{mjs → esm}/interfaces/heap.js +0 -0
  341. /package/dist/{mjs → esm}/interfaces/heap.js.map +0 -0
  342. /package/dist/{mjs → esm}/interfaces/index.d.ts +0 -0
  343. /package/dist/{mjs → esm}/interfaces/index.js +0 -0
  344. /package/dist/{mjs → esm}/interfaces/index.js.map +0 -0
  345. /package/dist/{mjs → esm}/interfaces/navigator.d.ts +0 -0
  346. /package/dist/{mjs → esm}/interfaces/navigator.js +0 -0
  347. /package/dist/{mjs → esm}/interfaces/navigator.js.map +0 -0
  348. /package/dist/{mjs → esm}/interfaces/priority-queue.d.ts +0 -0
  349. /package/dist/{mjs → esm}/interfaces/priority-queue.js +0 -0
  350. /package/dist/{mjs → esm}/interfaces/priority-queue.js.map +0 -0
  351. /package/dist/{mjs → esm}/interfaces/segment-tree.d.ts +0 -0
  352. /package/dist/{mjs → esm}/interfaces/segment-tree.js +0 -0
  353. /package/dist/{mjs → esm}/interfaces/segment-tree.js.map +0 -0
  354. /package/dist/{mjs → esm}/interfaces/singly-linked-list.d.ts +0 -0
  355. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js +0 -0
  356. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js.map +0 -0
  357. /package/dist/{mjs → esm}/types/common.d.ts +0 -0
  358. /package/dist/{mjs → esm}/types/common.js +0 -0
  359. /package/dist/{mjs → esm}/types/common.js.map +0 -0
  360. /package/dist/{mjs → esm}/types/data-structures/base/base.d.ts +0 -0
  361. /package/dist/{mjs → esm}/types/data-structures/base/base.js +0 -0
  362. /package/dist/{mjs → esm}/types/data-structures/base/base.js.map +0 -0
  363. /package/dist/{mjs → esm}/types/data-structures/base/index.d.ts +0 -0
  364. /package/dist/{mjs → esm}/types/data-structures/base/index.js +0 -0
  365. /package/dist/{mjs → esm}/types/data-structures/base/index.js.map +0 -0
  366. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -0
  367. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -0
  368. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js +0 -0
  369. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js.map +0 -0
  370. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  371. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js +0 -0
  372. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -0
  373. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js +0 -0
  374. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js.map +0 -0
  375. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js +0 -0
  376. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js.map +0 -0
  377. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  378. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js +0 -0
  379. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js.map +0 -0
  380. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js +0 -0
  381. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js.map +0 -0
  382. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  383. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js +0 -0
  384. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js.map +0 -0
  385. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.d.ts +0 -0
  386. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js +0 -0
  387. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js.map +0 -0
  388. /package/dist/{mjs → esm}/types/data-structures/graph/index.d.ts +0 -0
  389. /package/dist/{mjs → esm}/types/data-structures/graph/index.js +0 -0
  390. /package/dist/{mjs → esm}/types/data-structures/graph/index.js.map +0 -0
  391. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.d.ts +0 -0
  392. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js +0 -0
  393. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js.map +0 -0
  394. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  395. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js +0 -0
  396. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js.map +0 -0
  397. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.d.ts +0 -0
  398. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js +0 -0
  399. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js.map +0 -0
  400. /package/dist/{mjs → esm}/types/data-structures/hash/index.d.ts +0 -0
  401. /package/dist/{mjs → esm}/types/data-structures/hash/index.js +0 -0
  402. /package/dist/{mjs → esm}/types/data-structures/hash/index.js.map +0 -0
  403. /package/dist/{mjs → esm}/types/data-structures/heap/heap.d.ts +0 -0
  404. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js +0 -0
  405. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js.map +0 -0
  406. /package/dist/{mjs → esm}/types/data-structures/heap/index.d.ts +0 -0
  407. /package/dist/{mjs → esm}/types/data-structures/heap/index.js +0 -0
  408. /package/dist/{mjs → esm}/types/data-structures/heap/index.js.map +0 -0
  409. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.d.ts +0 -0
  410. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js +0 -0
  411. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js.map +0 -0
  412. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.d.ts +0 -0
  413. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js +0 -0
  414. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js.map +0 -0
  415. /package/dist/{mjs → esm}/types/data-structures/index.d.ts +0 -0
  416. /package/dist/{mjs → esm}/types/data-structures/index.js +0 -0
  417. /package/dist/{mjs → esm}/types/data-structures/index.js.map +0 -0
  418. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  419. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js +0 -0
  420. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  421. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.d.ts +0 -0
  422. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js +0 -0
  423. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js.map +0 -0
  424. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  425. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js +0 -0
  426. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js.map +0 -0
  427. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  428. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js +0 -0
  429. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js.map +0 -0
  430. /package/dist/{mjs → esm}/types/data-structures/matrix/index.d.ts +0 -0
  431. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js +0 -0
  432. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js.map +0 -0
  433. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.d.ts +0 -0
  434. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js +0 -0
  435. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js.map +0 -0
  436. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.d.ts +0 -0
  437. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js +0 -0
  438. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js.map +0 -0
  439. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.d.ts +0 -0
  440. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js +0 -0
  441. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js.map +0 -0
  442. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  443. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js +0 -0
  444. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js.map +0 -0
  445. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  446. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js +0 -0
  447. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js.map +0 -0
  448. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  449. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js +0 -0
  450. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js.map +0 -0
  451. /package/dist/{mjs → esm}/types/data-structures/queue/deque.d.ts +0 -0
  452. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js +0 -0
  453. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js.map +0 -0
  454. /package/dist/{mjs → esm}/types/data-structures/queue/index.d.ts +0 -0
  455. /package/dist/{mjs → esm}/types/data-structures/queue/index.js +0 -0
  456. /package/dist/{mjs → esm}/types/data-structures/queue/index.js.map +0 -0
  457. /package/dist/{mjs → esm}/types/data-structures/queue/queue.d.ts +0 -0
  458. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js +0 -0
  459. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js.map +0 -0
  460. /package/dist/{mjs → esm}/types/data-structures/stack/index.d.ts +0 -0
  461. /package/dist/{mjs → esm}/types/data-structures/stack/index.js +0 -0
  462. /package/dist/{mjs → esm}/types/data-structures/stack/index.js.map +0 -0
  463. /package/dist/{mjs → esm}/types/data-structures/stack/stack.d.ts +0 -0
  464. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js +0 -0
  465. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js.map +0 -0
  466. /package/dist/{mjs → esm}/types/data-structures/tree/index.d.ts +0 -0
  467. /package/dist/{mjs → esm}/types/data-structures/tree/index.js +0 -0
  468. /package/dist/{mjs → esm}/types/data-structures/tree/index.js.map +0 -0
  469. /package/dist/{mjs → esm}/types/data-structures/tree/tree.d.ts +0 -0
  470. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js +0 -0
  471. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js.map +0 -0
  472. /package/dist/{mjs → esm}/types/data-structures/trie/index.d.ts +0 -0
  473. /package/dist/{mjs → esm}/types/data-structures/trie/index.js +0 -0
  474. /package/dist/{mjs → esm}/types/data-structures/trie/index.js.map +0 -0
  475. /package/dist/{mjs → esm}/types/data-structures/trie/trie.d.ts +0 -0
  476. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js +0 -0
  477. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js.map +0 -0
  478. /package/dist/{mjs → esm}/types/index.d.ts +0 -0
  479. /package/dist/{mjs → esm}/types/index.js +0 -0
  480. /package/dist/{mjs → esm}/types/index.js.map +0 -0
  481. /package/dist/{mjs → esm}/types/utils/index.d.ts +0 -0
  482. /package/dist/{mjs → esm}/types/utils/index.js +0 -0
  483. /package/dist/{mjs → esm}/types/utils/index.js.map +0 -0
  484. /package/dist/{mjs → esm}/types/utils/utils.d.ts +0 -0
  485. /package/dist/{mjs → esm}/types/utils/utils.js +0 -0
  486. /package/dist/{mjs → esm}/types/utils/utils.js.map +0 -0
  487. /package/dist/{mjs → esm}/types/utils/validate-type.d.ts +0 -0
  488. /package/dist/{mjs → esm}/types/utils/validate-type.js +0 -0
  489. /package/dist/{mjs → esm}/types/utils/validate-type.js.map +0 -0
  490. /package/dist/{mjs → esm}/utils/index.d.ts +0 -0
  491. /package/dist/{mjs → esm}/utils/index.js +0 -0
  492. /package/dist/{mjs → esm}/utils/index.js.map +0 -0
  493. /package/dist/{mjs → esm}/utils/number.d.ts +0 -0
  494. /package/dist/{mjs → esm}/utils/number.js +0 -0
  495. /package/dist/{mjs → esm}/utils/number.js.map +0 -0
  496. /package/dist/{mjs → esm}/utils/utils.d.ts +0 -0
  497. /package/dist/{mjs → esm}/utils/utils.js +0 -0
  498. /package/dist/{mjs → esm}/utils/utils.js.map +0 -0
@@ -1,20 +1,40 @@
1
1
  import { BST, BSTNode } from './bst';
2
2
  export class RedBlackTreeNode extends BSTNode {
3
3
  /**
4
- * The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a
5
- * color.
6
- * @param {K} key - The key parameter is of type K and represents the key of the node in the
7
- * Red-Black Tree.
8
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
9
- * associated with the key in the Red-Black Tree Node. It is not required and can be omitted when
10
- * creating a new instance of the Red-Black Tree Node.
11
- * @param {RBTNColor} color - The `color` parameter is used to specify the color of the Red-Black
12
- * Tree Node. It is an optional parameter with a default value of `'BLACK'`.
4
+ * The constructor initializes a node with a key, value, and color for a Red-Black Tree.
5
+ * @param {K} key - The `key` parameter is a key of type `K` that is used to identify the node in a
6
+ * Red-Black Tree data structure.
7
+ * @param {V} [value] - The `value` parameter in the constructor is an optional parameter of type
8
+ * `V`. It represents the value associated with the key in the data structure being constructed.
9
+ * @param {RBTNColor} [color=BLACK] - The `color` parameter in the constructor is used to specify the
10
+ * color of the node in a Red-Black Tree. It has a default value of 'BLACK' if not provided
11
+ * explicitly.
13
12
  */
14
13
  constructor(key, value, color = 'BLACK') {
15
14
  super(key, value);
16
15
  this._color = color;
17
16
  }
17
+ parent = undefined;
18
+ _left = undefined;
19
+ get left() {
20
+ return this._left;
21
+ }
22
+ set left(v) {
23
+ if (v) {
24
+ v.parent = this;
25
+ }
26
+ this._left = v;
27
+ }
28
+ _right = undefined;
29
+ get right() {
30
+ return this._right;
31
+ }
32
+ set right(v) {
33
+ if (v) {
34
+ v.parent = this;
35
+ }
36
+ this._right = v;
37
+ }
18
38
  }
19
39
  /**
20
40
  * 1. Efficient self-balancing, but not completely balanced. Compared with AVLTree, the addition and deletion efficiency is high but the query efficiency is slightly lower.
@@ -71,14 +91,15 @@ export class RedBlackTreeNode extends BSTNode {
71
91
  */
72
92
  export class RedBlackTree extends BST {
73
93
  /**
74
- * This is the constructor function for a Red-Black Tree data structure in TypeScript.
75
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
76
- * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
77
- * initialize the RBTree with the provided elements.
78
- * @param [options] - The `options` parameter is an optional object that can be passed to the
79
- * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
80
- * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
81
- * depend on the implementation
94
+ * This TypeScript constructor initializes a Red-Black Tree with optional keys, nodes, entries, or
95
+ * raw data.
96
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
97
+ * iterable that can contain either `BTNRep<K, V, RedBlackTreeNode<K, V>>` objects or `R` objects. It
98
+ * is used to initialize the Red-Black Tree with keys, nodes, entries, or
99
+ * @param [options] - The `options` parameter in the constructor is of type `RedBlackTreeOptions<K,
100
+ * V, R>`. It is an optional parameter that allows you to specify additional options for the
101
+ * RedBlackTree class. These options could include configuration settings, behavior customization, or
102
+ * any other parameters that are specific to
82
103
  */
83
104
  constructor(keysNodesEntriesOrRaws = [], options) {
84
105
  super([], options);
@@ -88,14 +109,13 @@ export class RedBlackTree extends BST {
88
109
  }
89
110
  }
90
111
  _root;
91
- /**
92
- * The function returns the root node of a tree or undefined if there is no root.
93
- * @returns The root node of the tree structure, or undefined if there is no root node.
94
- */
95
112
  get root() {
96
113
  return this._root;
97
114
  }
98
115
  /**
116
+ * Time Complexity: O(1)
117
+ * Space Complexity: O(1)
118
+ *
99
119
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
100
120
  * @param {K} key - The key parameter represents the key value of the node being created. It is of
101
121
  * type K, which is a generic type that can be replaced with any specific type when using the
@@ -113,6 +133,9 @@ export class RedBlackTree extends BST {
113
133
  return new RedBlackTreeNode(key, this._isMapMode ? undefined : value, color);
114
134
  }
115
135
  /**
136
+ * Time Complexity: O(1)
137
+ * Space Complexity: O(1)
138
+ *
116
139
  * The function creates a new Red-Black Tree with the specified options.
117
140
  * @param [options] - The `options` parameter is an optional object that contains additional
118
141
  * configuration options for creating the Red-Black Tree. It has the following properties:
@@ -132,13 +155,13 @@ export class RedBlackTree extends BST {
132
155
  * Space Complexity: O(1)
133
156
  *
134
157
  * The function checks if the input is an instance of the RedBlackTreeNode class.
135
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
136
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
137
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
158
+ * @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The parameter
159
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, RedBlackTreeNode<K, V>>`.
160
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
138
161
  * an instance of the `RedBlackTreeNode` class.
139
162
  */
140
- isNode(keyNodeEntryOrRaw) {
141
- return keyNodeEntryOrRaw instanceof RedBlackTreeNode;
163
+ isNode(keyNodeOrEntry) {
164
+ return keyNodeOrEntry instanceof RedBlackTreeNode;
142
165
  }
143
166
  /**
144
167
  * Time Complexity: O(1)
@@ -153,12 +176,12 @@ export class RedBlackTree extends BST {
153
176
  }
154
177
  /**
155
178
  * Time Complexity: O(log n)
156
- * Space Complexity: O(1)
179
+ * Space Complexity: O(log n)
157
180
  *
158
181
  * The function adds a new node to a binary search tree and returns true if the node was successfully
159
182
  * added.
160
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
161
- * `keyNodeEntryOrRaw` can accept a value of type `R` or `BTNRep<K, V, NODE>`.
183
+ * @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The parameter
184
+ * `keyNodeOrEntry` can accept a value of type `R` or `BTNRep<K, V, RedBlackTreeNode<K, V>>`.
162
185
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
163
186
  * the key in the data structure. It represents the value that you want to add or update in the data
164
187
  * structure.
@@ -166,8 +189,8 @@ export class RedBlackTree extends BST {
166
189
  * the method returns true. If the node already exists and its value is updated, the method also
167
190
  * returns true. If the node cannot be added or updated, the method returns false.
168
191
  */
169
- add(keyNodeEntryOrRaw, value) {
170
- const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
192
+ add(keyNodeOrEntry, value) {
193
+ const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
171
194
  if (!this.isRealNode(newNode))
172
195
  return false;
173
196
  const insertStatus = this._insert(newNode);
@@ -193,27 +216,27 @@ export class RedBlackTree extends BST {
193
216
  }
194
217
  /**
195
218
  * Time Complexity: O(log n)
196
- * Space Complexity: O(1)
219
+ * Space Complexity: O(log n)
197
220
  *
198
221
  * The function overrides the delete method in a binary tree data structure to remove a node based on
199
222
  * a given predicate and maintain the binary search tree properties.
200
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
223
+ * @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
201
224
  * parameter in the `override delete` method is used to specify the condition or key based on which a
202
225
  * node should be deleted from the binary tree. It can be a key, a node, an entry, or a predicate
203
226
  * function that determines which node(s) should be deleted.
204
- * @returns The `override delete` method is returning an array of `BinaryTreeDeleteResult<NODE>`
227
+ * @returns The `override delete` method is returning an array of `BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>`
205
228
  * objects. Each object in the array contains information about the deleted node and whether
206
229
  * balancing is needed.
207
230
  */
208
- delete(keyNodeEntryOrRaw) {
209
- if (keyNodeEntryOrRaw === null)
231
+ delete(keyNodeOrEntry) {
232
+ if (keyNodeOrEntry === null)
210
233
  return [];
211
234
  const results = [];
212
235
  let nodeToDelete;
213
- if (this._isPredicate(keyNodeEntryOrRaw))
214
- nodeToDelete = this.getNode(keyNodeEntryOrRaw);
236
+ if (this._isPredicate(keyNodeOrEntry))
237
+ nodeToDelete = this.getNode(keyNodeOrEntry);
215
238
  else
216
- nodeToDelete = this.isRealNode(keyNodeEntryOrRaw) ? keyNodeEntryOrRaw : this.getNode(keyNodeEntryOrRaw);
239
+ nodeToDelete = this.isRealNode(keyNodeOrEntry) ? keyNodeOrEntry : this.getNode(keyNodeOrEntry);
217
240
  if (!nodeToDelete) {
218
241
  return results;
219
242
  }
@@ -267,13 +290,54 @@ export class RedBlackTree extends BST {
267
290
  results.push({ deleted: nodeToDelete, needBalanced: undefined });
268
291
  return results;
269
292
  }
293
+ /**
294
+ * Time Complexity: O(n)
295
+ * Space Complexity: O(n)
296
+ *
297
+ * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
298
+ * applying a callback to each entry in the original tree.
299
+ * @param callback - A function that will be called for each entry in the tree, with parameters
300
+ * representing the key, value, index, and the tree itself. It should return an entry for the new
301
+ * tree.
302
+ * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
303
+ * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
304
+ * Tree that will be created during the mapping process. These options could include things like
305
+ * custom comparators
306
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
307
+ * the value of `this` when executing the `callback` function. It allows you to set the context
308
+ * (value of `this`) for the callback function. This can be useful when you want to access properties
309
+ * or
310
+ * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
311
+ * provided callback function.
312
+ */
313
+ map(callback, options, thisArg) {
314
+ const newTree = new RedBlackTree([], options);
315
+ let index = 0;
316
+ for (const [key, value] of this) {
317
+ newTree.add(callback.call(thisArg, key, value, index++, this));
318
+ }
319
+ return newTree;
320
+ }
321
+ /**
322
+ * Time Complexity: O(n)
323
+ * Space Complexity: O(n)
324
+ *
325
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
326
+ * structure.
327
+ * @returns The `cloned` object is being returned.
328
+ */
329
+ clone() {
330
+ const cloned = this.createTree();
331
+ this._clone(cloned);
332
+ return cloned;
333
+ }
270
334
  /**
271
335
  * Time Complexity: O(1)
272
336
  * Space Complexity: O(1)
273
337
  *
274
338
  * The function sets the root of a tree-like structure and updates the parent property of the new
275
339
  * root.
276
- * @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
340
+ * @param {RedBlackTreeNode<K, V> | undefined} v - v is a parameter of type RedBlackTreeNode<K, V> or undefined.
277
341
  */
278
342
  _setRoot(v) {
279
343
  if (v) {
@@ -286,9 +350,9 @@ export class RedBlackTree extends BST {
286
350
  * Space Complexity: O(1)
287
351
  *
288
352
  * The function replaces an old node with a new node while preserving the color of the old node.
289
- * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
353
+ * @param {RedBlackTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
290
354
  * the data structure.
291
- * @param {NODE} newNode - The `newNode` parameter is of type `NODE`, which represents a node in a
355
+ * @param {RedBlackTreeNode<K, V>} newNode - The `newNode` parameter is of type `RedBlackTreeNode<K, V>`, which represents a node in a
292
356
  * data structure.
293
357
  * @returns The method is returning the result of calling the `_replaceNode` method from the
294
358
  * superclass, with the `oldNode` and `newNode` parameters.
@@ -299,11 +363,11 @@ export class RedBlackTree extends BST {
299
363
  }
300
364
  /**
301
365
  * Time Complexity: O(log n)
302
- * Space Complexity: O(1)
366
+ * Space Complexity: O(log n)
303
367
  *
304
368
  * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
305
369
  * maintain the red-black tree properties.
306
- * @param {NODE} node - The `node` parameter represents the node that needs to be inserted into the
370
+ * @param {RedBlackTreeNode<K, V>} node - The `node` parameter represents the node that needs to be inserted into the
307
371
  * binary search tree.
308
372
  * @returns a string value indicating the result of the insertion operation. It can return either
309
373
  * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
@@ -347,9 +411,9 @@ export class RedBlackTree extends BST {
347
411
  * Space Complexity: O(1)
348
412
  *
349
413
  * The function `_transplant` is used to replace a node `u` with another node `v` in a binary tree.
350
- * @param {NODE} u - The parameter "u" represents a node in a binary tree.
351
- * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`, which means it can
352
- * either be a `NODE` object or `undefined`.
414
+ * @param {RedBlackTreeNode<K, V>} u - The parameter "u" represents a node in a binary tree.
415
+ * @param {RedBlackTreeNode<K, V> | undefined} v - The parameter `v` is of type `RedBlackTreeNode<K, V> | undefined`, which means it can
416
+ * either be a `RedBlackTreeNode<K, V>` object or `undefined`.
353
417
  */
354
418
  _transplant(u, v) {
355
419
  if (!u.parent) {
@@ -370,7 +434,7 @@ export class RedBlackTree extends BST {
370
434
  * Space Complexity: O(1)
371
435
  *
372
436
  * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
373
- * @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
437
+ * @param {RedBlackTreeNode<K, V> | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
374
438
  * structure. It can either be a valid node or `undefined`.
375
439
  */
376
440
  _insertFixup(z) {
@@ -437,7 +501,7 @@ export class RedBlackTree extends BST {
437
501
  *
438
502
  * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
439
503
  * the colors and performing rotations.
440
- * @param {NODE | undefined} node - The `node` parameter represents a node in a binary tree. It can
504
+ * @param {RedBlackTreeNode<K, V> | undefined} node - The `node` parameter represents a node in a binary tree. It can
441
505
  * be either a valid node object or `undefined`.
442
506
  * @returns The function does not return any value. It has a return type of `void`, which means it
443
507
  * does not return anything.
@@ -522,7 +586,7 @@ export class RedBlackTree extends BST {
522
586
  * Space Complexity: O(1)
523
587
  *
524
588
  * The `_leftRotate` function performs a left rotation on a given node in a binary tree.
525
- * @param {NODE | undefined} x - The parameter `x` is of type `NODE | undefined`. It represents a
589
+ * @param {RedBlackTreeNode<K, V> | undefined} x - The parameter `x` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
526
590
  * node in a binary tree or `undefined` if there is no node.
527
591
  * @returns void, which means it does not return any value.
528
592
  */
@@ -553,7 +617,7 @@ export class RedBlackTree extends BST {
553
617
  * Space Complexity: O(1)
554
618
  *
555
619
  * The `_rightRotate` function performs a right rotation on a given node in a binary tree.
556
- * @param {NODE | undefined} y - The parameter `y` is of type `NODE | undefined`. It represents a
620
+ * @param {RedBlackTreeNode<K, V> | undefined} y - The parameter `y` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
557
621
  * node in a binary tree or `undefined` if there is no node.
558
622
  * @returns void, which means it does not return any value.
559
623
  */
@@ -579,33 +643,5 @@ export class RedBlackTree extends BST {
579
643
  x.right = y;
580
644
  y.parent = x;
581
645
  }
582
- /**
583
- * Time Complexity: O(n)
584
- * Space Complexity: O(n)
585
- *
586
- * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
587
- * applying a callback to each entry in the original tree.
588
- * @param callback - A function that will be called for each entry in the tree, with parameters
589
- * representing the key, value, index, and the tree itself. It should return an entry for the new
590
- * tree.
591
- * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
592
- * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
593
- * Tree that will be created during the mapping process. These options could include things like
594
- * custom comparators
595
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
596
- * the value of `this` when executing the `callback` function. It allows you to set the context
597
- * (value of `this`) for the callback function. This can be useful when you want to access properties
598
- * or
599
- * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
600
- * provided callback function.
601
- */
602
- map(callback, options, thisArg) {
603
- const newTree = new RedBlackTree([], options);
604
- let index = 0;
605
- for (const [key, value] of this) {
606
- newTree.add(callback.call(thisArg, key, value, index++, this));
607
- }
608
- return newTree;
609
- }
610
646
  }
611
647
  //# sourceMappingURL=red-black-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"red-black-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/red-black-tree.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGrC,MAAM,OAAO,gBAAmC,SAAQ,OAAa;IACnE;;;;;;;;;OASG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,QAAmB,OAAO;QACvD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,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;QACx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AC;QACpB,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QACX,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACf,CAAC;IAED;;;;;;;;OAQG;IACO,YAAY,CAAC,CAAqC;QAC1D,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;QAEjB,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QAEpB,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/B,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,212 @@
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 { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, OptNodeOrNull, RBTNColor, TreeCounterOptions } from '../../types';
9
+ import { IBinaryTree } from '../../interfaces';
10
+ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
11
+ export declare class TreeCounterNode<K = any, V = any> extends RedBlackTreeNode<K, V> {
12
+ /**
13
+ * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
14
+ * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
15
+ * used to identify and locate the node within the tree.
16
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
17
+ * associated with the key in the Red-Black Tree node. It is not required and can be omitted when
18
+ * creating a new node.
19
+ * @param [count=1] - The `count` parameter represents the number of occurrences of a particular key
20
+ * in the Red-Black Tree. It is an optional parameter with a default value of 1.
21
+ * @param {RBTNColor} [color=BLACK] - The `color` parameter is used to specify the color of the node
22
+ * in a Red-Black Tree. It is optional and has a default value of `'BLACK'`.
23
+ */
24
+ constructor(key: K, value?: V, count?: number, color?: RBTNColor);
25
+ parent?: TreeCounterNode<K, V>;
26
+ _left?: OptNodeOrNull<TreeCounterNode<K, V>>;
27
+ get left(): OptNodeOrNull<TreeCounterNode<K, V>>;
28
+ set left(v: OptNodeOrNull<TreeCounterNode<K, V>>);
29
+ _right?: OptNodeOrNull<TreeCounterNode<K, V>>;
30
+ get right(): OptNodeOrNull<TreeCounterNode<K, V>>;
31
+ set right(v: OptNodeOrNull<TreeCounterNode<K, V>>);
32
+ }
33
+ /**
34
+ *
35
+ */
36
+ export declare class TreeCounter<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> {
37
+ /**
38
+ * The constructor function initializes a TreeCounter object with optional initial data.
39
+ * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
40
+ * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
41
+ * TreeCounter with initial data.
42
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
43
+ * behavior of the `TreeCounter` constructor. It can include properties such as `compareKeys` and
44
+ * `compareValues`, which are functions used to compare keys and values respectively.
45
+ */
46
+ constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, TreeCounterNode<K, V>> | R>, options?: TreeCounterOptions<K, V, R>);
47
+ protected _count: number;
48
+ /**
49
+ * The function calculates the sum of the count property of all nodes in a tree structure.
50
+ * @returns the sum of the count property of all nodes in the tree.
51
+ */
52
+ get count(): number;
53
+ /**
54
+ * Time Complexity: O(n)
55
+ * Space Complexity: O(1)
56
+ *
57
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
58
+ * search.
59
+ * @returns the sum of the count property of all nodes in the tree.
60
+ */
61
+ getComputedCount(): number;
62
+ /**
63
+ * The function creates a new TreeCounterNode with the specified key, value, color, and count.
64
+ * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
65
+ * which is a generic type representing the type of keys in the tree.
66
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
67
+ * associated with the key in the node. It is of type `V`, which can be any data type.
68
+ * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
69
+ * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
70
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
71
+ * the tree. It is an optional parameter and is used to keep track of the number of values associated
72
+ * with a key in the tree.
73
+ * @returns A new instance of the TreeCounterNode class, casted as TreeCounterNode<K, V>.
74
+ */
75
+ createNode(key: K, value?: V, color?: RBTNColor, count?: number): TreeCounterNode<K, V>;
76
+ /**
77
+ * The function creates a new instance of a TreeCounter with the specified options and returns it.
78
+ * @param [options] - The `options` parameter is an optional object that contains additional
79
+ * configuration options for creating the `TreeCounter`. It is of type `TreeCounterOptions<K, V,
80
+ * R>`.
81
+ * @returns a new instance of the `TreeCounter` class, with the provided options merged with the
82
+ * existing `iterationType` property. The returned value is casted as `TREE`.
83
+ */
84
+ createTree(options?: TreeCounterOptions<K, V, R>): TreeCounter<K, V, R, MK, MV, MR>;
85
+ /**
86
+ * The function checks if the input is an instance of the TreeCounterNode class.
87
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
88
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
89
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
90
+ * an instance of the `TreeCounterNode` class.
91
+ */
92
+ isNode(keyNodeOrEntry: BTNRep<K, V, TreeCounterNode<K, V>>): keyNodeOrEntry is TreeCounterNode<K, V>;
93
+ /**
94
+ * Time Complexity: O(log n)
95
+ * Space Complexity: O(1)
96
+ *
97
+ * The function overrides the add method of a class and adds a new node to a data structure, updating
98
+ * the count and returning a boolean indicating success.
99
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The
100
+ * `keyNodeOrEntry` parameter can accept one of the following types:
101
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
102
+ * data structure. It is an optional parameter, so it can be omitted if not needed.
103
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
104
+ * be added to the data structure. By default, it is set to 1, meaning that if no value is provided
105
+ * for `count`, the key-value pair will be added once.
106
+ * @returns The method is returning a boolean value. It returns true if the addition of the new node
107
+ * was successful, and false otherwise.
108
+ */
109
+ add(keyNodeOrEntry: BTNRep<K, V, TreeCounterNode<K, V>>, value?: V, count?: number): boolean;
110
+ /**
111
+ * Time Complexity: O(log n)
112
+ * Space Complexity: O(1)
113
+ *
114
+ * The function `delete` in TypeScript overrides the deletion operation in a binary tree data
115
+ * structure, handling cases where nodes have children and maintaining balance in the tree.
116
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The `predicate`
117
+ * parameter in the `delete` method is used to specify the condition or key based on which a node
118
+ * should be deleted from the binary tree. It can be a key, a node, or an entry.
119
+ * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
120
+ * boolean flag that determines whether to ignore the count of nodes when performing deletion. If
121
+ * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
122
+ * `ignoreCount` is `false
123
+ * @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<TreeCounterNode<K, V>>` objects.
124
+ */
125
+ delete(keyNodeOrEntry: BTNRep<K, V, TreeCounterNode<K, V>>, ignoreCount?: boolean): BinaryTreeDeleteResult<TreeCounterNode<K, V>>[];
126
+ /**
127
+ * Time Complexity: O(1)
128
+ * Space Complexity: O(1)
129
+ *
130
+ * The "clear" function overrides the parent class's "clear" function and also resets the count to
131
+ * zero.
132
+ */
133
+ clear(): void;
134
+ /**
135
+ * Time Complexity: O(n log n)
136
+ * Space Complexity: O(log n)
137
+ *
138
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
139
+ * tree using either a recursive or iterative approach.
140
+ * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
141
+ * specifies the type of iteration to use when building the balanced binary search tree. It has a
142
+ * default value of `this.iterationType`, which means it will use the iteration type specified by the
143
+ * `iterationType` property of the current object.
144
+ * @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
145
+ * balancing operation is successful, and `false` if there are no nodes to balance.
146
+ */
147
+ perfectlyBalance(iterationType?: IterationType): boolean;
148
+ /**
149
+ * Time complexity: O(n)
150
+ * Space complexity: O(n)
151
+ *
152
+ * The function overrides the clone method to create a deep copy of a tree object.
153
+ * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
154
+ */
155
+ clone(): TreeCounter<K, V, R, MK, MV, MR>;
156
+ /**
157
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeCounter with
158
+ * modified entries based on a provided callback.
159
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
160
+ * map. It takes four arguments:
161
+ * @param [options] - The `options` parameter in the `override map` function is of type
162
+ * `TreeCounterOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
163
+ * options when creating a new `TreeCounter` instance within the `map` function. These options could
164
+ * include things like
165
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
166
+ * the value of `this` when executing the `callback` function. It allows you to set the context
167
+ * (value of `this`) for the callback function when it is called within the `map` function. This
168
+ * @returns A new TreeCounter instance is being returned, which is populated with entries generated
169
+ * by the provided callback function.
170
+ */
171
+ map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: TreeCounterOptions<MK, MV, MR>, thisArg?: any): TreeCounter<MK, MV, MR>;
172
+ /**
173
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
174
+ * node based on the input.
175
+ * @param {BTNRep<K, V, TreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
176
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, TreeCounterNode<K, V>>`.
177
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
178
+ * associated with the key in the node. It is used when creating a new node or updating the value of
179
+ * an existing node.
180
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
181
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
182
+ * @returns either a TreeCounterNode<K, V> object or undefined.
183
+ */
184
+ protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: BTNRep<K, V, TreeCounterNode<K, V>>, value?: V, count?: number): [TreeCounterNode<K, V> | undefined, V | undefined];
185
+ /**
186
+ * Time Complexity: O(1)
187
+ * Space Complexity: O(1)
188
+ *
189
+ * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
190
+ * in a binary search tree.
191
+ * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} srcNode - The `srcNode` parameter represents the source node
192
+ * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
193
+ * instance of the `BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>` class.
194
+ * @param {R | BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>} destNode - The `destNode` parameter represents the destination
195
+ * node where the properties will be swapped with the source node.
196
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
197
+ * If either `srcNode` or `destNode` is undefined, it returns undefined.
198
+ */
199
+ protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>, destNode: BSTNOptKeyOrNode<K, TreeCounterNode<K, V>>): TreeCounterNode<K, V> | undefined;
200
+ /**
201
+ * Time Complexity: O(1)
202
+ * Space Complexity: O(1)
203
+ *
204
+ * The function replaces an old node with a new node and updates the count property of the new node.
205
+ * @param {TreeCounterNode<K, V>} oldNode - The `oldNode` parameter is the node that you want to replace in the data
206
+ * structure.
207
+ * @param {TreeCounterNode<K, V>} newNode - The `newNode` parameter is an instance of the `TreeCounterNode<K, V>` class.
208
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
209
+ * superclass, which is of type `TreeCounterNode<K, V>`.
210
+ */
211
+ protected _replaceNode(oldNode: TreeCounterNode<K, V>, newNode: TreeCounterNode<K, V>): TreeCounterNode<K, V>;
212
+ }