data-structure-typed 1.54.0 → 1.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -0
  3. package/benchmark/report.html +1 -28
  4. package/benchmark/report.json +17 -326
  5. package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts → cjs/data-structures/binary-tree/avl-tree-counter.d.ts} +54 -47
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +408 -0
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  8. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -177
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +135 -340
  10. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +102 -57
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js +110 -47
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  15. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  16. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +240 -190
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js +269 -240
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/bst.d.ts +145 -112
  21. package/dist/cjs/data-structures/binary-tree/bst.js +180 -129
  22. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -0
  24. package/dist/cjs/data-structures/binary-tree/index.js +2 -0
  25. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  27. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +115 -79
  28. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  29. package/dist/{mjs/data-structures/binary-tree/tree-multi-map.d.ts → cjs/data-structures/binary-tree/tree-counter.d.ts} +74 -64
  30. package/dist/cjs/data-structures/binary-tree/tree-counter.js +445 -0
  31. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -0
  32. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +78 -174
  33. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +142 -377
  34. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  35. package/dist/cjs/data-structures/graph/directed-graph.d.ts +3 -0
  36. package/dist/cjs/data-structures/graph/directed-graph.js +3 -0
  37. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  38. package/dist/cjs/data-structures/graph/map-graph.d.ts +3 -0
  39. package/dist/cjs/data-structures/graph/map-graph.js +3 -0
  40. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +3 -0
  42. package/dist/cjs/data-structures/graph/undirected-graph.js +3 -0
  43. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  44. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  45. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +3 -0
  46. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  48. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +3 -0
  49. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/matrix/matrix.d.ts +3 -0
  51. package/dist/cjs/data-structures/matrix/matrix.js +3 -0
  52. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  53. package/dist/cjs/data-structures/matrix/navigator.d.ts +3 -0
  54. package/dist/cjs/data-structures/matrix/navigator.js +3 -0
  55. package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  57. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +3 -0
  58. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  60. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +3 -0
  61. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/trie/trie.d.ts +0 -4
  63. package/dist/cjs/data-structures/trie/trie.js +0 -4
  64. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  65. package/dist/cjs/interfaces/binary-tree.d.ts +8 -8
  66. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  67. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +3 -0
  68. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  69. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  70. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  71. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  72. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -3
  73. package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -0
  74. package/dist/cjs/types/data-structures/binary-tree/index.js +2 -0
  75. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  76. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -4
  77. package/dist/cjs/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  78. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +3 -0
  79. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  80. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -4
  81. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  82. package/dist/{mjs/data-structures/binary-tree/avl-tree-multi-map.js → esm/data-structures/binary-tree/avl-tree-counter.js} +73 -60
  83. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  84. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -0
  85. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +191 -0
  86. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  87. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +234 -0
  88. package/dist/{mjs → esm}/data-structures/binary-tree/avl-tree.js +110 -47
  89. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -0
  90. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  91. package/dist/{mjs → esm}/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  92. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +1 -0
  93. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.d.ts +240 -190
  94. package/dist/{mjs → esm}/data-structures/binary-tree/binary-tree.js +272 -245
  95. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -0
  96. package/dist/{mjs → esm}/data-structures/binary-tree/bst.d.ts +145 -112
  97. package/dist/{mjs → esm}/data-structures/binary-tree/bst.js +201 -155
  98. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -0
  99. package/dist/{mjs → esm}/data-structures/binary-tree/index.d.ts +2 -0
  100. package/dist/{mjs → esm}/data-structures/binary-tree/index.js +2 -0
  101. package/dist/{mjs → esm}/data-structures/binary-tree/index.js.map +1 -1
  102. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  103. package/dist/{mjs → esm}/data-structures/binary-tree/red-black-tree.js +115 -79
  104. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -0
  105. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +212 -0
  106. package/dist/{mjs/data-structures/binary-tree/tree-multi-map.js → esm/data-structures/binary-tree/tree-counter.js} +111 -96
  107. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -0
  108. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +106 -0
  109. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +196 -0
  110. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  111. package/dist/{mjs → esm}/data-structures/graph/directed-graph.d.ts +3 -0
  112. package/dist/{mjs → esm}/data-structures/graph/directed-graph.js +3 -0
  113. package/dist/esm/data-structures/graph/directed-graph.js.map +1 -0
  114. package/dist/{mjs → esm}/data-structures/graph/map-graph.d.ts +3 -0
  115. package/dist/{mjs → esm}/data-structures/graph/map-graph.js +3 -0
  116. package/dist/esm/data-structures/graph/map-graph.js.map +1 -0
  117. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.d.ts +3 -0
  118. package/dist/{mjs → esm}/data-structures/graph/undirected-graph.js +3 -0
  119. package/dist/esm/data-structures/graph/undirected-graph.js.map +1 -0
  120. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  121. package/dist/{mjs → esm}/data-structures/linked-list/singly-linked-list.js +3 -0
  122. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -0
  123. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  124. package/dist/{mjs → esm}/data-structures/linked-list/skip-linked-list.js +3 -0
  125. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +1 -0
  126. package/dist/{mjs → esm}/data-structures/matrix/matrix.d.ts +3 -0
  127. package/dist/{mjs → esm}/data-structures/matrix/matrix.js +3 -0
  128. package/dist/esm/data-structures/matrix/matrix.js.map +1 -0
  129. package/dist/{mjs → esm}/data-structures/matrix/navigator.d.ts +3 -0
  130. package/dist/{mjs → esm}/data-structures/matrix/navigator.js +3 -0
  131. package/dist/esm/data-structures/matrix/navigator.js.map +1 -0
  132. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  133. package/dist/{mjs → esm}/data-structures/priority-queue/max-priority-queue.js +3 -0
  134. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -0
  135. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  136. package/dist/{mjs → esm}/data-structures/priority-queue/min-priority-queue.js +3 -0
  137. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -0
  138. package/dist/{mjs → esm}/data-structures/trie/trie.d.ts +0 -4
  139. package/dist/{mjs → esm}/data-structures/trie/trie.js +0 -4
  140. package/dist/esm/data-structures/trie/trie.js.map +1 -0
  141. package/dist/esm/interfaces/binary-tree.d.ts +9 -0
  142. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  143. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  144. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +1 -0
  145. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  146. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  147. package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  148. package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.d.ts +3 -3
  149. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.d.ts +2 -0
  150. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js +2 -0
  151. package/dist/{mjs → esm}/types/data-structures/binary-tree/index.js.map +1 -1
  152. package/dist/esm/types/data-structures/binary-tree/rb-tree.d.ts +3 -0
  153. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  154. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +2 -0
  155. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +1 -0
  156. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  157. package/dist/umd/data-structure-typed.js +1464 -895
  158. package/dist/umd/data-structure-typed.min.js +5 -5
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +14 -14
  161. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  162. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +155 -393
  163. package/src/data-structures/binary-tree/avl-tree.ts +144 -93
  164. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  165. package/src/data-structures/binary-tree/binary-tree.ts +433 -405
  166. package/src/data-structures/binary-tree/bst.ts +261 -239
  167. package/src/data-structures/binary-tree/index.ts +2 -0
  168. package/src/data-structures/binary-tree/red-black-tree.ts +163 -134
  169. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  170. package/src/data-structures/binary-tree/tree-multi-map.ts +161 -429
  171. package/src/data-structures/graph/directed-graph.ts +3 -0
  172. package/src/data-structures/graph/map-graph.ts +3 -0
  173. package/src/data-structures/graph/undirected-graph.ts +3 -0
  174. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  175. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  176. package/src/data-structures/matrix/matrix.ts +3 -0
  177. package/src/data-structures/matrix/navigator.ts +3 -0
  178. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  179. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  180. package/src/data-structures/trie/trie.ts +0 -4
  181. package/src/interfaces/binary-tree.ts +10 -24
  182. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  183. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  184. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  185. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  186. package/src/types/data-structures/binary-tree/bst.ts +5 -5
  187. package/src/types/data-structures/binary-tree/index.ts +2 -0
  188. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -6
  189. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  190. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -6
  191. package/test/integration/all-in-one.test.ts +1 -1
  192. package/test/integration/avl-tree.test.ts +1 -1
  193. package/test/integration/bst.test.ts +2 -2
  194. package/test/integration/compile.js +144 -0
  195. package/test/integration/compile.ts +171 -0
  196. package/test/integration/index.html +48 -48
  197. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
  198. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +5 -4
  199. package/test/performance/data-structures/comparison/comparison.test.ts +2 -2
  200. package/test/performance/reportor.ts +5 -3
  201. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +877 -0
  202. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +459 -761
  203. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +223 -223
  204. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +474 -492
  205. package/test/unit/data-structures/binary-tree/bst.test.ts +1 -1
  206. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -3
  207. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +87 -90
  208. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +975 -0
  209. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +729 -857
  210. package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
  211. package/{tsconfig-mjs.json → tsconfig-esm.json} +1 -1
  212. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  213. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -189
  214. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  215. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  216. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  217. package/dist/mjs/data-structures/binary-tree/bst.js.map +0 -1
  218. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  219. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  220. package/dist/mjs/data-structures/graph/directed-graph.js.map +0 -1
  221. package/dist/mjs/data-structures/graph/map-graph.js.map +0 -1
  222. package/dist/mjs/data-structures/graph/undirected-graph.js.map +0 -1
  223. package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  224. package/dist/mjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  225. package/dist/mjs/data-structures/matrix/matrix.js.map +0 -1
  226. package/dist/mjs/data-structures/matrix/navigator.js.map +0 -1
  227. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  228. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  229. package/dist/mjs/data-structures/trie/trie.js.map +0 -1
  230. package/dist/mjs/interfaces/binary-tree.d.ts +0 -9
  231. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -5
  232. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +0 -5
  233. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +0 -6
  234. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -5
  235. /package/dist/{mjs → esm}/common/index.d.ts +0 -0
  236. /package/dist/{mjs → esm}/common/index.js +0 -0
  237. /package/dist/{mjs → esm}/common/index.js.map +0 -0
  238. /package/dist/{mjs → esm}/data-structures/base/index.d.ts +0 -0
  239. /package/dist/{mjs → esm}/data-structures/base/index.js +0 -0
  240. /package/dist/{mjs → esm}/data-structures/base/index.js.map +0 -0
  241. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.d.ts +0 -0
  242. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js +0 -0
  243. /package/dist/{mjs → esm}/data-structures/base/iterable-element-base.js.map +0 -0
  244. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.d.ts +0 -0
  245. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js +0 -0
  246. /package/dist/{mjs → esm}/data-structures/base/iterable-entry-base.js.map +0 -0
  247. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  248. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js +0 -0
  249. /package/dist/{mjs → esm}/data-structures/binary-tree/segment-tree.js.map +0 -0
  250. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.d.ts +0 -0
  251. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js +0 -0
  252. /package/dist/{mjs → esm}/data-structures/graph/abstract-graph.js.map +0 -0
  253. /package/dist/{mjs → esm}/data-structures/graph/index.d.ts +0 -0
  254. /package/dist/{mjs → esm}/data-structures/graph/index.js +0 -0
  255. /package/dist/{mjs → esm}/data-structures/graph/index.js.map +0 -0
  256. /package/dist/{mjs → esm}/data-structures/hash/hash-map.d.ts +0 -0
  257. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js +0 -0
  258. /package/dist/{mjs → esm}/data-structures/hash/hash-map.js.map +0 -0
  259. /package/dist/{mjs → esm}/data-structures/hash/index.d.ts +0 -0
  260. /package/dist/{mjs → esm}/data-structures/hash/index.js +0 -0
  261. /package/dist/{mjs → esm}/data-structures/hash/index.js.map +0 -0
  262. /package/dist/{mjs → esm}/data-structures/heap/heap.d.ts +0 -0
  263. /package/dist/{mjs → esm}/data-structures/heap/heap.js +0 -0
  264. /package/dist/{mjs → esm}/data-structures/heap/heap.js.map +0 -0
  265. /package/dist/{mjs → esm}/data-structures/heap/index.d.ts +0 -0
  266. /package/dist/{mjs → esm}/data-structures/heap/index.js +0 -0
  267. /package/dist/{mjs → esm}/data-structures/heap/index.js.map +0 -0
  268. /package/dist/{mjs → esm}/data-structures/heap/max-heap.d.ts +0 -0
  269. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js +0 -0
  270. /package/dist/{mjs → esm}/data-structures/heap/max-heap.js.map +0 -0
  271. /package/dist/{mjs → esm}/data-structures/heap/min-heap.d.ts +0 -0
  272. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js +0 -0
  273. /package/dist/{mjs → esm}/data-structures/heap/min-heap.js.map +0 -0
  274. /package/dist/{mjs → esm}/data-structures/index.d.ts +0 -0
  275. /package/dist/{mjs → esm}/data-structures/index.js +0 -0
  276. /package/dist/{mjs → esm}/data-structures/index.js.map +0 -0
  277. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  278. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js +0 -0
  279. /package/dist/{mjs → esm}/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  280. /package/dist/{mjs → esm}/data-structures/linked-list/index.d.ts +0 -0
  281. /package/dist/{mjs → esm}/data-structures/linked-list/index.js +0 -0
  282. /package/dist/{mjs → esm}/data-structures/linked-list/index.js.map +0 -0
  283. /package/dist/{mjs → esm}/data-structures/matrix/index.d.ts +0 -0
  284. /package/dist/{mjs → esm}/data-structures/matrix/index.js +0 -0
  285. /package/dist/{mjs → esm}/data-structures/matrix/index.js.map +0 -0
  286. /package/dist/{mjs → esm}/data-structures/priority-queue/index.d.ts +0 -0
  287. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js +0 -0
  288. /package/dist/{mjs → esm}/data-structures/priority-queue/index.js.map +0 -0
  289. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  290. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js +0 -0
  291. /package/dist/{mjs → esm}/data-structures/priority-queue/priority-queue.js.map +0 -0
  292. /package/dist/{mjs → esm}/data-structures/queue/deque.d.ts +0 -0
  293. /package/dist/{mjs → esm}/data-structures/queue/deque.js +0 -0
  294. /package/dist/{mjs → esm}/data-structures/queue/deque.js.map +0 -0
  295. /package/dist/{mjs → esm}/data-structures/queue/index.d.ts +0 -0
  296. /package/dist/{mjs → esm}/data-structures/queue/index.js +0 -0
  297. /package/dist/{mjs → esm}/data-structures/queue/index.js.map +0 -0
  298. /package/dist/{mjs → esm}/data-structures/queue/queue.d.ts +0 -0
  299. /package/dist/{mjs → esm}/data-structures/queue/queue.js +0 -0
  300. /package/dist/{mjs → esm}/data-structures/queue/queue.js.map +0 -0
  301. /package/dist/{mjs → esm}/data-structures/stack/index.d.ts +0 -0
  302. /package/dist/{mjs → esm}/data-structures/stack/index.js +0 -0
  303. /package/dist/{mjs → esm}/data-structures/stack/index.js.map +0 -0
  304. /package/dist/{mjs → esm}/data-structures/stack/stack.d.ts +0 -0
  305. /package/dist/{mjs → esm}/data-structures/stack/stack.js +0 -0
  306. /package/dist/{mjs → esm}/data-structures/stack/stack.js.map +0 -0
  307. /package/dist/{mjs → esm}/data-structures/tree/index.d.ts +0 -0
  308. /package/dist/{mjs → esm}/data-structures/tree/index.js +0 -0
  309. /package/dist/{mjs → esm}/data-structures/tree/index.js.map +0 -0
  310. /package/dist/{mjs → esm}/data-structures/tree/tree.d.ts +0 -0
  311. /package/dist/{mjs → esm}/data-structures/tree/tree.js +0 -0
  312. /package/dist/{mjs → esm}/data-structures/tree/tree.js.map +0 -0
  313. /package/dist/{mjs → esm}/data-structures/trie/index.d.ts +0 -0
  314. /package/dist/{mjs → esm}/data-structures/trie/index.js +0 -0
  315. /package/dist/{mjs → esm}/data-structures/trie/index.js.map +0 -0
  316. /package/dist/{mjs → esm}/index.d.ts +0 -0
  317. /package/dist/{mjs → esm}/index.js +0 -0
  318. /package/dist/{mjs → esm}/index.js.map +0 -0
  319. /package/dist/{mjs → esm}/interfaces/binary-tree.js +0 -0
  320. /package/dist/{mjs → esm}/interfaces/binary-tree.js.map +0 -0
  321. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.d.ts +0 -0
  322. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js +0 -0
  323. /package/dist/{mjs → esm}/interfaces/doubly-linked-list.js.map +0 -0
  324. /package/dist/{mjs → esm}/interfaces/graph.d.ts +0 -0
  325. /package/dist/{mjs → esm}/interfaces/graph.js +0 -0
  326. /package/dist/{mjs → esm}/interfaces/graph.js.map +0 -0
  327. /package/dist/{mjs → esm}/interfaces/heap.d.ts +0 -0
  328. /package/dist/{mjs → esm}/interfaces/heap.js +0 -0
  329. /package/dist/{mjs → esm}/interfaces/heap.js.map +0 -0
  330. /package/dist/{mjs → esm}/interfaces/index.d.ts +0 -0
  331. /package/dist/{mjs → esm}/interfaces/index.js +0 -0
  332. /package/dist/{mjs → esm}/interfaces/index.js.map +0 -0
  333. /package/dist/{mjs → esm}/interfaces/navigator.d.ts +0 -0
  334. /package/dist/{mjs → esm}/interfaces/navigator.js +0 -0
  335. /package/dist/{mjs → esm}/interfaces/navigator.js.map +0 -0
  336. /package/dist/{mjs → esm}/interfaces/priority-queue.d.ts +0 -0
  337. /package/dist/{mjs → esm}/interfaces/priority-queue.js +0 -0
  338. /package/dist/{mjs → esm}/interfaces/priority-queue.js.map +0 -0
  339. /package/dist/{mjs → esm}/interfaces/segment-tree.d.ts +0 -0
  340. /package/dist/{mjs → esm}/interfaces/segment-tree.js +0 -0
  341. /package/dist/{mjs → esm}/interfaces/segment-tree.js.map +0 -0
  342. /package/dist/{mjs → esm}/interfaces/singly-linked-list.d.ts +0 -0
  343. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js +0 -0
  344. /package/dist/{mjs → esm}/interfaces/singly-linked-list.js.map +0 -0
  345. /package/dist/{mjs → esm}/types/common.d.ts +0 -0
  346. /package/dist/{mjs → esm}/types/common.js +0 -0
  347. /package/dist/{mjs → esm}/types/common.js.map +0 -0
  348. /package/dist/{mjs → esm}/types/data-structures/base/base.d.ts +0 -0
  349. /package/dist/{mjs → esm}/types/data-structures/base/base.js +0 -0
  350. /package/dist/{mjs → esm}/types/data-structures/base/base.js.map +0 -0
  351. /package/dist/{mjs → esm}/types/data-structures/base/index.d.ts +0 -0
  352. /package/dist/{mjs → esm}/types/data-structures/base/index.js +0 -0
  353. /package/dist/{mjs → esm}/types/data-structures/base/index.js.map +0 -0
  354. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -0
  355. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -0
  356. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js +0 -0
  357. /package/dist/{mjs → esm}/types/data-structures/binary-tree/avl-tree.js.map +0 -0
  358. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  359. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js +0 -0
  360. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -0
  361. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js +0 -0
  362. /package/dist/{mjs → esm}/types/data-structures/binary-tree/binary-tree.js.map +0 -0
  363. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js +0 -0
  364. /package/dist/{mjs → esm}/types/data-structures/binary-tree/bst.js.map +0 -0
  365. /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js +0 -0
  366. /package/dist/{mjs → esm}/types/data-structures/binary-tree/rb-tree.js.map +0 -0
  367. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  368. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js +0 -0
  369. /package/dist/{mjs → esm}/types/data-structures/binary-tree/segment-tree.js.map +0 -0
  370. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js +0 -0
  371. /package/dist/{mjs → esm}/types/data-structures/binary-tree/tree-multi-map.js.map +0 -0
  372. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  373. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js +0 -0
  374. /package/dist/{mjs → esm}/types/data-structures/graph/abstract-graph.js.map +0 -0
  375. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.d.ts +0 -0
  376. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js +0 -0
  377. /package/dist/{mjs → esm}/types/data-structures/graph/directed-graph.js.map +0 -0
  378. /package/dist/{mjs → esm}/types/data-structures/graph/index.d.ts +0 -0
  379. /package/dist/{mjs → esm}/types/data-structures/graph/index.js +0 -0
  380. /package/dist/{mjs → esm}/types/data-structures/graph/index.js.map +0 -0
  381. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.d.ts +0 -0
  382. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js +0 -0
  383. /package/dist/{mjs → esm}/types/data-structures/graph/map-graph.js.map +0 -0
  384. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  385. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js +0 -0
  386. /package/dist/{mjs → esm}/types/data-structures/graph/undirected-graph.js.map +0 -0
  387. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.d.ts +0 -0
  388. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js +0 -0
  389. /package/dist/{mjs → esm}/types/data-structures/hash/hash-map.js.map +0 -0
  390. /package/dist/{mjs → esm}/types/data-structures/hash/index.d.ts +0 -0
  391. /package/dist/{mjs → esm}/types/data-structures/hash/index.js +0 -0
  392. /package/dist/{mjs → esm}/types/data-structures/hash/index.js.map +0 -0
  393. /package/dist/{mjs → esm}/types/data-structures/heap/heap.d.ts +0 -0
  394. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js +0 -0
  395. /package/dist/{mjs → esm}/types/data-structures/heap/heap.js.map +0 -0
  396. /package/dist/{mjs → esm}/types/data-structures/heap/index.d.ts +0 -0
  397. /package/dist/{mjs → esm}/types/data-structures/heap/index.js +0 -0
  398. /package/dist/{mjs → esm}/types/data-structures/heap/index.js.map +0 -0
  399. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.d.ts +0 -0
  400. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js +0 -0
  401. /package/dist/{mjs → esm}/types/data-structures/heap/max-heap.js.map +0 -0
  402. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.d.ts +0 -0
  403. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js +0 -0
  404. /package/dist/{mjs → esm}/types/data-structures/heap/min-heap.js.map +0 -0
  405. /package/dist/{mjs → esm}/types/data-structures/index.d.ts +0 -0
  406. /package/dist/{mjs → esm}/types/data-structures/index.js +0 -0
  407. /package/dist/{mjs → esm}/types/data-structures/index.js.map +0 -0
  408. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  409. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js +0 -0
  410. /package/dist/{mjs → esm}/types/data-structures/linked-list/doubly-linked-list.js.map +0 -0
  411. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.d.ts +0 -0
  412. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js +0 -0
  413. /package/dist/{mjs → esm}/types/data-structures/linked-list/index.js.map +0 -0
  414. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  415. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js +0 -0
  416. /package/dist/{mjs → esm}/types/data-structures/linked-list/singly-linked-list.js.map +0 -0
  417. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  418. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js +0 -0
  419. /package/dist/{mjs → esm}/types/data-structures/linked-list/skip-linked-list.js.map +0 -0
  420. /package/dist/{mjs → esm}/types/data-structures/matrix/index.d.ts +0 -0
  421. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js +0 -0
  422. /package/dist/{mjs → esm}/types/data-structures/matrix/index.js.map +0 -0
  423. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.d.ts +0 -0
  424. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js +0 -0
  425. /package/dist/{mjs → esm}/types/data-structures/matrix/matrix.js.map +0 -0
  426. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.d.ts +0 -0
  427. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js +0 -0
  428. /package/dist/{mjs → esm}/types/data-structures/matrix/navigator.js.map +0 -0
  429. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.d.ts +0 -0
  430. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js +0 -0
  431. /package/dist/{mjs → esm}/types/data-structures/priority-queue/index.js.map +0 -0
  432. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  433. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js +0 -0
  434. /package/dist/{mjs → esm}/types/data-structures/priority-queue/max-priority-queue.js.map +0 -0
  435. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  436. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js +0 -0
  437. /package/dist/{mjs → esm}/types/data-structures/priority-queue/min-priority-queue.js.map +0 -0
  438. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  439. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js +0 -0
  440. /package/dist/{mjs → esm}/types/data-structures/priority-queue/priority-queue.js.map +0 -0
  441. /package/dist/{mjs → esm}/types/data-structures/queue/deque.d.ts +0 -0
  442. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js +0 -0
  443. /package/dist/{mjs → esm}/types/data-structures/queue/deque.js.map +0 -0
  444. /package/dist/{mjs → esm}/types/data-structures/queue/index.d.ts +0 -0
  445. /package/dist/{mjs → esm}/types/data-structures/queue/index.js +0 -0
  446. /package/dist/{mjs → esm}/types/data-structures/queue/index.js.map +0 -0
  447. /package/dist/{mjs → esm}/types/data-structures/queue/queue.d.ts +0 -0
  448. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js +0 -0
  449. /package/dist/{mjs → esm}/types/data-structures/queue/queue.js.map +0 -0
  450. /package/dist/{mjs → esm}/types/data-structures/stack/index.d.ts +0 -0
  451. /package/dist/{mjs → esm}/types/data-structures/stack/index.js +0 -0
  452. /package/dist/{mjs → esm}/types/data-structures/stack/index.js.map +0 -0
  453. /package/dist/{mjs → esm}/types/data-structures/stack/stack.d.ts +0 -0
  454. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js +0 -0
  455. /package/dist/{mjs → esm}/types/data-structures/stack/stack.js.map +0 -0
  456. /package/dist/{mjs → esm}/types/data-structures/tree/index.d.ts +0 -0
  457. /package/dist/{mjs → esm}/types/data-structures/tree/index.js +0 -0
  458. /package/dist/{mjs → esm}/types/data-structures/tree/index.js.map +0 -0
  459. /package/dist/{mjs → esm}/types/data-structures/tree/tree.d.ts +0 -0
  460. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js +0 -0
  461. /package/dist/{mjs → esm}/types/data-structures/tree/tree.js.map +0 -0
  462. /package/dist/{mjs → esm}/types/data-structures/trie/index.d.ts +0 -0
  463. /package/dist/{mjs → esm}/types/data-structures/trie/index.js +0 -0
  464. /package/dist/{mjs → esm}/types/data-structures/trie/index.js.map +0 -0
  465. /package/dist/{mjs → esm}/types/data-structures/trie/trie.d.ts +0 -0
  466. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js +0 -0
  467. /package/dist/{mjs → esm}/types/data-structures/trie/trie.js.map +0 -0
  468. /package/dist/{mjs → esm}/types/index.d.ts +0 -0
  469. /package/dist/{mjs → esm}/types/index.js +0 -0
  470. /package/dist/{mjs → esm}/types/index.js.map +0 -0
  471. /package/dist/{mjs → esm}/types/utils/index.d.ts +0 -0
  472. /package/dist/{mjs → esm}/types/utils/index.js +0 -0
  473. /package/dist/{mjs → esm}/types/utils/index.js.map +0 -0
  474. /package/dist/{mjs → esm}/types/utils/utils.d.ts +0 -0
  475. /package/dist/{mjs → esm}/types/utils/utils.js +0 -0
  476. /package/dist/{mjs → esm}/types/utils/utils.js.map +0 -0
  477. /package/dist/{mjs → esm}/types/utils/validate-type.d.ts +0 -0
  478. /package/dist/{mjs → esm}/types/utils/validate-type.js +0 -0
  479. /package/dist/{mjs → esm}/types/utils/validate-type.js.map +0 -0
  480. /package/dist/{mjs → esm}/utils/index.d.ts +0 -0
  481. /package/dist/{mjs → esm}/utils/index.js +0 -0
  482. /package/dist/{mjs → esm}/utils/index.js.map +0 -0
  483. /package/dist/{mjs → esm}/utils/number.d.ts +0 -0
  484. /package/dist/{mjs → esm}/utils/number.js +0 -0
  485. /package/dist/{mjs → esm}/utils/number.js.map +0 -0
  486. /package/dist/{mjs → esm}/utils/utils.d.ts +0 -0
  487. /package/dist/{mjs → esm}/utils/utils.js +0 -0
  488. /package/dist/{mjs → esm}/utils/utils.js.map +0 -0
@@ -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,34 +125,58 @@ 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
  }
135
+ _comparator = (a, b) => {
136
+ if (isComparable(a) && isComparable(b)) {
137
+ if (a > b)
138
+ return 1;
139
+ if (a < b)
140
+ return -1;
141
+ return 0;
142
+ }
143
+ if (this._specifyComparable) {
144
+ if (this._specifyComparable(a) > this._specifyComparable(b))
145
+ return 1;
146
+ if (this._specifyComparable(a) < this._specifyComparable(b))
147
+ return -1;
148
+ return 0;
149
+ }
150
+ if (typeof a === 'object' || typeof b === 'object') {
151
+ throw TypeError(`When comparing object types, a custom specifyComparable must be defined in the constructor's options parameter.`);
152
+ }
153
+ return 0;
154
+ };
155
+ get comparator() {
156
+ return this._comparator;
157
+ }
158
+ _specifyComparable;
159
+ get specifyComparable() {
160
+ return this._specifyComparable;
161
+ }
156
162
  /**
163
+ * Time Complexity: O(1)
164
+ * Space Complexity: O(1)
165
+ *
157
166
  * The function creates a new BSTNode with the given key and value and returns it.
158
167
  * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
159
168
  * being created.
160
169
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
161
170
  * value associated with the key in the node being created.
162
- * @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.
163
172
  */
164
173
  createNode(key, value) {
165
174
  return new BSTNode(key, this._isMapMode ? undefined : value);
166
175
  }
167
176
  /**
177
+ * Time Complexity: O(1)
178
+ * Space Complexity: O(1)
179
+ *
168
180
  * The function creates a new binary search tree with the specified options.
169
181
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
170
182
  * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
@@ -181,29 +193,14 @@ export class BST extends BinaryTree {
181
193
  ...options
182
194
  });
183
195
  }
184
- /**
185
- * The function overrides a method and converts a key, value pair or entry or raw element to a node.
186
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
187
- * type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
188
- * element.
189
- * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
190
- * value associated with a key in a key-value pair.
191
- * @returns either a NODE object or undefined.
192
- */
193
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
194
- const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
195
- if (node === null)
196
- return [undefined, undefined];
197
- return [node, value ?? entryValue];
198
- }
199
196
  /**
200
197
  * Time Complexity: O(log n)
201
198
  * Space Complexity: O(log n)
202
199
  *
203
200
  * The function ensures the existence of a node in a data structure and returns it, or undefined if
204
201
  * it doesn't exist.
205
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
206
- * `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,
207
204
  * entry, or raw element that needs to be ensured in the tree.
208
205
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
209
206
  * parameter that specifies the type of iteration to be used when ensuring a node. It has a default
@@ -211,43 +208,49 @@ export class BST extends BinaryTree {
211
208
  * @returns The method is returning either the node that was ensured or `undefined` if the node could
212
209
  * not be ensured.
213
210
  */
214
- ensureNode(keyNodeEntryOrRaw, iterationType = this.iterationType) {
215
- return super.ensureNode(keyNodeEntryOrRaw, iterationType) ?? undefined;
211
+ ensureNode(keyNodeOrEntry, iterationType = this.iterationType) {
212
+ return super.ensureNode(keyNodeOrEntry, iterationType) ?? undefined;
216
213
  }
217
214
  /**
215
+ * Time Complexity: O(1)
216
+ * Space Complexity: O(1)
217
+ *
218
218
  * The function checks if the input is an instance of the BSTNode class.
219
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
220
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
221
- * @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
222
222
  * an instance of the `BSTNode` class.
223
223
  */
224
- isNode(keyNodeEntryOrRaw) {
225
- return keyNodeEntryOrRaw instanceof BSTNode;
224
+ isNode(keyNodeOrEntry) {
225
+ return keyNodeOrEntry instanceof BSTNode;
226
226
  }
227
227
  /**
228
- * 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.
229
232
  * @param {any} key - The `key` parameter is a value that will be checked to determine if it is of
230
233
  * type `K`.
231
- * @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
232
235
  * the result of the `isComparable` function with the condition `this._compare !==
233
236
  * this._DEFAULT_COMPARATOR`.
234
237
  */
235
- isKey(key) {
238
+ isValidKey(key) {
236
239
  return isComparable(key, this._specifyComparable !== undefined);
237
240
  }
238
241
  /**
239
242
  * Time Complexity: O(log n)
240
- * Space Complexity: O(1)
243
+ * Space Complexity: O(log n)
241
244
  *
242
245
  * The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
243
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
244
- * `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>>`.
245
248
  * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
246
249
  * key in the binary search tree. If provided, it will be stored in the node along with the key.
247
250
  * @returns a boolean value.
248
251
  */
249
- add(keyNodeEntryOrRaw, value) {
250
- const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
252
+ add(keyNodeOrEntry, value) {
253
+ const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
251
254
  if (newNode === undefined)
252
255
  return false;
253
256
  if (this._root === undefined) {
@@ -318,8 +321,10 @@ export class BST extends BinaryTree {
318
321
  valuesIterator = values[Symbol.iterator]();
319
322
  }
320
323
  if (!isBalanceAdd) {
321
- for (const kve of keysNodesEntriesOrRaws) {
324
+ for (let kve of keysNodesEntriesOrRaws) {
322
325
  const value = valuesIterator?.next().value;
326
+ if (this.isRaw(kve))
327
+ kve = this._toEntryFn(kve);
323
328
  inserted.push(this.add(kve, value));
324
329
  }
325
330
  return inserted;
@@ -333,23 +338,21 @@ export class BST extends BinaryTree {
333
338
  let sorted = [];
334
339
  sorted = realBTNExemplars.sort(({ key: a }, { key: b }) => {
335
340
  let keyA, keyB;
336
- if (this.isEntry(a))
341
+ if (this.isRaw(a))
342
+ keyA = this._toEntryFn(a)[0];
343
+ else if (this.isEntry(a))
337
344
  keyA = a[0];
338
345
  else if (this.isRealNode(a))
339
346
  keyA = a.key;
340
- else if (this._toEntryFn) {
341
- keyA = this._toEntryFn(a)[0];
342
- }
343
347
  else {
344
348
  keyA = a;
345
349
  }
346
- if (this.isEntry(b))
350
+ if (this.isRaw(b))
351
+ keyB = this._toEntryFn(b)[0];
352
+ else if (this.isEntry(b))
347
353
  keyB = b[0];
348
354
  else if (this.isRealNode(b))
349
355
  keyB = b.key;
350
- else if (this._toEntryFn) {
351
- keyB = this._toEntryFn(b)[0];
352
- }
353
356
  else {
354
357
  keyB = b;
355
358
  }
@@ -362,7 +365,13 @@ export class BST extends BinaryTree {
362
365
  if (arr.length === 0)
363
366
  return;
364
367
  const mid = Math.floor((arr.length - 1) / 2);
365
- 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
+ }
366
375
  inserted[orgIndex] = this.add(key, value);
367
376
  _dfs(arr.slice(0, mid));
368
377
  _dfs(arr.slice(mid + 1));
@@ -376,7 +385,13 @@ export class BST extends BinaryTree {
376
385
  const [l, r] = popped;
377
386
  if (l <= r) {
378
387
  const m = l + Math.floor((r - l) / 2);
379
- 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
+ }
380
395
  inserted[orgIndex] = this.add(key, value);
381
396
  stack.push([m + 1, r]);
382
397
  stack.push([l, m - 1]);
@@ -398,17 +413,17 @@ export class BST extends BinaryTree {
398
413
  *
399
414
  * The function `search` in TypeScript overrides the search behavior in a binary tree structure based
400
415
  * on specified criteria.
401
- * @param {BTNRep<K, V, NODE> | R | NodePredicate<NODE>} keyNodeEntryRawOrPredicate - The
402
- * `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
403
418
  * following types:
404
419
  * @param [onlyOne=false] - The `onlyOne` parameter is a boolean flag that determines whether the
405
420
  * search should stop after finding the first matching node. If `onlyOne` is set to `true`, the
406
421
  * search will return as soon as a matching node is found. If `onlyOne` is set to `false`, the
407
422
  * @param {C} callback - The `callback` parameter in the `override search` function is a function
408
423
  * that will be called on each node that matches the search criteria. It is of type `C`, which
409
- * 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
410
425
  * argument and
411
- * @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`
412
427
  * method represents the node from which the search operation will begin. It is the starting point
413
428
  * for searching within the tree data structure. The method ensures that the `startNode` is a valid
414
429
  * node before proceeding with the search operation. If the `
@@ -420,26 +435,26 @@ export class BST extends BinaryTree {
420
435
  * structure based on the provided key, predicate, and other options. The search results are
421
436
  * collected in an array and returned as the output of the method.
422
437
  */
423
- search(keyNodeEntryRawOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
424
- if (keyNodeEntryRawOrPredicate === undefined)
438
+ search(keyNodeEntryOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
439
+ if (keyNodeEntryOrPredicate === undefined)
425
440
  return [];
426
- if (keyNodeEntryRawOrPredicate === null)
441
+ if (keyNodeEntryOrPredicate === null)
427
442
  return [];
428
443
  startNode = this.ensureNode(startNode);
429
444
  if (!startNode)
430
445
  return [];
431
446
  let predicate;
432
- const isRange = this.isRange(keyNodeEntryRawOrPredicate);
447
+ const isRange = this.isRange(keyNodeEntryOrPredicate);
433
448
  // Set predicate based on parameter type
434
449
  if (isRange) {
435
- predicate = node => keyNodeEntryRawOrPredicate.isInRange(node.key, this._comparator);
450
+ predicate = node => keyNodeEntryOrPredicate.isInRange(node.key, this._comparator);
436
451
  }
437
452
  else {
438
- predicate = this._ensurePredicate(keyNodeEntryRawOrPredicate);
453
+ predicate = this._ensurePredicate(keyNodeEntryOrPredicate);
439
454
  }
440
455
  const isToLeftByRange = (cur) => {
441
456
  if (isRange) {
442
- const range = keyNodeEntryRawOrPredicate;
457
+ const range = keyNodeEntryOrPredicate;
443
458
  const leftS = this.isReverse ? range.high : range.low;
444
459
  const leftI = this.isReverse ? range.includeHigh : range.includeLow;
445
460
  return (leftI && this._compare(cur.key, leftS) >= 0) || (!leftI && this._compare(cur.key, leftS) > 0);
@@ -448,7 +463,7 @@ export class BST extends BinaryTree {
448
463
  };
449
464
  const isToRightByRange = (cur) => {
450
465
  if (isRange) {
451
- const range = keyNodeEntryRawOrPredicate;
466
+ const range = keyNodeEntryOrPredicate;
452
467
  const rightS = this.isReverse ? range.low : range.high;
453
468
  const rightI = this.isReverse ? range.includeLow : range.includeLow;
454
469
  return (rightI && this._compare(cur.key, rightS) <= 0) || (!rightI && this._compare(cur.key, rightS) < 0);
@@ -471,8 +486,8 @@ export class BST extends BinaryTree {
471
486
  if (this.isRealNode(cur.right) && isToRightByRange(cur))
472
487
  dfs(cur.right);
473
488
  }
474
- else if (!this._isPredicate(keyNodeEntryRawOrPredicate)) {
475
- const benchmarkKey = this._extractKey(keyNodeEntryRawOrPredicate);
489
+ else if (!this._isPredicate(keyNodeEntryOrPredicate)) {
490
+ const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
476
491
  if (this.isRealNode(cur.left) &&
477
492
  benchmarkKey !== null &&
478
493
  benchmarkKey !== undefined &&
@@ -508,8 +523,8 @@ export class BST extends BinaryTree {
508
523
  if (this.isRealNode(cur.right) && isToRightByRange(cur))
509
524
  stack.push(cur.right);
510
525
  }
511
- else if (!this._isPredicate(keyNodeEntryRawOrPredicate)) {
512
- const benchmarkKey = this._extractKey(keyNodeEntryRawOrPredicate);
526
+ else if (!this._isPredicate(keyNodeEntryOrPredicate)) {
527
+ const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
513
528
  if (this.isRealNode(cur.right) &&
514
529
  benchmarkKey !== null &&
515
530
  benchmarkKey !== undefined &&
@@ -533,16 +548,16 @@ export class BST extends BinaryTree {
533
548
  }
534
549
  /**
535
550
  * Time Complexity: O(log n)
536
- * Space Complexity: O(n)
551
+ * Space Complexity: O(k + log n)
537
552
  *
538
553
  * The `rangeSearch` function searches for nodes within a specified range in a binary search tree.
539
554
  * @param {Range<K> | [K, K]} range - The `range` parameter in the `rangeSearch` function can be
540
555
  * either a `Range` object or an array of two elements representing the range boundaries.
541
556
  * @param {C} callback - The `callback` parameter in the `rangeSearch` function is a callback
542
557
  * function that is used to process each node that is found within the specified range during the
543
- * 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
544
559
  * data structure.
545
- * @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`
546
561
  * function represents the node from which the search for nodes within the specified range will
547
562
  * begin. It is the starting point for the range search operation.
548
563
  * @param {IterationType} iterationType - The `iterationType` parameter in the `rangeSearch` function
@@ -558,12 +573,12 @@ export class BST extends BinaryTree {
558
573
  }
559
574
  /**
560
575
  * Time Complexity: O(log n)
561
- * Space Complexity: O(1)
576
+ * Space Complexity: O(log n)
562
577
  *
563
- * This function retrieves a node based on a given keyNodeEntryRawOrPredicate within a binary search tree structure.
564
- * @param {BTNRep<K, V, NODE> | R | NodePredicate<NODE>} keyNodeEntryRawOrPredicate - The `keyNodeEntryRawOrPredicate`
565
- * parameter can be of type `BTNRep<K, V, NODE>`, `R`, or `NodePredicate<NODE>`.
566
- * @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
567
582
  * is used to specify the starting point for searching nodes in the binary search tree. If no
568
583
  * specific starting point is provided, the default value is set to `this._root`, which is the root
569
584
  * node of the binary search tree.
@@ -571,13 +586,13 @@ export class BST extends BinaryTree {
571
586
  * parameter that specifies the type of iteration to be used. It has a default value of
572
587
  * `this.iterationType`, which means it will use the iteration type defined in the class instance if
573
588
  * no value is provided when calling the method.
574
- * @returns The `getNode` method is returning an optional binary search tree node (`OptNode<NODE>`).
575
- * 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
576
591
  * the specified root node (`startNode`) and using the specified iteration type. The method then
577
592
  * returns the first node found or `undefined` if no node is found.
578
593
  */
579
- getNode(keyNodeEntryRawOrPredicate, startNode = this._root, iterationType = this.iterationType) {
580
- 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;
581
596
  }
582
597
  /**
583
598
  * Time complexity: O(n)
@@ -591,7 +606,7 @@ export class BST extends BinaryTree {
591
606
  * @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
592
607
  * order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
593
608
  * take one of the following values:
594
- * @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
595
610
  * point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
596
611
  * node entry. If not specified, the default value is the root of the tree.
597
612
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
@@ -611,7 +626,7 @@ export class BST extends BinaryTree {
611
626
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
612
627
  * visited during the breadth-first search. It should take a single argument, which is the current
613
628
  * node being visited, and it can return a value of any type.
614
- * @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
615
630
  * point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
616
631
  * object. If no value is provided, the default value is the root of the tree.
617
632
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -629,9 +644,9 @@ export class BST extends BinaryTree {
629
644
  * The function overrides the listLevels method from the superclass and returns an array of arrays
630
645
  * containing the results of the callback function applied to each level of the tree.
631
646
  * @param {C} callback - The `callback` parameter is a generic type `C` that extends
632
- * `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
633
648
  * tree during the iteration process.
634
- * @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
635
650
  * point for listing the levels of the binary tree. It can be either a root node of the tree, a
636
651
  * key-value pair representing a node in the tree, or a key representing a node in the tree. If no
637
652
  * value is provided, the root of
@@ -655,7 +670,7 @@ export class BST extends BinaryTree {
655
670
  * @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
656
671
  * traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
657
672
  * 0, or 1, where:
658
- * @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
659
674
  * the binary tree that you want to start traversing from. It can be specified either by providing
660
675
  * the key of the node, the node itself, or an entry containing the key and value of the node. If no
661
676
  * `targetNode` is provided,
@@ -815,46 +830,71 @@ export class BST extends BinaryTree {
815
830
  }
816
831
  return balanced;
817
832
  }
818
- _comparator = (a, b) => {
819
- if (isComparable(a) && isComparable(b)) {
820
- if (a > b)
821
- return 1;
822
- if (a < b)
823
- return -1;
824
- return 0;
825
- }
826
- if (this._specifyComparable) {
827
- if (this._specifyComparable(a) > this._specifyComparable(b))
828
- return 1;
829
- if (this._specifyComparable(a) < this._specifyComparable(b))
830
- return -1;
831
- return 0;
832
- }
833
- if (typeof a === 'object' || typeof b === 'object') {
834
- throw TypeError(`When comparing object types, a custom specifyComparable must be defined in the constructor's options parameter.`);
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
+ */
852
+ map(callback, options, thisArg) {
853
+ const newTree = new BST([], options);
854
+ let index = 0;
855
+ for (const [key, value] of this) {
856
+ newTree.add(callback.call(thisArg, key, value, index++, this));
835
857
  }
836
- return 0;
837
- };
858
+ return newTree;
859
+ }
838
860
  /**
839
- * The function returns the value of the _comparator property.
840
- * @returns The `_comparator` property is being returned.
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.
841
867
  */
842
- get comparator() {
843
- return this._comparator;
868
+ clone() {
869
+ const cloned = this.createTree();
870
+ this._clone(cloned);
871
+ return cloned;
844
872
  }
845
- _specifyComparable;
846
873
  /**
847
- * This function returns the value of the `_specifyComparable` property.
848
- * @returns The method `specifyComparable()` is being returned, which is a getter method for the
849
- * `_specifyComparable` property.
874
+ * Time Complexity: O(1)
875
+ * Space Complexity: O(1)
876
+ *
877
+ * The function overrides a method and converts a key, value pair or entry or raw element to a node.
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
880
+ * element.
881
+ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
882
+ * value associated with a key in a key-value pair.
883
+ * @returns either a BSTNode<K, V> object or undefined.
850
884
  */
851
- get specifyComparable() {
852
- return this._specifyComparable;
885
+ _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value) {
886
+ const [node, entryValue] = super._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
887
+ if (node === null)
888
+ return [undefined, undefined];
889
+ return [node, value ?? entryValue];
853
890
  }
854
891
  /**
892
+ * Time Complexity: O(1)
893
+ * Space Complexity: O(1)
894
+ *
855
895
  * The function sets the root of a tree-like structure and updates the parent property of the new
856
896
  * root.
857
- * @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.
858
898
  */
859
899
  _setRoot(v) {
860
900
  if (v) {
@@ -862,16 +902,22 @@ export class BST extends BinaryTree {
862
902
  }
863
903
  this._root = v;
864
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
+ */
865
919
  _compare(a, b) {
866
920
  return this._isReverse ? -this._comparator(a, b) : this._comparator(a, b);
867
921
  }
868
- map(callback, options, thisArg) {
869
- const newTree = new BST([], options);
870
- let index = 0;
871
- for (const [key, value] of this) {
872
- newTree.add(callback.call(thisArg, key, value, index++, this));
873
- }
874
- return newTree;
875
- }
876
922
  }
877
923
  //# sourceMappingURL=bst.js.map