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
@@ -3,46 +3,33 @@ import { Queue } from '../queue';
3
3
  import { isComparable } from '../../utils';
4
4
  import { Range } from '../../common';
5
5
  export class BSTNode extends BinaryTreeNode {
6
- parent;
6
+ /**
7
+ * This TypeScript constructor function initializes an instance with a key and an optional value.
8
+ * @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
9
+ * within a data structure. It serves as a reference or identifier for accessing or manipulating the
10
+ * associated value.
11
+ * @param {V} [value] - The `value` parameter in the constructor is optional, meaning it does not
12
+ * have to be provided when creating an instance of the class. If a value is not provided, it will
13
+ * default to `undefined`.
14
+ */
7
15
  constructor(key, value) {
8
16
  super(key, value);
9
- this.parent = undefined;
10
- this._left = undefined;
11
- this._right = undefined;
12
17
  }
13
- _left;
14
- /**
15
- * The function returns the value of the `_left` property.
16
- * @returns The `_left` property of the current object is being returned.
17
- */
18
+ parent = undefined;
19
+ _left = undefined;
18
20
  get left() {
19
21
  return this._left;
20
22
  }
21
- /**
22
- * The function sets the left child of a node and updates the parent reference of the child.
23
- * @param {OptNode<NODE>} v - The parameter `v` is of type `OptNode<NODE>`. It can either be an
24
- * instance of the `NODE` class or `undefined`.
25
- */
26
23
  set left(v) {
27
24
  if (v) {
28
25
  v.parent = this;
29
26
  }
30
27
  this._left = v;
31
28
  }
32
- _right;
33
- /**
34
- * The function returns the right node of a binary tree or undefined if there is no right node.
35
- * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
36
- * `undefined`.
37
- */
29
+ _right = undefined;
38
30
  get right() {
39
31
  return this._right;
40
32
  }
41
- /**
42
- * The function sets the right child of a node and updates the parent reference of the child.
43
- * @param {OptNode<NODE>} v - The parameter `v` is of type `OptNode<NODE>`. It can either be a
44
- * `NODE` object or `undefined`.
45
- */
46
33
  set right(v) {
47
34
  if (v) {
48
35
  v.parent = this;
@@ -117,12 +104,13 @@ export class BSTNode extends BinaryTreeNode {
117
104
  */
118
105
  export class BST extends BinaryTree {
119
106
  /**
120
- * This is the constructor function for a Binary Search Tree class in TypeScript.
121
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
122
- * iterable that can contain either keys, nodes, entries, or raw elements. These elements will be
123
- * added to the binary search tree during the construction of the object.
124
- * @param [options] - An optional object that contains additional options for the Binary Search Tree.
125
- * It can include a comparator function that defines the order of the elements in the tree.
107
+ * This TypeScript constructor initializes a binary search tree with optional options and adds
108
+ * elements if provided.
109
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
110
+ * iterable that can contain elements of type `BTNRep<K, V, BSTNode<K, V>>` or `R`. It is used to
111
+ * initialize the binary search tree with keys, nodes, entries, or raw data.
112
+ * @param [options] - The `options` parameter is an optional object that can contain the following
113
+ * properties:
126
114
  */
127
115
  constructor(keysNodesEntriesOrRaws = [], options) {
128
116
  super([], options);
@@ -137,19 +125,10 @@ export class BST extends BinaryTree {
137
125
  this.addMany(keysNodesEntriesOrRaws);
138
126
  }
139
127
  _root = undefined;
140
- /**
141
- * The function returns the root node of a tree structure.
142
- * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
143
- */
144
128
  get root() {
145
129
  return this._root;
146
130
  }
147
131
  _isReverse = false;
148
- /**
149
- * The above function is a getter method in TypeScript that returns the value of the private property
150
- * `_isReverse`.
151
- * @returns The `isReverse` property of the object, which is a boolean value.
152
- */
153
132
  get isReverse() {
154
133
  return this._isReverse;
155
134
  }
@@ -173,29 +152,23 @@ export class BST extends BinaryTree {
173
152
  }
174
153
  return 0;
175
154
  };
176
- /**
177
- * The function returns the value of the _comparator property.
178
- * @returns The `_comparator` property is being returned.
179
- */
180
155
  get comparator() {
181
156
  return this._comparator;
182
157
  }
183
158
  _specifyComparable;
184
- /**
185
- * This function returns the value of the `_specifyComparable` property.
186
- * @returns The method `specifyComparable()` is being returned, which is a getter method for the
187
- * `_specifyComparable` property.
188
- */
189
159
  get specifyComparable() {
190
160
  return this._specifyComparable;
191
161
  }
192
162
  /**
163
+ * Time Complexity: O(1)
164
+ * Space Complexity: O(1)
165
+ *
193
166
  * The function creates a new BSTNode with the given key and value and returns it.
194
167
  * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
195
168
  * being created.
196
169
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
197
170
  * value associated with the key in the node being created.
198
- * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
171
+ * @returns The method is returning a new instance of the BSTNode class, casted as the BSTNode<K, V> type.
199
172
  */
200
173
  createNode(key, value) {
201
174
  return new BSTNode(key, this._isMapMode ? undefined : value);
@@ -204,14 +177,12 @@ export class BST extends BinaryTree {
204
177
  * Time Complexity: O(1)
205
178
  * Space Complexity: O(1)
206
179
  *
207
- * The `createTree` function in TypeScript overrides the default options with the provided options to
208
- * create a new Binary Search Tree.
209
- * @param [options] - The `options` parameter in the `createTree` method is an optional object that
210
- * can contain the following properties:
211
- * @returns A new instance of a Binary Search Tree (BST) is being returned with the specified options
212
- * and properties inherited from the current instance.
180
+ * The function creates a new binary search tree with the specified options.
181
+ * @param [options] - The `options` parameter is an optional object that allows you to customize the
182
+ * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
183
+ * following properties:
184
+ * @returns a new instance of the BST class with the provided options.
213
185
  */
214
- // @ts-ignore
215
186
  createTree(options) {
216
187
  return new BST([], {
217
188
  iterationType: this.iterationType,
@@ -228,8 +199,8 @@ export class BST extends BinaryTree {
228
199
  *
229
200
  * The function ensures the existence of a node in a data structure and returns it, or undefined if
230
201
  * it doesn't exist.
231
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
232
- * `keyNodeEntryOrRaw` can accept a value of type `R`, which represents the key, node,
202
+ * @param {BTNRep<K, V, BSTNode<K, V>>} keyNodeOrEntry - The parameter
203
+ * `keyNodeOrEntry` can accept a value of type `R`, which represents the key, node,
233
204
  * entry, or raw element that needs to be ensured in the tree.
234
205
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
235
206
  * parameter that specifies the type of iteration to be used when ensuring a node. It has a default
@@ -237,43 +208,49 @@ export class BST extends BinaryTree {
237
208
  * @returns The method is returning either the node that was ensured or `undefined` if the node could
238
209
  * not be ensured.
239
210
  */
240
- ensureNode(keyNodeEntryOrRaw, iterationType = this.iterationType) {
241
- return super.ensureNode(keyNodeEntryOrRaw, iterationType) ?? undefined;
211
+ ensureNode(keyNodeOrEntry, iterationType = this.iterationType) {
212
+ return super.ensureNode(keyNodeOrEntry, iterationType) ?? undefined;
242
213
  }
243
214
  /**
215
+ * Time Complexity: O(1)
216
+ * Space Complexity: O(1)
217
+ *
244
218
  * The function checks if the input is an instance of the BSTNode class.
245
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
246
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
247
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
219
+ * @param {BTNRep<K, V, BSTNode<K, V>>} keyNodeOrEntry - The parameter
220
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, BSTNode<K, V>>`.
221
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
248
222
  * an instance of the `BSTNode` class.
249
223
  */
250
- isNode(keyNodeEntryOrRaw) {
251
- return keyNodeEntryOrRaw instanceof BSTNode;
224
+ isNode(keyNodeOrEntry) {
225
+ return keyNodeOrEntry instanceof BSTNode;
252
226
  }
253
227
  /**
254
- * The function "override isKey" checks if a key is comparable based on a given comparator.
228
+ * Time Complexity: O(1)
229
+ * Space Complexity: O(1)
230
+ *
231
+ * The function "override isValidKey" checks if a key is comparable based on a given comparator.
255
232
  * @param {any} key - The `key` parameter is a value that will be checked to determine if it is of
256
233
  * type `K`.
257
- * @returns The `override isKey(key: any): key is K` function is returning a boolean value based on
234
+ * @returns The `override isValidKey(key: any): key is K` function is returning a boolean value based on
258
235
  * the result of the `isComparable` function with the condition `this._compare !==
259
236
  * this._DEFAULT_COMPARATOR`.
260
237
  */
261
- isKey(key) {
238
+ isValidKey(key) {
262
239
  return isComparable(key, this._specifyComparable !== undefined);
263
240
  }
264
241
  /**
265
242
  * Time Complexity: O(log n)
266
- * Space Complexity: O(1)
243
+ * Space Complexity: O(log n)
267
244
  *
268
245
  * The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
269
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
270
- * `keyNodeEntryOrRaw` can accept a value of type `R` or `BTNRep<K, V, NODE>`.
246
+ * @param {BTNRep<K, V, BSTNode<K, V>>} keyNodeOrEntry - The parameter
247
+ * `keyNodeOrEntry` can accept a value of type `R` or `BTNRep<K, V, BSTNode<K, V>>`.
271
248
  * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
272
249
  * key in the binary search tree. If provided, it will be stored in the node along with the key.
273
250
  * @returns a boolean value.
274
251
  */
275
- add(keyNodeEntryOrRaw, value) {
276
- const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
252
+ add(keyNodeOrEntry, value) {
253
+ const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
277
254
  if (newNode === undefined)
278
255
  return false;
279
256
  if (this._root === undefined) {
@@ -299,7 +276,8 @@ export class BST extends BinaryTree {
299
276
  this._size++;
300
277
  return true;
301
278
  }
302
- current = current.left;
279
+ if (current.left !== null)
280
+ current = current.left;
303
281
  }
304
282
  else {
305
283
  if (current.right === undefined) {
@@ -309,7 +287,8 @@ export class BST extends BinaryTree {
309
287
  this._size++;
310
288
  return true;
311
289
  }
312
- current = current.right;
290
+ if (current.right !== null)
291
+ current = current.right;
313
292
  }
314
293
  }
315
294
  return false;
@@ -342,8 +321,10 @@ export class BST extends BinaryTree {
342
321
  valuesIterator = values[Symbol.iterator]();
343
322
  }
344
323
  if (!isBalanceAdd) {
345
- for (const kve of keysNodesEntriesOrRaws) {
324
+ for (let kve of keysNodesEntriesOrRaws) {
346
325
  const value = valuesIterator?.next().value;
326
+ if (this.isRaw(kve))
327
+ kve = this._toEntryFn(kve);
347
328
  inserted.push(this.add(kve, value));
348
329
  }
349
330
  return inserted;
@@ -357,23 +338,21 @@ export class BST extends BinaryTree {
357
338
  let sorted = [];
358
339
  sorted = realBTNExemplars.sort(({ key: a }, { key: b }) => {
359
340
  let keyA, keyB;
360
- if (this.isEntry(a))
341
+ if (this.isRaw(a))
342
+ keyA = this._toEntryFn(a)[0];
343
+ else if (this.isEntry(a))
361
344
  keyA = a[0];
362
345
  else if (this.isRealNode(a))
363
346
  keyA = a.key;
364
- else if (this._toEntryFn) {
365
- keyA = this._toEntryFn(a)[0];
366
- }
367
347
  else {
368
348
  keyA = a;
369
349
  }
370
- if (this.isEntry(b))
350
+ if (this.isRaw(b))
351
+ keyB = this._toEntryFn(b)[0];
352
+ else if (this.isEntry(b))
371
353
  keyB = b[0];
372
354
  else if (this.isRealNode(b))
373
355
  keyB = b.key;
374
- else if (this._toEntryFn) {
375
- keyB = this._toEntryFn(b)[0];
376
- }
377
356
  else {
378
357
  keyB = b;
379
358
  }
@@ -386,7 +365,13 @@ export class BST extends BinaryTree {
386
365
  if (arr.length === 0)
387
366
  return;
388
367
  const mid = Math.floor((arr.length - 1) / 2);
389
- const { key, value, orgIndex } = arr[mid];
368
+ let { key, value } = arr[mid];
369
+ const { orgIndex } = arr[mid];
370
+ if (this.isRaw(key)) {
371
+ const entry = this._toEntryFn(key);
372
+ key = entry[0];
373
+ value = entry[1] ?? value;
374
+ }
390
375
  inserted[orgIndex] = this.add(key, value);
391
376
  _dfs(arr.slice(0, mid));
392
377
  _dfs(arr.slice(mid + 1));
@@ -400,7 +385,13 @@ export class BST extends BinaryTree {
400
385
  const [l, r] = popped;
401
386
  if (l <= r) {
402
387
  const m = l + Math.floor((r - l) / 2);
403
- const { key, value, orgIndex } = sorted[m];
388
+ let { key, value } = sorted[m];
389
+ const { orgIndex } = sorted[m];
390
+ if (this.isRaw(key)) {
391
+ const entry = this._toEntryFn(key);
392
+ key = entry[0];
393
+ value = entry[1] ?? value;
394
+ }
404
395
  inserted[orgIndex] = this.add(key, value);
405
396
  stack.push([m + 1, r]);
406
397
  stack.push([l, m - 1]);
@@ -416,35 +407,23 @@ export class BST extends BinaryTree {
416
407
  }
417
408
  return inserted;
418
409
  }
419
- /**
420
- * Time Complexity: O(n)
421
- * Space Complexity: O(1)
422
- *
423
- * The `merge` function overrides the base class method by adding elements from another
424
- * binary search tree.
425
- * @param anotherTree - `anotherTree` is an instance of a Binary Search Tree (BST) with key type `K`,
426
- * value type `V`, return type `R`, node type `NODE`, and tree type `TREE`.
427
- */
428
- merge(anotherTree) {
429
- this.addMany(anotherTree, [], false);
430
- }
431
410
  /**
432
411
  * Time Complexity: O(log n)
433
412
  * Space Complexity: O(k + log n)
434
413
  *
435
414
  * The function `search` in TypeScript overrides the search behavior in a binary tree structure based
436
415
  * on specified criteria.
437
- * @param {BTNRep<K, V, NODE> | R | NodePredicate<NODE>} keyNodeEntryRawOrPredicate - The
438
- * `keyNodeEntryRawOrPredicate` parameter in the `override search` method can accept one of the
416
+ * @param {BTNRep<K, V, BSTNode<K, V>> | NodePredicate<BSTNode<K, V>>} keyNodeEntryOrPredicate - The
417
+ * `keyNodeEntryOrPredicate` parameter in the `override search` method can accept one of the
439
418
  * following types:
440
419
  * @param [onlyOne=false] - The `onlyOne` parameter is a boolean flag that determines whether the
441
420
  * search should stop after finding the first matching node. If `onlyOne` is set to `true`, the
442
421
  * search will return as soon as a matching node is found. If `onlyOne` is set to `false`, the
443
422
  * @param {C} callback - The `callback` parameter in the `override search` function is a function
444
423
  * that will be called on each node that matches the search criteria. It is of type `C`, which
445
- * extends `NodeCallback<NODE>`. The callback function should accept a node of type `NODE` as its
424
+ * extends `NodeCallback<BSTNode<K, V>>`. The callback function should accept a node of type `BSTNode<K, V>` as its
446
425
  * argument and
447
- * @param {BTNRep<K, V, NODE> | R} startNode - The `startNode` parameter in the `override search`
426
+ * @param {BTNRep<K, V, BSTNode<K, V>>} startNode - The `startNode` parameter in the `override search`
448
427
  * method represents the node from which the search operation will begin. It is the starting point
449
428
  * for searching within the tree data structure. The method ensures that the `startNode` is a valid
450
429
  * node before proceeding with the search operation. If the `
@@ -456,26 +435,26 @@ export class BST extends BinaryTree {
456
435
  * structure based on the provided key, predicate, and other options. The search results are
457
436
  * collected in an array and returned as the output of the method.
458
437
  */
459
- search(keyNodeEntryRawOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
460
- if (keyNodeEntryRawOrPredicate === undefined)
438
+ search(keyNodeEntryOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
439
+ if (keyNodeEntryOrPredicate === undefined)
461
440
  return [];
462
- if (keyNodeEntryRawOrPredicate === null)
441
+ if (keyNodeEntryOrPredicate === null)
463
442
  return [];
464
443
  startNode = this.ensureNode(startNode);
465
444
  if (!startNode)
466
445
  return [];
467
446
  let predicate;
468
- const isRange = this.isRange(keyNodeEntryRawOrPredicate);
447
+ const isRange = this.isRange(keyNodeEntryOrPredicate);
469
448
  // Set predicate based on parameter type
470
449
  if (isRange) {
471
- predicate = node => keyNodeEntryRawOrPredicate.isInRange(node.key, this._comparator);
450
+ predicate = node => keyNodeEntryOrPredicate.isInRange(node.key, this._comparator);
472
451
  }
473
452
  else {
474
- predicate = this._ensurePredicate(keyNodeEntryRawOrPredicate);
453
+ predicate = this._ensurePredicate(keyNodeEntryOrPredicate);
475
454
  }
476
455
  const isToLeftByRange = (cur) => {
477
456
  if (isRange) {
478
- const range = keyNodeEntryRawOrPredicate;
457
+ const range = keyNodeEntryOrPredicate;
479
458
  const leftS = this.isReverse ? range.high : range.low;
480
459
  const leftI = this.isReverse ? range.includeHigh : range.includeLow;
481
460
  return (leftI && this._compare(cur.key, leftS) >= 0) || (!leftI && this._compare(cur.key, leftS) > 0);
@@ -484,7 +463,7 @@ export class BST extends BinaryTree {
484
463
  };
485
464
  const isToRightByRange = (cur) => {
486
465
  if (isRange) {
487
- const range = keyNodeEntryRawOrPredicate;
466
+ const range = keyNodeEntryOrPredicate;
488
467
  const rightS = this.isReverse ? range.low : range.high;
489
468
  const rightI = this.isReverse ? range.includeLow : range.includeLow;
490
469
  return (rightI && this._compare(cur.key, rightS) <= 0) || (!rightI && this._compare(cur.key, rightS) < 0);
@@ -507,8 +486,8 @@ export class BST extends BinaryTree {
507
486
  if (this.isRealNode(cur.right) && isToRightByRange(cur))
508
487
  dfs(cur.right);
509
488
  }
510
- else if (!this._isPredicate(keyNodeEntryRawOrPredicate)) {
511
- const benchmarkKey = this._extractKey(keyNodeEntryRawOrPredicate);
489
+ else if (!this._isPredicate(keyNodeEntryOrPredicate)) {
490
+ const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
512
491
  if (this.isRealNode(cur.left) &&
513
492
  benchmarkKey !== null &&
514
493
  benchmarkKey !== undefined &&
@@ -544,8 +523,8 @@ export class BST extends BinaryTree {
544
523
  if (this.isRealNode(cur.right) && isToRightByRange(cur))
545
524
  stack.push(cur.right);
546
525
  }
547
- else if (!this._isPredicate(keyNodeEntryRawOrPredicate)) {
548
- const benchmarkKey = this._extractKey(keyNodeEntryRawOrPredicate);
526
+ else if (!this._isPredicate(keyNodeEntryOrPredicate)) {
527
+ const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
549
528
  if (this.isRealNode(cur.right) &&
550
529
  benchmarkKey !== null &&
551
530
  benchmarkKey !== undefined &&
@@ -569,16 +548,16 @@ export class BST extends BinaryTree {
569
548
  }
570
549
  /**
571
550
  * Time Complexity: O(log n)
572
- * Space Complexity: O(n)
551
+ * Space Complexity: O(k + log n)
573
552
  *
574
553
  * The `rangeSearch` function searches for nodes within a specified range in a binary search tree.
575
554
  * @param {Range<K> | [K, K]} range - The `range` parameter in the `rangeSearch` function can be
576
555
  * either a `Range` object or an array of two elements representing the range boundaries.
577
556
  * @param {C} callback - The `callback` parameter in the `rangeSearch` function is a callback
578
557
  * function that is used to process each node that is found within the specified range during the
579
- * search operation. It is of type `NodeCallback<NODE>`, where `NODE` is the type of nodes in the
558
+ * search operation. It is of type `NodeCallback<BSTNode<K, V>>`, where `BSTNode<K, V>` is the type of nodes in the
580
559
  * data structure.
581
- * @param {BTNRep<K, V, NODE> | R} startNode - The `startNode` parameter in the `rangeSearch`
560
+ * @param {BTNRep<K, V, BSTNode<K, V>>} startNode - The `startNode` parameter in the `rangeSearch`
582
561
  * function represents the node from which the search for nodes within the specified range will
583
562
  * begin. It is the starting point for the range search operation.
584
563
  * @param {IterationType} iterationType - The `iterationType` parameter in the `rangeSearch` function
@@ -594,12 +573,12 @@ export class BST extends BinaryTree {
594
573
  }
595
574
  /**
596
575
  * Time Complexity: O(log n)
597
- * Space Complexity: O(1)
576
+ * Space Complexity: O(log n)
598
577
  *
599
- * This function retrieves a node based on a given keyNodeEntryRawOrPredicate within a binary search tree structure.
600
- * @param {BTNRep<K, V, NODE> | R | NodePredicate<NODE>} keyNodeEntryRawOrPredicate - The `keyNodeEntryRawOrPredicate`
601
- * parameter can be of type `BTNRep<K, V, NODE>`, `R`, or `NodePredicate<NODE>`.
602
- * @param {R | BSTNOptKeyOrNode<K, NODE>} startNode - The `startNode` parameter in the `getNode` method
578
+ * This function retrieves a node based on a given keyNodeEntryOrPredicate within a binary search tree structure.
579
+ * @param {BTNRep<K, V, BSTNode<K, V>> | NodePredicate<BSTNode<K, V>>} keyNodeEntryOrPredicate - The `keyNodeEntryOrPredicate`
580
+ * parameter can be of type `BTNRep<K, V, BSTNode<K, V>>`, `R`, or `NodePredicate<BSTNode<K, V>>`.
581
+ * @param {BSTNOptKeyOrNode<K, BSTNode<K, V>>} startNode - The `startNode` parameter in the `getNode` method
603
582
  * is used to specify the starting point for searching nodes in the binary search tree. If no
604
583
  * specific starting point is provided, the default value is set to `this._root`, which is the root
605
584
  * node of the binary search tree.
@@ -607,13 +586,13 @@ export class BST extends BinaryTree {
607
586
  * parameter that specifies the type of iteration to be used. It has a default value of
608
587
  * `this.iterationType`, which means it will use the iteration type defined in the class instance if
609
588
  * no value is provided when calling the method.
610
- * @returns The `getNode` method is returning an optional binary search tree node (`OptNode<NODE>`).
611
- * It is using the `getNodes` method to find the node based on the provided keyNodeEntryRawOrPredicate, beginning at
589
+ * @returns The `getNode` method is returning an optional binary search tree node (`OptNode<BSTNode<K, V>>`).
590
+ * It is using the `getNodes` method to find the node based on the provided keyNodeEntryOrPredicate, beginning at
612
591
  * the specified root node (`startNode`) and using the specified iteration type. The method then
613
592
  * returns the first node found or `undefined` if no node is found.
614
593
  */
615
- getNode(keyNodeEntryRawOrPredicate, startNode = this._root, iterationType = this.iterationType) {
616
- return this.getNodes(keyNodeEntryRawOrPredicate, true, startNode, iterationType)[0] ?? undefined;
594
+ getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
595
+ return this.getNodes(keyNodeEntryOrPredicate, true, startNode, iterationType)[0] ?? undefined;
617
596
  }
618
597
  /**
619
598
  * Time complexity: O(n)
@@ -627,7 +606,7 @@ export class BST extends BinaryTree {
627
606
  * @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
628
607
  * order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
629
608
  * take one of the following values:
630
- * @param {BTNRep<K, V, NODE> | R} startNode - The `startNode` parameter is the starting
609
+ * @param {BTNRep<K, V, BSTNode<K, V>>} startNode - The `startNode` parameter is the starting
631
610
  * point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
632
611
  * node entry. If not specified, the default value is the root of the tree.
633
612
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
@@ -647,7 +626,7 @@ export class BST extends BinaryTree {
647
626
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
648
627
  * visited during the breadth-first search. It should take a single argument, which is the current
649
628
  * node being visited, and it can return a value of any type.
650
- * @param {BTNRep<K, V, NODE> | R} startNode - The `startNode` parameter is the starting
629
+ * @param {BTNRep<K, V, BSTNode<K, V>>} startNode - The `startNode` parameter is the starting
651
630
  * point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
652
631
  * object. If no value is provided, the default value is the root of the tree.
653
632
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -665,9 +644,9 @@ export class BST extends BinaryTree {
665
644
  * The function overrides the listLevels method from the superclass and returns an array of arrays
666
645
  * containing the results of the callback function applied to each level of the tree.
667
646
  * @param {C} callback - The `callback` parameter is a generic type `C` that extends
668
- * `NodeCallback<NODE>`. It represents a callback function that will be called for each node in the
647
+ * `NodeCallback<BSTNode<K, V>>`. It represents a callback function that will be called for each node in the
669
648
  * tree during the iteration process.
670
- * @param {BTNRep<K, V, NODE> | R} startNode - The `startNode` parameter is the starting
649
+ * @param {BTNRep<K, V, BSTNode<K, V>>} startNode - The `startNode` parameter is the starting
671
650
  * point for listing the levels of the binary tree. It can be either a root node of the tree, a
672
651
  * key-value pair representing a node in the tree, or a key representing a node in the tree. If no
673
652
  * value is provided, the root of
@@ -691,7 +670,7 @@ export class BST extends BinaryTree {
691
670
  * @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
692
671
  * traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
693
672
  * 0, or 1, where:
694
- * @param {BTNRep<K, V, NODE> | R} targetNode - The `targetNode` parameter is the node in
673
+ * @param {BTNRep<K, V, BSTNode<K, V>>} targetNode - The `targetNode` parameter is the node in
695
674
  * the binary tree that you want to start traversing from. It can be specified either by providing
696
675
  * the key of the node, the node itself, or an entry containing the key and value of the node. If no
697
676
  * `targetNode` is provided,
@@ -827,7 +806,8 @@ export class BST extends BinaryTree {
827
806
  while (stack.length > 0 || node) {
828
807
  if (node) {
829
808
  stack.push(node);
830
- node = node.left;
809
+ if (node.left !== null)
810
+ node = node.left;
831
811
  }
832
812
  else {
833
813
  node = stack[stack.length - 1];
@@ -850,7 +830,25 @@ export class BST extends BinaryTree {
850
830
  }
851
831
  return balanced;
852
832
  }
853
- // @ts-ignore
833
+ /**
834
+ * Time complexity: O(n)
835
+ * Space complexity: O(n)
836
+ *
837
+ * The `map` function in TypeScript overrides the default map behavior for a binary search tree by
838
+ * applying a callback function to each entry and creating a new tree with the results.
839
+ * @param callback - A function that will be called for each entry in the BST. It takes four
840
+ * arguments: the key, the value (which can be undefined), the index of the entry, and a reference to
841
+ * the BST itself.
842
+ * @param [options] - The `options` parameter in the `override map` method is of type `BSTOptions<MK,
843
+ * MV, MR>`. It is an optional parameter that allows you to specify additional options for the Binary
844
+ * Search Tree (BST) being created in the `map` method. These options could include configuration
845
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` method is used to specify
846
+ * the value of `this` that should be used when executing the `callback` function. It allows you to
847
+ * set the context or scope in which the callback function will be called. This can be useful when
848
+ * you want
849
+ * @returns The `map` method is returning a new Binary Search Tree (`BST`) instance with the entries
850
+ * transformed by the provided callback function.
851
+ */
854
852
  map(callback, options, thisArg) {
855
853
  const newTree = new BST([], options);
856
854
  let index = 0;
@@ -860,24 +858,43 @@ export class BST extends BinaryTree {
860
858
  return newTree;
861
859
  }
862
860
  /**
861
+ * Time complexity: O(n)
862
+ * Space complexity: O(n)
863
+ *
864
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
865
+ * structure.
866
+ * @returns The `cloned` object is being returned.
867
+ */
868
+ clone() {
869
+ const cloned = this.createTree();
870
+ this._clone(cloned);
871
+ return cloned;
872
+ }
873
+ /**
874
+ * Time Complexity: O(1)
875
+ * Space Complexity: O(1)
876
+ *
863
877
  * The function overrides a method and converts a key, value pair or entry or raw element to a node.
864
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
865
- * type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
878
+ * @param {BTNRep<K, V, BSTNode<K, V>>} keyNodeOrEntry - A variable that can be of
879
+ * type R or BTNRep<K, V, BSTNode<K, V>>. It represents either a key, a node, an entry, or a raw
866
880
  * element.
867
881
  * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
868
882
  * value associated with a key in a key-value pair.
869
- * @returns either a NODE object or undefined.
883
+ * @returns either a BSTNode<K, V> object or undefined.
870
884
  */
871
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
872
- const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
885
+ _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value) {
886
+ const [node, entryValue] = super._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
873
887
  if (node === null)
874
888
  return [undefined, undefined];
875
889
  return [node, value ?? entryValue];
876
890
  }
877
891
  /**
892
+ * Time Complexity: O(1)
893
+ * Space Complexity: O(1)
894
+ *
878
895
  * The function sets the root of a tree-like structure and updates the parent property of the new
879
896
  * root.
880
- * @param {OptNode<NODE>} v - v is a parameter of type NODE or undefined.
897
+ * @param {OptNode<BSTNode<K, V>>} v - v is a parameter of type BSTNode<K, V> or undefined.
881
898
  */
882
899
  _setRoot(v) {
883
900
  if (v) {
@@ -885,6 +902,20 @@ export class BST extends BinaryTree {
885
902
  }
886
903
  this._root = v;
887
904
  }
905
+ /**
906
+ * Time Complexity: O(1)
907
+ * Space Complexity: O(1)
908
+ *
909
+ * The _compare function compares two values using a specified comparator function and optionally
910
+ * reverses the result.
911
+ * @param {K} a - The parameter `a` is of type `K`, which is used as an input for comparison in the
912
+ * `_compare` method.
913
+ * @param {K} b - The parameter `b` in the `_compare` function is of type `K`.
914
+ * @returns The `_compare` method is returning the result of the ternary expression. If `_isReverse`
915
+ * is true, it returns the negation of the result of calling the `_comparator` function with
916
+ * arguments `a` and `b`. If `_isReverse` is false, it returns the result of calling the
917
+ * `_comparator` function with arguments `a` and `b`.
918
+ */
888
919
  _compare(a, b) {
889
920
  return this._isReverse ? -this._comparator(a, b) : this._comparator(a, b);
890
921
  }