data-structure-typed 1.53.9 → 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 -59
  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 -189
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +133 -357
  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 +108 -78
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js +126 -79
  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 +243 -190
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js +273 -229
  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 +141 -122
  21. package/dist/cjs/data-structures/binary-tree/bst.js +170 -134
  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 +84 -80
  27. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +101 -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} +54 -56
  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 -186
  33. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +140 -388
  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 +7 -6
  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 -3
  70. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  71. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
  72. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -2
  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 -3
  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 -3
  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} +72 -78
  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 +126 -80
  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 +243 -190
  94. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.js +276 -234
  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 +141 -122
  97. package/dist/{mjs → esm}/data-structures/binary-tree/bst.js +171 -140
  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 +84 -80
  103. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.js +100 -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} +88 -86
  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 -2
  148. package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.d.ts +3 -2
  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 +1407 -913
  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 +148 -394
  163. package/src/data-structures/binary-tree/avl-tree.ts +152 -112
  164. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  165. package/src/data-structures/binary-tree/binary-tree.ts +446 -379
  166. package/src/data-structures/binary-tree/bst.ts +224 -201
  167. package/src/data-structures/binary-tree/index.ts +2 -0
  168. package/src/data-structures/binary-tree/red-black-tree.ts +138 -114
  169. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  170. package/src/data-structures/binary-tree/tree-multi-map.ts +156 -428
  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 -11
  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 -4
  184. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -3
  185. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  186. package/src/types/data-structures/binary-tree/bst.ts +5 -3
  187. package/src/types/data-structures/binary-tree/index.ts +2 -0
  188. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -4
  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 -4
  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 -204
  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 -8
  231. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -4
  232. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -4
  233. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -5
  234. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -4
  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,34 +1,39 @@
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
  }
18
- _color;
19
- /**
20
- * The function returns the color value of a variable.
21
- * @returns The color value stored in the private variable `_color`.
22
- */
23
- get color() {
24
- return this._color;
17
+ parent = undefined;
18
+ _left = undefined;
19
+ get left() {
20
+ return this._left;
25
21
  }
26
- /**
27
- * The function sets the color property to the specified value.
28
- * @param {RBTNColor} value - The value parameter is of type RBTNColor.
29
- */
30
- set color(value) {
31
- this._color = value;
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;
32
37
  }
33
38
  }
34
39
  /**
@@ -86,14 +91,15 @@ export class RedBlackTreeNode extends BSTNode {
86
91
  */
87
92
  export class RedBlackTree extends BST {
88
93
  /**
89
- * This is the constructor function for a Red-Black Tree data structure in TypeScript.
90
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
91
- * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
92
- * initialize the RedBlackTree with the provided elements.
93
- * @param [options] - The `options` parameter is an optional object that can be passed to the
94
- * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
95
- * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
96
- * 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
97
103
  */
98
104
  constructor(keysNodesEntriesOrRaws = [], options) {
99
105
  super([], options);
@@ -103,14 +109,13 @@ export class RedBlackTree extends BST {
103
109
  }
104
110
  }
105
111
  _root;
106
- /**
107
- * The function returns the root node of a tree or undefined if there is no root.
108
- * @returns The root node of the tree structure, or undefined if there is no root node.
109
- */
110
112
  get root() {
111
113
  return this._root;
112
114
  }
113
115
  /**
116
+ * Time Complexity: O(1)
117
+ * Space Complexity: O(1)
118
+ *
114
119
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
115
120
  * @param {K} key - The key parameter represents the key value of the node being created. It is of
116
121
  * type K, which is a generic type that can be replaced with any specific type when using the
@@ -128,15 +133,14 @@ export class RedBlackTree extends BST {
128
133
  return new RedBlackTreeNode(key, this._isMapMode ? undefined : value, color);
129
134
  }
130
135
  /**
131
- * The function `createTree` overrides the default implementation to create a Red-Black Tree with
132
- * specified options in TypeScript.
133
- * @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
134
- * V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
135
- * allows you to pass additional configuration options when creating a new Red-
136
- * @returns A new instance of a RedBlackTree with the specified options and properties from the
137
- * current object is being returned.
136
+ * Time Complexity: O(1)
137
+ * Space Complexity: O(1)
138
+ *
139
+ * The function creates a new Red-Black Tree with the specified options.
140
+ * @param [options] - The `options` parameter is an optional object that contains additional
141
+ * configuration options for creating the Red-Black Tree. It has the following properties:
142
+ * @returns a new instance of a RedBlackTree object.
138
143
  */
139
- // @ts-ignore
140
144
  createTree(options) {
141
145
  return new RedBlackTree([], {
142
146
  iterationType: this.iterationType,
@@ -151,13 +155,13 @@ export class RedBlackTree extends BST {
151
155
  * Space Complexity: O(1)
152
156
  *
153
157
  * The function checks if the input is an instance of the RedBlackTreeNode class.
154
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
155
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
156
- * @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
157
161
  * an instance of the `RedBlackTreeNode` class.
158
162
  */
159
- isNode(keyNodeEntryOrRaw) {
160
- return keyNodeEntryOrRaw instanceof RedBlackTreeNode;
163
+ isNode(keyNodeOrEntry) {
164
+ return keyNodeOrEntry instanceof RedBlackTreeNode;
161
165
  }
162
166
  /**
163
167
  * Time Complexity: O(1)
@@ -172,12 +176,12 @@ export class RedBlackTree extends BST {
172
176
  }
173
177
  /**
174
178
  * Time Complexity: O(log n)
175
- * Space Complexity: O(1)
179
+ * Space Complexity: O(log n)
176
180
  *
177
181
  * The function adds a new node to a binary search tree and returns true if the node was successfully
178
182
  * added.
179
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
180
- * `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>>`.
181
185
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
182
186
  * the key in the data structure. It represents the value that you want to add or update in the data
183
187
  * structure.
@@ -185,8 +189,8 @@ export class RedBlackTree extends BST {
185
189
  * the method returns true. If the node already exists and its value is updated, the method also
186
190
  * returns true. If the node cannot be added or updated, the method returns false.
187
191
  */
188
- add(keyNodeEntryOrRaw, value) {
189
- const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
192
+ add(keyNodeOrEntry, value) {
193
+ const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
190
194
  if (!this.isRealNode(newNode))
191
195
  return false;
192
196
  const insertStatus = this._insert(newNode);
@@ -212,35 +216,37 @@ export class RedBlackTree extends BST {
212
216
  }
213
217
  /**
214
218
  * Time Complexity: O(log n)
215
- * Space Complexity: O(1)
219
+ * Space Complexity: O(log n)
216
220
  *
217
221
  * The function overrides the delete method in a binary tree data structure to remove a node based on
218
222
  * a given predicate and maintain the binary search tree properties.
219
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
223
+ * @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
220
224
  * parameter in the `override delete` method is used to specify the condition or key based on which a
221
225
  * node should be deleted from the binary tree. It can be a key, a node, an entry, or a predicate
222
226
  * function that determines which node(s) should be deleted.
223
- * @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>>`
224
228
  * objects. Each object in the array contains information about the deleted node and whether
225
229
  * balancing is needed.
226
230
  */
227
- delete(keyNodeEntryOrRaw) {
228
- if (keyNodeEntryOrRaw === null)
231
+ delete(keyNodeOrEntry) {
232
+ if (keyNodeOrEntry === null)
229
233
  return [];
230
234
  const results = [];
231
235
  let nodeToDelete;
232
- if (this._isPredicate(keyNodeEntryOrRaw))
233
- nodeToDelete = this.getNode(keyNodeEntryOrRaw);
236
+ if (this._isPredicate(keyNodeOrEntry))
237
+ nodeToDelete = this.getNode(keyNodeOrEntry);
234
238
  else
235
- nodeToDelete = this.isRealNode(keyNodeEntryOrRaw) ? keyNodeEntryOrRaw : this.getNode(keyNodeEntryOrRaw);
239
+ nodeToDelete = this.isRealNode(keyNodeOrEntry) ? keyNodeOrEntry : this.getNode(keyNodeOrEntry);
236
240
  if (!nodeToDelete) {
237
241
  return results;
238
242
  }
239
243
  let originalColor = nodeToDelete.color;
240
244
  let replacementNode;
241
245
  if (!this.isRealNode(nodeToDelete.left)) {
242
- replacementNode = nodeToDelete.right;
243
- this._transplant(nodeToDelete, nodeToDelete.right);
246
+ if (nodeToDelete.right !== null) {
247
+ replacementNode = nodeToDelete.right;
248
+ this._transplant(nodeToDelete, nodeToDelete.right);
249
+ }
244
250
  }
245
251
  else if (!this.isRealNode(nodeToDelete.right)) {
246
252
  replacementNode = nodeToDelete.left;
@@ -250,15 +256,18 @@ export class RedBlackTree extends BST {
250
256
  const successor = this.getLeftMost(node => node, nodeToDelete.right);
251
257
  if (successor) {
252
258
  originalColor = successor.color;
253
- replacementNode = successor.right;
259
+ if (successor.right !== null)
260
+ replacementNode = successor.right;
254
261
  if (successor.parent === nodeToDelete) {
255
262
  if (this.isRealNode(replacementNode)) {
256
263
  replacementNode.parent = successor;
257
264
  }
258
265
  }
259
266
  else {
260
- this._transplant(successor, successor.right);
261
- successor.right = nodeToDelete.right;
267
+ if (successor.right !== null) {
268
+ this._transplant(successor, successor.right);
269
+ successor.right = nodeToDelete.right;
270
+ }
262
271
  if (this.isRealNode(successor.right)) {
263
272
  successor.right.parent = successor;
264
273
  }
@@ -301,7 +310,6 @@ export class RedBlackTree extends BST {
301
310
  * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
302
311
  * provided callback function.
303
312
  */
304
- // @ts-ignore
305
313
  map(callback, options, thisArg) {
306
314
  const newTree = new RedBlackTree([], options);
307
315
  let index = 0;
@@ -310,13 +318,26 @@ export class RedBlackTree extends BST {
310
318
  }
311
319
  return newTree;
312
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
+ }
313
334
  /**
314
335
  * Time Complexity: O(1)
315
336
  * Space Complexity: O(1)
316
337
  *
317
338
  * The function sets the root of a tree-like structure and updates the parent property of the new
318
339
  * root.
319
- * @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.
320
341
  */
321
342
  _setRoot(v) {
322
343
  if (v) {
@@ -329,9 +350,9 @@ export class RedBlackTree extends BST {
329
350
  * Space Complexity: O(1)
330
351
  *
331
352
  * The function replaces an old node with a new node while preserving the color of the old node.
332
- * @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
333
354
  * the data structure.
334
- * @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
335
356
  * data structure.
336
357
  * @returns The method is returning the result of calling the `_replaceNode` method from the
337
358
  * superclass, with the `oldNode` and `newNode` parameters.
@@ -342,11 +363,11 @@ export class RedBlackTree extends BST {
342
363
  }
343
364
  /**
344
365
  * Time Complexity: O(log n)
345
- * Space Complexity: O(1)
366
+ * Space Complexity: O(log n)
346
367
  *
347
368
  * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
348
369
  * maintain the red-black tree properties.
349
- * @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
350
371
  * binary search tree.
351
372
  * @returns a string value indicating the result of the insertion operation. It can return either
352
373
  * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
@@ -390,9 +411,9 @@ export class RedBlackTree extends BST {
390
411
  * Space Complexity: O(1)
391
412
  *
392
413
  * The function `_transplant` is used to replace a node `u` with another node `v` in a binary tree.
393
- * @param {NODE} u - The parameter "u" represents a node in a binary tree.
394
- * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`, which means it can
395
- * 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`.
396
417
  */
397
418
  _transplant(u, v) {
398
419
  if (!u.parent) {
@@ -413,7 +434,7 @@ export class RedBlackTree extends BST {
413
434
  * Space Complexity: O(1)
414
435
  *
415
436
  * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
416
- * @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
417
438
  * structure. It can either be a valid node or `undefined`.
418
439
  */
419
440
  _insertFixup(z) {
@@ -450,7 +471,7 @@ export class RedBlackTree extends BST {
450
471
  else {
451
472
  // Symmetric case for the right child (left and right exchanged)
452
473
  // Follow the same logic as above with left and right exchanged
453
- const y = z?.parent?.parent?.left;
474
+ const y = z?.parent?.parent?.left ?? undefined;
454
475
  if (y?.color === 'RED') {
455
476
  z.parent.color = 'BLACK';
456
477
  y.color = 'BLACK';
@@ -480,7 +501,7 @@ export class RedBlackTree extends BST {
480
501
  *
481
502
  * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
482
503
  * the colors and performing rotations.
483
- * @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
484
505
  * be either a valid node object or `undefined`.
485
506
  * @returns The function does not return any value. It has a return type of `void`, which means it
486
507
  * does not return anything.
@@ -565,7 +586,7 @@ export class RedBlackTree extends BST {
565
586
  * Space Complexity: O(1)
566
587
  *
567
588
  * The `_leftRotate` function performs a left rotation on a given node in a binary tree.
568
- * @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
569
590
  * node in a binary tree or `undefined` if there is no node.
570
591
  * @returns void, which means it does not return any value.
571
592
  */
@@ -596,7 +617,7 @@ export class RedBlackTree extends BST {
596
617
  * Space Complexity: O(1)
597
618
  *
598
619
  * The `_rightRotate` function performs a right rotation on a given node in a binary tree.
599
- * @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
600
621
  * node in a binary tree or `undefined` if there is no node.
601
622
  * @returns void, which means it does not return any value.
602
623
  */
@@ -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;QACxD,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM,GAA2C,SAAS,CAAC;IAEpE,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAa,KAAK,CAAC,CAAwC;QACzD,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC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AC,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
+ }