data-structure-typed 2.1.0 → 2.1.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 (704) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/COMMANDS.md +13 -3
  3. package/README.md +5 -34
  4. package/benchmark/report.html +1 -1
  5. package/benchmark/report.json +101 -101
  6. package/dist/cjs/index.cjs +13062 -0
  7. package/dist/cjs/index.cjs.map +1 -0
  8. package/dist/esm/index.mjs +12984 -0
  9. package/dist/esm/index.mjs.map +1 -0
  10. package/dist/index.cjs +13091 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.js +13013 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/{cjs → types}/data-structures/binary-tree/avl-tree-counter.d.ts +4 -4
  15. package/dist/{esm → types}/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
  16. package/dist/{esm → types}/data-structures/binary-tree/avl-tree.d.ts +4 -4
  17. package/dist/{esm → types}/data-structures/binary-tree/binary-tree.d.ts +5 -5
  18. package/dist/{esm → types}/data-structures/binary-tree/bst.d.ts +5 -5
  19. package/dist/{esm → types}/data-structures/binary-tree/red-black-tree.d.ts +5 -5
  20. package/dist/{cjs → types}/data-structures/binary-tree/tree-counter.d.ts +4 -4
  21. package/dist/{cjs → types}/data-structures/binary-tree/tree-multi-map.d.ts +5 -5
  22. package/dist/{esm → types}/interfaces/binary-tree.d.ts +2 -2
  23. package/dist/umd/data-structure-typed.js +12 -11
  24. package/dist/umd/data-structure-typed.js.map +1 -0
  25. package/dist/umd/data-structure-typed.min.js +2 -2
  26. package/dist/umd/data-structure-typed.min.js.map +1 -1
  27. package/jest.integration.config.js +3 -0
  28. package/package.json +13 -11
  29. package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -7
  30. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +5 -10
  31. package/src/data-structures/binary-tree/avl-tree.ts +4 -6
  32. package/src/data-structures/binary-tree/binary-tree.ts +14 -16
  33. package/src/data-structures/binary-tree/bst.ts +5 -10
  34. package/src/data-structures/binary-tree/red-black-tree.ts +5 -10
  35. package/src/data-structures/binary-tree/tree-counter.ts +4 -9
  36. package/src/data-structures/binary-tree/tree-multi-map.ts +5 -10
  37. package/src/interfaces/binary-tree.ts +2 -2
  38. package/test/integration/all-in-one.test.ts +1 -1
  39. package/test/performance/data-structures/comparison/comparison.test.ts +27 -57
  40. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +109 -1
  41. package/tsconfig-base.json +20 -20
  42. package/tsconfig-types.json +17 -0
  43. package/tsconfig.test.json +8 -0
  44. package/tsup.config.js +11 -22
  45. package/tsup.node.config.ts +37 -0
  46. package/dist/cjs/common/index.js +0 -29
  47. package/dist/cjs/common/index.js.map +0 -1
  48. package/dist/cjs/data-structures/base/index.js +0 -19
  49. package/dist/cjs/data-structures/base/index.js.map +0 -1
  50. package/dist/cjs/data-structures/base/iterable-element-base.js +0 -244
  51. package/dist/cjs/data-structures/base/iterable-element-base.js.map +0 -1
  52. package/dist/cjs/data-structures/base/iterable-entry-base.js +0 -184
  53. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +0 -1
  54. package/dist/cjs/data-structures/base/linear-base.js +0 -416
  55. package/dist/cjs/data-structures/base/linear-base.js.map +0 -1
  56. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +0 -375
  57. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  58. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  59. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +0 -251
  60. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  61. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -291
  62. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -612
  63. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +0 -1
  64. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +0 -295
  65. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  66. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +0 -754
  67. package/dist/cjs/data-structures/binary-tree/binary-tree.js +0 -1926
  68. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +0 -1
  69. package/dist/cjs/data-structures/binary-tree/bst.d.ts +0 -413
  70. package/dist/cjs/data-structures/binary-tree/bst.js +0 -904
  71. package/dist/cjs/data-structures/binary-tree/bst.js.map +0 -1
  72. package/dist/cjs/data-structures/binary-tree/index.js +0 -27
  73. package/dist/cjs/data-structures/binary-tree/index.js.map +0 -1
  74. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  75. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +0 -547
  76. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +0 -1
  77. package/dist/cjs/data-structures/binary-tree/segment-tree.js +0 -298
  78. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +0 -1
  79. package/dist/cjs/data-structures/binary-tree/tree-counter.js +0 -414
  80. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +0 -1
  81. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +0 -385
  82. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  83. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -897
  84. package/dist/cjs/data-structures/graph/abstract-graph.js.map +0 -1
  85. package/dist/cjs/data-structures/graph/directed-graph.js +0 -526
  86. package/dist/cjs/data-structures/graph/directed-graph.js.map +0 -1
  87. package/dist/cjs/data-structures/graph/index.js +0 -21
  88. package/dist/cjs/data-structures/graph/index.js.map +0 -1
  89. package/dist/cjs/data-structures/graph/map-graph.js +0 -108
  90. package/dist/cjs/data-structures/graph/map-graph.js.map +0 -1
  91. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -425
  92. package/dist/cjs/data-structures/graph/undirected-graph.js.map +0 -1
  93. package/dist/cjs/data-structures/hash/hash-map.js +0 -693
  94. package/dist/cjs/data-structures/hash/hash-map.js.map +0 -1
  95. package/dist/cjs/data-structures/hash/index.js +0 -18
  96. package/dist/cjs/data-structures/hash/index.js.map +0 -1
  97. package/dist/cjs/data-structures/heap/heap.js +0 -902
  98. package/dist/cjs/data-structures/heap/heap.js.map +0 -1
  99. package/dist/cjs/data-structures/heap/index.js +0 -20
  100. package/dist/cjs/data-structures/heap/index.js.map +0 -1
  101. package/dist/cjs/data-structures/heap/max-heap.js +0 -41
  102. package/dist/cjs/data-structures/heap/max-heap.js.map +0 -1
  103. package/dist/cjs/data-structures/heap/min-heap.js +0 -32
  104. package/dist/cjs/data-structures/heap/min-heap.js.map +0 -1
  105. package/dist/cjs/data-structures/index.js +0 -29
  106. package/dist/cjs/data-structures/index.js.map +0 -1
  107. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +0 -1112
  108. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  109. package/dist/cjs/data-structures/linked-list/index.js +0 -20
  110. package/dist/cjs/data-structures/linked-list/index.js.map +0 -1
  111. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -851
  112. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +0 -1
  113. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +0 -145
  114. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +0 -1
  115. package/dist/cjs/data-structures/matrix/index.js +0 -19
  116. package/dist/cjs/data-structures/matrix/index.js.map +0 -1
  117. package/dist/cjs/data-structures/matrix/matrix.js +0 -449
  118. package/dist/cjs/data-structures/matrix/matrix.js.map +0 -1
  119. package/dist/cjs/data-structures/matrix/navigator.js +0 -112
  120. package/dist/cjs/data-structures/matrix/navigator.js.map +0 -1
  121. package/dist/cjs/data-structures/priority-queue/index.js +0 -20
  122. package/dist/cjs/data-structures/priority-queue/index.js.map +0 -1
  123. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -35
  124. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  125. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -25
  126. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  127. package/dist/cjs/data-structures/priority-queue/priority-queue.js +0 -21
  128. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +0 -1
  129. package/dist/cjs/data-structures/queue/deque.js +0 -880
  130. package/dist/cjs/data-structures/queue/deque.js.map +0 -1
  131. package/dist/cjs/data-structures/queue/index.js +0 -19
  132. package/dist/cjs/data-structures/queue/index.js.map +0 -1
  133. package/dist/cjs/data-structures/queue/queue.js +0 -474
  134. package/dist/cjs/data-structures/queue/queue.js.map +0 -1
  135. package/dist/cjs/data-structures/stack/index.js +0 -18
  136. package/dist/cjs/data-structures/stack/index.js.map +0 -1
  137. package/dist/cjs/data-structures/stack/stack.js +0 -402
  138. package/dist/cjs/data-structures/stack/stack.js.map +0 -1
  139. package/dist/cjs/data-structures/tree/index.js +0 -18
  140. package/dist/cjs/data-structures/tree/index.js.map +0 -1
  141. package/dist/cjs/data-structures/tree/tree.js +0 -108
  142. package/dist/cjs/data-structures/tree/tree.js.map +0 -1
  143. package/dist/cjs/data-structures/trie/index.js +0 -18
  144. package/dist/cjs/data-structures/trie/index.js.map +0 -1
  145. package/dist/cjs/data-structures/trie/trie.js +0 -611
  146. package/dist/cjs/data-structures/trie/trie.js.map +0 -1
  147. package/dist/cjs/index.js +0 -22
  148. package/dist/cjs/index.js.map +0 -1
  149. package/dist/cjs/interfaces/binary-tree.d.ts +0 -59
  150. package/dist/cjs/interfaces/binary-tree.js +0 -3
  151. package/dist/cjs/interfaces/binary-tree.js.map +0 -1
  152. package/dist/cjs/interfaces/doubly-linked-list.js +0 -3
  153. package/dist/cjs/interfaces/doubly-linked-list.js.map +0 -1
  154. package/dist/cjs/interfaces/graph.js +0 -3
  155. package/dist/cjs/interfaces/graph.js.map +0 -1
  156. package/dist/cjs/interfaces/heap.js +0 -3
  157. package/dist/cjs/interfaces/heap.js.map +0 -1
  158. package/dist/cjs/interfaces/index.js +0 -25
  159. package/dist/cjs/interfaces/index.js.map +0 -1
  160. package/dist/cjs/interfaces/navigator.js +0 -3
  161. package/dist/cjs/interfaces/navigator.js.map +0 -1
  162. package/dist/cjs/interfaces/priority-queue.js +0 -3
  163. package/dist/cjs/interfaces/priority-queue.js.map +0 -1
  164. package/dist/cjs/interfaces/segment-tree.js +0 -3
  165. package/dist/cjs/interfaces/segment-tree.js.map +0 -1
  166. package/dist/cjs/interfaces/singly-linked-list.js +0 -3
  167. package/dist/cjs/interfaces/singly-linked-list.js.map +0 -1
  168. package/dist/cjs/types/common.js +0 -3
  169. package/dist/cjs/types/common.js.map +0 -1
  170. package/dist/cjs/types/data-structures/base/base.js +0 -3
  171. package/dist/cjs/types/data-structures/base/base.js.map +0 -1
  172. package/dist/cjs/types/data-structures/base/index.js +0 -18
  173. package/dist/cjs/types/data-structures/base/index.js.map +0 -1
  174. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js +0 -3
  175. package/dist/cjs/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  176. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -3
  177. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  178. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js +0 -3
  179. package/dist/cjs/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  180. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js +0 -3
  181. package/dist/cjs/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  182. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -3
  183. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  184. package/dist/cjs/types/data-structures/binary-tree/bst.js +0 -3
  185. package/dist/cjs/types/data-structures/binary-tree/bst.js.map +0 -1
  186. package/dist/cjs/types/data-structures/binary-tree/index.js +0 -26
  187. package/dist/cjs/types/data-structures/binary-tree/index.js.map +0 -1
  188. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js +0 -3
  189. package/dist/cjs/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  190. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js +0 -3
  191. package/dist/cjs/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  192. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js +0 -3
  193. package/dist/cjs/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  194. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js +0 -3
  195. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  196. package/dist/cjs/types/data-structures/graph/abstract-graph.js +0 -3
  197. package/dist/cjs/types/data-structures/graph/abstract-graph.js.map +0 -1
  198. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -3
  199. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +0 -1
  200. package/dist/cjs/types/data-structures/graph/index.js +0 -20
  201. package/dist/cjs/types/data-structures/graph/index.js.map +0 -1
  202. package/dist/cjs/types/data-structures/graph/map-graph.js +0 -3
  203. package/dist/cjs/types/data-structures/graph/map-graph.js.map +0 -1
  204. package/dist/cjs/types/data-structures/graph/undirected-graph.js +0 -3
  205. package/dist/cjs/types/data-structures/graph/undirected-graph.js.map +0 -1
  206. package/dist/cjs/types/data-structures/hash/hash-map.js +0 -3
  207. package/dist/cjs/types/data-structures/hash/hash-map.js.map +0 -1
  208. package/dist/cjs/types/data-structures/hash/index.js +0 -18
  209. package/dist/cjs/types/data-structures/hash/index.js.map +0 -1
  210. package/dist/cjs/types/data-structures/heap/heap.js +0 -3
  211. package/dist/cjs/types/data-structures/heap/heap.js.map +0 -1
  212. package/dist/cjs/types/data-structures/heap/index.js +0 -18
  213. package/dist/cjs/types/data-structures/heap/index.js.map +0 -1
  214. package/dist/cjs/types/data-structures/heap/max-heap.js +0 -3
  215. package/dist/cjs/types/data-structures/heap/max-heap.js.map +0 -1
  216. package/dist/cjs/types/data-structures/heap/min-heap.js +0 -3
  217. package/dist/cjs/types/data-structures/heap/min-heap.js.map +0 -1
  218. package/dist/cjs/types/data-structures/index.js +0 -29
  219. package/dist/cjs/types/data-structures/index.js.map +0 -1
  220. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js +0 -3
  221. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  222. package/dist/cjs/types/data-structures/linked-list/index.js +0 -20
  223. package/dist/cjs/types/data-structures/linked-list/index.js.map +0 -1
  224. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js +0 -3
  225. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  226. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js +0 -3
  227. package/dist/cjs/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  228. package/dist/cjs/types/data-structures/matrix/index.js +0 -19
  229. package/dist/cjs/types/data-structures/matrix/index.js.map +0 -1
  230. package/dist/cjs/types/data-structures/matrix/matrix.js +0 -3
  231. package/dist/cjs/types/data-structures/matrix/matrix.js.map +0 -1
  232. package/dist/cjs/types/data-structures/matrix/navigator.js +0 -3
  233. package/dist/cjs/types/data-structures/matrix/navigator.js.map +0 -1
  234. package/dist/cjs/types/data-structures/priority-queue/index.js +0 -20
  235. package/dist/cjs/types/data-structures/priority-queue/index.js.map +0 -1
  236. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js +0 -3
  237. package/dist/cjs/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  238. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js +0 -3
  239. package/dist/cjs/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  240. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js +0 -3
  241. package/dist/cjs/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  242. package/dist/cjs/types/data-structures/queue/deque.js +0 -3
  243. package/dist/cjs/types/data-structures/queue/deque.js.map +0 -1
  244. package/dist/cjs/types/data-structures/queue/index.js +0 -19
  245. package/dist/cjs/types/data-structures/queue/index.js.map +0 -1
  246. package/dist/cjs/types/data-structures/queue/queue.js +0 -3
  247. package/dist/cjs/types/data-structures/queue/queue.js.map +0 -1
  248. package/dist/cjs/types/data-structures/stack/index.js +0 -18
  249. package/dist/cjs/types/data-structures/stack/index.js.map +0 -1
  250. package/dist/cjs/types/data-structures/stack/stack.js +0 -3
  251. package/dist/cjs/types/data-structures/stack/stack.js.map +0 -1
  252. package/dist/cjs/types/data-structures/tree/index.js +0 -18
  253. package/dist/cjs/types/data-structures/tree/index.js.map +0 -1
  254. package/dist/cjs/types/data-structures/tree/tree.js +0 -3
  255. package/dist/cjs/types/data-structures/tree/tree.js.map +0 -1
  256. package/dist/cjs/types/data-structures/trie/index.js +0 -18
  257. package/dist/cjs/types/data-structures/trie/index.js.map +0 -1
  258. package/dist/cjs/types/data-structures/trie/trie.js +0 -3
  259. package/dist/cjs/types/data-structures/trie/trie.js.map +0 -1
  260. package/dist/cjs/types/index.js +0 -20
  261. package/dist/cjs/types/index.js.map +0 -1
  262. package/dist/cjs/types/utils/index.js +0 -19
  263. package/dist/cjs/types/utils/index.js.map +0 -1
  264. package/dist/cjs/types/utils/utils.js +0 -3
  265. package/dist/cjs/types/utils/utils.js.map +0 -1
  266. package/dist/cjs/types/utils/validate-type.js +0 -3
  267. package/dist/cjs/types/utils/validate-type.js.map +0 -1
  268. package/dist/cjs/utils/index.js +0 -19
  269. package/dist/cjs/utils/index.js.map +0 -1
  270. package/dist/cjs/utils/number.js +0 -24
  271. package/dist/cjs/utils/number.js.map +0 -1
  272. package/dist/cjs/utils/utils.js +0 -354
  273. package/dist/cjs/utils/utils.js.map +0 -1
  274. package/dist/esm/common/index.d.ts +0 -12
  275. package/dist/esm/common/index.js +0 -29
  276. package/dist/esm/common/index.js.map +0 -1
  277. package/dist/esm/data-structures/base/index.d.ts +0 -2
  278. package/dist/esm/data-structures/base/index.js +0 -3
  279. package/dist/esm/data-structures/base/index.js.map +0 -1
  280. package/dist/esm/data-structures/base/iterable-element-base.d.ts +0 -219
  281. package/dist/esm/data-structures/base/iterable-element-base.js +0 -247
  282. package/dist/esm/data-structures/base/iterable-element-base.js.map +0 -1
  283. package/dist/esm/data-structures/base/iterable-entry-base.d.ts +0 -144
  284. package/dist/esm/data-structures/base/iterable-entry-base.js +0 -180
  285. package/dist/esm/data-structures/base/iterable-entry-base.js.map +0 -1
  286. package/dist/esm/data-structures/base/linear-base.d.ts +0 -335
  287. package/dist/esm/data-structures/base/linear-base.js +0 -412
  288. package/dist/esm/data-structures/base/linear-base.js.map +0 -1
  289. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  290. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +0 -369
  291. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  292. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +0 -244
  293. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  294. package/dist/esm/data-structures/binary-tree/avl-tree.js +0 -607
  295. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +0 -1
  296. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  297. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js +0 -296
  298. package/dist/esm/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  299. package/dist/esm/data-structures/binary-tree/binary-tree.js +0 -1922
  300. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +0 -1
  301. package/dist/esm/data-structures/binary-tree/bst.js +0 -901
  302. package/dist/esm/data-structures/binary-tree/bst.js.map +0 -1
  303. package/dist/esm/data-structures/binary-tree/index.d.ts +0 -10
  304. package/dist/esm/data-structures/binary-tree/index.js +0 -11
  305. package/dist/esm/data-structures/binary-tree/index.js.map +0 -1
  306. package/dist/esm/data-structures/binary-tree/red-black-tree.js +0 -540
  307. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +0 -1
  308. package/dist/esm/data-structures/binary-tree/segment-tree.d.ts +0 -160
  309. package/dist/esm/data-structures/binary-tree/segment-tree.js +0 -295
  310. package/dist/esm/data-structures/binary-tree/segment-tree.js.map +0 -1
  311. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +0 -190
  312. package/dist/esm/data-structures/binary-tree/tree-counter.js +0 -412
  313. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +0 -1
  314. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  315. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +0 -378
  316. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  317. package/dist/esm/data-structures/graph/abstract-graph.d.ts +0 -340
  318. package/dist/esm/data-structures/graph/abstract-graph.js +0 -892
  319. package/dist/esm/data-structures/graph/abstract-graph.js.map +0 -1
  320. package/dist/esm/data-structures/graph/directed-graph.d.ts +0 -207
  321. package/dist/esm/data-structures/graph/directed-graph.js +0 -521
  322. package/dist/esm/data-structures/graph/directed-graph.js.map +0 -1
  323. package/dist/esm/data-structures/graph/index.d.ts +0 -4
  324. package/dist/esm/data-structures/graph/index.js +0 -5
  325. package/dist/esm/data-structures/graph/index.js.map +0 -1
  326. package/dist/esm/data-structures/graph/map-graph.d.ts +0 -78
  327. package/dist/esm/data-structures/graph/map-graph.js +0 -105
  328. package/dist/esm/data-structures/graph/map-graph.js.map +0 -1
  329. package/dist/esm/data-structures/graph/undirected-graph.d.ts +0 -188
  330. package/dist/esm/data-structures/graph/undirected-graph.js +0 -418
  331. package/dist/esm/data-structures/graph/undirected-graph.js.map +0 -1
  332. package/dist/esm/data-structures/hash/hash-map.d.ts +0 -345
  333. package/dist/esm/data-structures/hash/hash-map.js +0 -691
  334. package/dist/esm/data-structures/hash/hash-map.js.map +0 -1
  335. package/dist/esm/data-structures/hash/index.d.ts +0 -1
  336. package/dist/esm/data-structures/hash/index.js +0 -2
  337. package/dist/esm/data-structures/hash/index.js.map +0 -1
  338. package/dist/esm/data-structures/heap/heap.d.ts +0 -503
  339. package/dist/esm/data-structures/heap/heap.js +0 -894
  340. package/dist/esm/data-structures/heap/heap.js.map +0 -1
  341. package/dist/esm/data-structures/heap/index.d.ts +0 -3
  342. package/dist/esm/data-structures/heap/index.js +0 -4
  343. package/dist/esm/data-structures/heap/index.js.map +0 -1
  344. package/dist/esm/data-structures/heap/max-heap.d.ts +0 -32
  345. package/dist/esm/data-structures/heap/max-heap.js +0 -40
  346. package/dist/esm/data-structures/heap/max-heap.js.map +0 -1
  347. package/dist/esm/data-structures/heap/min-heap.d.ts +0 -33
  348. package/dist/esm/data-structures/heap/min-heap.js +0 -28
  349. package/dist/esm/data-structures/heap/min-heap.js.map +0 -1
  350. package/dist/esm/data-structures/index.d.ts +0 -12
  351. package/dist/esm/data-structures/index.js +0 -13
  352. package/dist/esm/data-structures/index.js.map +0 -1
  353. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  354. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +0 -1109
  355. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  356. package/dist/esm/data-structures/linked-list/index.d.ts +0 -3
  357. package/dist/esm/data-structures/linked-list/index.js +0 -4
  358. package/dist/esm/data-structures/linked-list/index.js.map +0 -1
  359. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  360. package/dist/esm/data-structures/linked-list/singly-linked-list.js +0 -847
  361. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +0 -1
  362. package/dist/esm/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  363. package/dist/esm/data-structures/linked-list/skip-linked-list.js +0 -143
  364. package/dist/esm/data-structures/linked-list/skip-linked-list.js.map +0 -1
  365. package/dist/esm/data-structures/matrix/index.d.ts +0 -2
  366. package/dist/esm/data-structures/matrix/index.js +0 -3
  367. package/dist/esm/data-structures/matrix/index.js.map +0 -1
  368. package/dist/esm/data-structures/matrix/matrix.d.ts +0 -168
  369. package/dist/esm/data-structures/matrix/matrix.js +0 -444
  370. package/dist/esm/data-structures/matrix/matrix.js.map +0 -1
  371. package/dist/esm/data-structures/matrix/navigator.d.ts +0 -55
  372. package/dist/esm/data-structures/matrix/navigator.js +0 -114
  373. package/dist/esm/data-structures/matrix/navigator.js.map +0 -1
  374. package/dist/esm/data-structures/priority-queue/index.d.ts +0 -3
  375. package/dist/esm/data-structures/priority-queue/index.js +0 -4
  376. package/dist/esm/data-structures/priority-queue/index.js.map +0 -1
  377. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  378. package/dist/esm/data-structures/priority-queue/max-priority-queue.js +0 -34
  379. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  380. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  381. package/dist/esm/data-structures/priority-queue/min-priority-queue.js +0 -21
  382. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  383. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +0 -15
  384. package/dist/esm/data-structures/priority-queue/priority-queue.js +0 -17
  385. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +0 -1
  386. package/dist/esm/data-structures/queue/deque.d.ts +0 -431
  387. package/dist/esm/data-structures/queue/deque.js +0 -880
  388. package/dist/esm/data-structures/queue/deque.js.map +0 -1
  389. package/dist/esm/data-structures/queue/index.d.ts +0 -2
  390. package/dist/esm/data-structures/queue/index.js +0 -3
  391. package/dist/esm/data-structures/queue/index.js.map +0 -1
  392. package/dist/esm/data-structures/queue/queue.d.ts +0 -308
  393. package/dist/esm/data-structures/queue/queue.js +0 -467
  394. package/dist/esm/data-structures/queue/queue.js.map +0 -1
  395. package/dist/esm/data-structures/stack/index.d.ts +0 -1
  396. package/dist/esm/data-structures/stack/index.js +0 -2
  397. package/dist/esm/data-structures/stack/index.js.map +0 -1
  398. package/dist/esm/data-structures/stack/stack.d.ts +0 -306
  399. package/dist/esm/data-structures/stack/stack.js +0 -398
  400. package/dist/esm/data-structures/stack/stack.js.map +0 -1
  401. package/dist/esm/data-structures/tree/index.d.ts +0 -1
  402. package/dist/esm/data-structures/tree/index.js +0 -2
  403. package/dist/esm/data-structures/tree/index.js.map +0 -1
  404. package/dist/esm/data-structures/tree/tree.d.ts +0 -62
  405. package/dist/esm/data-structures/tree/tree.js +0 -107
  406. package/dist/esm/data-structures/tree/tree.js.map +0 -1
  407. package/dist/esm/data-structures/trie/index.d.ts +0 -1
  408. package/dist/esm/data-structures/trie/index.js +0 -2
  409. package/dist/esm/data-structures/trie/index.js.map +0 -1
  410. package/dist/esm/data-structures/trie/trie.d.ts +0 -350
  411. package/dist/esm/data-structures/trie/trie.js +0 -613
  412. package/dist/esm/data-structures/trie/trie.js.map +0 -1
  413. package/dist/esm/index.d.ts +0 -5
  414. package/dist/esm/index.js +0 -6
  415. package/dist/esm/index.js.map +0 -1
  416. package/dist/esm/interfaces/binary-tree.js +0 -2
  417. package/dist/esm/interfaces/binary-tree.js.map +0 -1
  418. package/dist/esm/interfaces/doubly-linked-list.d.ts +0 -1
  419. package/dist/esm/interfaces/doubly-linked-list.js +0 -2
  420. package/dist/esm/interfaces/doubly-linked-list.js.map +0 -1
  421. package/dist/esm/interfaces/graph.d.ts +0 -21
  422. package/dist/esm/interfaces/graph.js +0 -2
  423. package/dist/esm/interfaces/graph.js.map +0 -1
  424. package/dist/esm/interfaces/heap.d.ts +0 -1
  425. package/dist/esm/interfaces/heap.js +0 -2
  426. package/dist/esm/interfaces/heap.js.map +0 -1
  427. package/dist/esm/interfaces/index.d.ts +0 -8
  428. package/dist/esm/interfaces/index.js +0 -9
  429. package/dist/esm/interfaces/index.js.map +0 -1
  430. package/dist/esm/interfaces/navigator.d.ts +0 -1
  431. package/dist/esm/interfaces/navigator.js +0 -2
  432. package/dist/esm/interfaces/navigator.js.map +0 -1
  433. package/dist/esm/interfaces/priority-queue.d.ts +0 -1
  434. package/dist/esm/interfaces/priority-queue.js +0 -2
  435. package/dist/esm/interfaces/priority-queue.js.map +0 -1
  436. package/dist/esm/interfaces/segment-tree.d.ts +0 -1
  437. package/dist/esm/interfaces/segment-tree.js +0 -2
  438. package/dist/esm/interfaces/segment-tree.js.map +0 -1
  439. package/dist/esm/interfaces/singly-linked-list.d.ts +0 -1
  440. package/dist/esm/interfaces/singly-linked-list.js +0 -2
  441. package/dist/esm/interfaces/singly-linked-list.js.map +0 -1
  442. package/dist/esm/types/common.d.ts +0 -15
  443. package/dist/esm/types/common.js +0 -2
  444. package/dist/esm/types/common.js.map +0 -1
  445. package/dist/esm/types/data-structures/base/base.d.ts +0 -13
  446. package/dist/esm/types/data-structures/base/base.js +0 -2
  447. package/dist/esm/types/data-structures/base/base.js.map +0 -1
  448. package/dist/esm/types/data-structures/base/index.d.ts +0 -1
  449. package/dist/esm/types/data-structures/base/index.js +0 -2
  450. package/dist/esm/types/data-structures/base/index.js.map +0 -1
  451. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  452. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  453. package/dist/esm/types/data-structures/binary-tree/avl-tree-counter.js.map +0 -1
  454. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  455. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  456. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.js.map +0 -1
  457. package/dist/esm/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  458. package/dist/esm/types/data-structures/binary-tree/avl-tree.js +0 -2
  459. package/dist/esm/types/data-structures/binary-tree/avl-tree.js.map +0 -1
  460. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -1
  461. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  462. package/dist/esm/types/data-structures/binary-tree/binary-indexed-tree.js.map +0 -1
  463. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +0 -29
  464. package/dist/esm/types/data-structures/binary-tree/binary-tree.js +0 -2
  465. package/dist/esm/types/data-structures/binary-tree/binary-tree.js.map +0 -1
  466. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +0 -12
  467. package/dist/esm/types/data-structures/binary-tree/bst.js +0 -2
  468. package/dist/esm/types/data-structures/binary-tree/bst.js.map +0 -1
  469. package/dist/esm/types/data-structures/binary-tree/index.d.ts +0 -9
  470. package/dist/esm/types/data-structures/binary-tree/index.js +0 -10
  471. package/dist/esm/types/data-structures/binary-tree/index.js.map +0 -1
  472. package/dist/esm/types/data-structures/binary-tree/red-black-tree.d.ts +0 -3
  473. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js +0 -2
  474. package/dist/esm/types/data-structures/binary-tree/red-black-tree.js.map +0 -1
  475. package/dist/esm/types/data-structures/binary-tree/segment-tree.d.ts +0 -1
  476. package/dist/esm/types/data-structures/binary-tree/segment-tree.js +0 -2
  477. package/dist/esm/types/data-structures/binary-tree/segment-tree.js.map +0 -1
  478. package/dist/esm/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  479. package/dist/esm/types/data-structures/binary-tree/tree-counter.js +0 -2
  480. package/dist/esm/types/data-structures/binary-tree/tree-counter.js.map +0 -1
  481. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -2
  482. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  483. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.js.map +0 -1
  484. package/dist/esm/types/data-structures/graph/abstract-graph.d.ts +0 -14
  485. package/dist/esm/types/data-structures/graph/abstract-graph.js +0 -2
  486. package/dist/esm/types/data-structures/graph/abstract-graph.js.map +0 -1
  487. package/dist/esm/types/data-structures/graph/directed-graph.d.ts +0 -1
  488. package/dist/esm/types/data-structures/graph/directed-graph.js +0 -2
  489. package/dist/esm/types/data-structures/graph/directed-graph.js.map +0 -1
  490. package/dist/esm/types/data-structures/graph/index.d.ts +0 -3
  491. package/dist/esm/types/data-structures/graph/index.js +0 -4
  492. package/dist/esm/types/data-structures/graph/index.js.map +0 -1
  493. package/dist/esm/types/data-structures/graph/map-graph.d.ts +0 -1
  494. package/dist/esm/types/data-structures/graph/map-graph.js +0 -2
  495. package/dist/esm/types/data-structures/graph/map-graph.js.map +0 -1
  496. package/dist/esm/types/data-structures/graph/undirected-graph.d.ts +0 -1
  497. package/dist/esm/types/data-structures/graph/undirected-graph.js +0 -2
  498. package/dist/esm/types/data-structures/graph/undirected-graph.js.map +0 -1
  499. package/dist/esm/types/data-structures/hash/hash-map.d.ts +0 -19
  500. package/dist/esm/types/data-structures/hash/hash-map.js +0 -2
  501. package/dist/esm/types/data-structures/hash/hash-map.js.map +0 -1
  502. package/dist/esm/types/data-structures/hash/index.d.ts +0 -2
  503. package/dist/esm/types/data-structures/hash/index.js +0 -2
  504. package/dist/esm/types/data-structures/hash/index.js.map +0 -1
  505. package/dist/esm/types/data-structures/heap/heap.d.ts +0 -5
  506. package/dist/esm/types/data-structures/heap/heap.js +0 -2
  507. package/dist/esm/types/data-structures/heap/heap.js.map +0 -1
  508. package/dist/esm/types/data-structures/heap/index.d.ts +0 -1
  509. package/dist/esm/types/data-structures/heap/index.js +0 -2
  510. package/dist/esm/types/data-structures/heap/index.js.map +0 -1
  511. package/dist/esm/types/data-structures/heap/max-heap.d.ts +0 -1
  512. package/dist/esm/types/data-structures/heap/max-heap.js +0 -2
  513. package/dist/esm/types/data-structures/heap/max-heap.js.map +0 -1
  514. package/dist/esm/types/data-structures/heap/min-heap.d.ts +0 -1
  515. package/dist/esm/types/data-structures/heap/min-heap.js +0 -2
  516. package/dist/esm/types/data-structures/heap/min-heap.js.map +0 -1
  517. package/dist/esm/types/data-structures/index.d.ts +0 -12
  518. package/dist/esm/types/data-structures/index.js +0 -13
  519. package/dist/esm/types/data-structures/index.js.map +0 -1
  520. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
  521. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  522. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.js.map +0 -1
  523. package/dist/esm/types/data-structures/linked-list/index.d.ts +0 -3
  524. package/dist/esm/types/data-structures/linked-list/index.js +0 -4
  525. package/dist/esm/types/data-structures/linked-list/index.js.map +0 -1
  526. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +0 -2
  527. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js +0 -2
  528. package/dist/esm/types/data-structures/linked-list/singly-linked-list.js.map +0 -1
  529. package/dist/esm/types/data-structures/linked-list/skip-linked-list.d.ts +0 -4
  530. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js +0 -2
  531. package/dist/esm/types/data-structures/linked-list/skip-linked-list.js.map +0 -1
  532. package/dist/esm/types/data-structures/matrix/index.d.ts +0 -2
  533. package/dist/esm/types/data-structures/matrix/index.js +0 -3
  534. package/dist/esm/types/data-structures/matrix/index.js.map +0 -1
  535. package/dist/esm/types/data-structures/matrix/matrix.d.ts +0 -7
  536. package/dist/esm/types/data-structures/matrix/matrix.js +0 -2
  537. package/dist/esm/types/data-structures/matrix/matrix.js.map +0 -1
  538. package/dist/esm/types/data-structures/matrix/navigator.d.ts +0 -14
  539. package/dist/esm/types/data-structures/matrix/navigator.js +0 -2
  540. package/dist/esm/types/data-structures/matrix/navigator.js.map +0 -1
  541. package/dist/esm/types/data-structures/priority-queue/index.d.ts +0 -3
  542. package/dist/esm/types/data-structures/priority-queue/index.js +0 -4
  543. package/dist/esm/types/data-structures/priority-queue/index.js.map +0 -1
  544. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -1
  545. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  546. package/dist/esm/types/data-structures/priority-queue/max-priority-queue.js.map +0 -1
  547. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -1
  548. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  549. package/dist/esm/types/data-structures/priority-queue/min-priority-queue.js.map +0 -1
  550. package/dist/esm/types/data-structures/priority-queue/priority-queue.d.ts +0 -2
  551. package/dist/esm/types/data-structures/priority-queue/priority-queue.js +0 -2
  552. package/dist/esm/types/data-structures/priority-queue/priority-queue.js.map +0 -1
  553. package/dist/esm/types/data-structures/queue/deque.d.ts +0 -4
  554. package/dist/esm/types/data-structures/queue/deque.js +0 -2
  555. package/dist/esm/types/data-structures/queue/deque.js.map +0 -1
  556. package/dist/esm/types/data-structures/queue/index.d.ts +0 -2
  557. package/dist/esm/types/data-structures/queue/index.js +0 -3
  558. package/dist/esm/types/data-structures/queue/index.js.map +0 -1
  559. package/dist/esm/types/data-structures/queue/queue.d.ts +0 -4
  560. package/dist/esm/types/data-structures/queue/queue.js +0 -2
  561. package/dist/esm/types/data-structures/queue/queue.js.map +0 -1
  562. package/dist/esm/types/data-structures/stack/index.d.ts +0 -1
  563. package/dist/esm/types/data-structures/stack/index.js +0 -2
  564. package/dist/esm/types/data-structures/stack/index.js.map +0 -1
  565. package/dist/esm/types/data-structures/stack/stack.d.ts +0 -2
  566. package/dist/esm/types/data-structures/stack/stack.js +0 -2
  567. package/dist/esm/types/data-structures/stack/stack.js.map +0 -1
  568. package/dist/esm/types/data-structures/tree/index.d.ts +0 -1
  569. package/dist/esm/types/data-structures/tree/index.js +0 -2
  570. package/dist/esm/types/data-structures/tree/index.js.map +0 -1
  571. package/dist/esm/types/data-structures/tree/tree.d.ts +0 -1
  572. package/dist/esm/types/data-structures/tree/tree.js +0 -2
  573. package/dist/esm/types/data-structures/tree/tree.js.map +0 -1
  574. package/dist/esm/types/data-structures/trie/index.d.ts +0 -1
  575. package/dist/esm/types/data-structures/trie/index.js +0 -2
  576. package/dist/esm/types/data-structures/trie/index.js.map +0 -1
  577. package/dist/esm/types/data-structures/trie/trie.d.ts +0 -4
  578. package/dist/esm/types/data-structures/trie/trie.js +0 -2
  579. package/dist/esm/types/data-structures/trie/trie.js.map +0 -1
  580. package/dist/esm/types/index.d.ts +0 -3
  581. package/dist/esm/types/index.js +0 -4
  582. package/dist/esm/types/index.js.map +0 -1
  583. package/dist/esm/types/utils/index.d.ts +0 -2
  584. package/dist/esm/types/utils/index.js +0 -3
  585. package/dist/esm/types/utils/index.js.map +0 -1
  586. package/dist/esm/types/utils/utils.d.ts +0 -22
  587. package/dist/esm/types/utils/utils.js +0 -2
  588. package/dist/esm/types/utils/utils.js.map +0 -1
  589. package/dist/esm/types/utils/validate-type.d.ts +0 -19
  590. package/dist/esm/types/utils/validate-type.js +0 -2
  591. package/dist/esm/types/utils/validate-type.js.map +0 -1
  592. package/dist/esm/utils/index.d.ts +0 -2
  593. package/dist/esm/utils/index.js +0 -3
  594. package/dist/esm/utils/index.js.map +0 -1
  595. package/dist/esm/utils/number.d.ts +0 -14
  596. package/dist/esm/utils/number.js +0 -21
  597. package/dist/esm/utils/number.js.map +0 -1
  598. package/dist/esm/utils/utils.d.ts +0 -209
  599. package/dist/esm/utils/utils.js +0 -325
  600. package/dist/esm/utils/utils.js.map +0 -1
  601. package/tsconfig-cjs.json +0 -14
  602. package/tsconfig-esm.json +0 -14
  603. /package/dist/{cjs → types}/common/index.d.ts +0 -0
  604. /package/dist/{cjs → types}/data-structures/base/index.d.ts +0 -0
  605. /package/dist/{cjs → types}/data-structures/base/iterable-element-base.d.ts +0 -0
  606. /package/dist/{cjs → types}/data-structures/base/iterable-entry-base.d.ts +0 -0
  607. /package/dist/{cjs → types}/data-structures/base/linear-base.d.ts +0 -0
  608. /package/dist/{cjs → types}/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  609. /package/dist/{cjs → types}/data-structures/binary-tree/index.d.ts +0 -0
  610. /package/dist/{cjs → types}/data-structures/binary-tree/segment-tree.d.ts +0 -0
  611. /package/dist/{cjs → types}/data-structures/graph/abstract-graph.d.ts +0 -0
  612. /package/dist/{cjs → types}/data-structures/graph/directed-graph.d.ts +0 -0
  613. /package/dist/{cjs → types}/data-structures/graph/index.d.ts +0 -0
  614. /package/dist/{cjs → types}/data-structures/graph/map-graph.d.ts +0 -0
  615. /package/dist/{cjs → types}/data-structures/graph/undirected-graph.d.ts +0 -0
  616. /package/dist/{cjs → types}/data-structures/hash/hash-map.d.ts +0 -0
  617. /package/dist/{cjs → types}/data-structures/hash/index.d.ts +0 -0
  618. /package/dist/{cjs → types}/data-structures/heap/heap.d.ts +0 -0
  619. /package/dist/{cjs → types}/data-structures/heap/index.d.ts +0 -0
  620. /package/dist/{cjs → types}/data-structures/heap/max-heap.d.ts +0 -0
  621. /package/dist/{cjs → types}/data-structures/heap/min-heap.d.ts +0 -0
  622. /package/dist/{cjs → types}/data-structures/index.d.ts +0 -0
  623. /package/dist/{cjs → types}/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  624. /package/dist/{cjs → types}/data-structures/linked-list/index.d.ts +0 -0
  625. /package/dist/{cjs → types}/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  626. /package/dist/{cjs → types}/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  627. /package/dist/{cjs → types}/data-structures/matrix/index.d.ts +0 -0
  628. /package/dist/{cjs → types}/data-structures/matrix/matrix.d.ts +0 -0
  629. /package/dist/{cjs → types}/data-structures/matrix/navigator.d.ts +0 -0
  630. /package/dist/{cjs → types}/data-structures/priority-queue/index.d.ts +0 -0
  631. /package/dist/{cjs → types}/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  632. /package/dist/{cjs → types}/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  633. /package/dist/{cjs → types}/data-structures/priority-queue/priority-queue.d.ts +0 -0
  634. /package/dist/{cjs → types}/data-structures/queue/deque.d.ts +0 -0
  635. /package/dist/{cjs → types}/data-structures/queue/index.d.ts +0 -0
  636. /package/dist/{cjs → types}/data-structures/queue/queue.d.ts +0 -0
  637. /package/dist/{cjs → types}/data-structures/stack/index.d.ts +0 -0
  638. /package/dist/{cjs → types}/data-structures/stack/stack.d.ts +0 -0
  639. /package/dist/{cjs → types}/data-structures/tree/index.d.ts +0 -0
  640. /package/dist/{cjs → types}/data-structures/tree/tree.d.ts +0 -0
  641. /package/dist/{cjs → types}/data-structures/trie/index.d.ts +0 -0
  642. /package/dist/{cjs → types}/data-structures/trie/trie.d.ts +0 -0
  643. /package/dist/{cjs → types}/index.d.ts +0 -0
  644. /package/dist/{cjs → types}/interfaces/doubly-linked-list.d.ts +0 -0
  645. /package/dist/{cjs → types}/interfaces/graph.d.ts +0 -0
  646. /package/dist/{cjs → types}/interfaces/heap.d.ts +0 -0
  647. /package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
  648. /package/dist/{cjs → types}/interfaces/navigator.d.ts +0 -0
  649. /package/dist/{cjs → types}/interfaces/priority-queue.d.ts +0 -0
  650. /package/dist/{cjs → types}/interfaces/segment-tree.d.ts +0 -0
  651. /package/dist/{cjs → types}/interfaces/singly-linked-list.d.ts +0 -0
  652. /package/dist/{cjs → types}/types/common.d.ts +0 -0
  653. /package/dist/{cjs → types}/types/data-structures/base/base.d.ts +0 -0
  654. /package/dist/{cjs → types}/types/data-structures/base/index.d.ts +0 -0
  655. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -0
  656. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -0
  657. /package/dist/{cjs → types}/types/data-structures/binary-tree/avl-tree.d.ts +0 -0
  658. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -0
  659. /package/dist/{cjs → types}/types/data-structures/binary-tree/binary-tree.d.ts +0 -0
  660. /package/dist/{cjs → types}/types/data-structures/binary-tree/bst.d.ts +0 -0
  661. /package/dist/{cjs → types}/types/data-structures/binary-tree/index.d.ts +0 -0
  662. /package/dist/{cjs → types}/types/data-structures/binary-tree/red-black-tree.d.ts +0 -0
  663. /package/dist/{cjs → types}/types/data-structures/binary-tree/segment-tree.d.ts +0 -0
  664. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-counter.d.ts +0 -0
  665. /package/dist/{cjs → types}/types/data-structures/binary-tree/tree-multi-map.d.ts +0 -0
  666. /package/dist/{cjs → types}/types/data-structures/graph/abstract-graph.d.ts +0 -0
  667. /package/dist/{cjs → types}/types/data-structures/graph/directed-graph.d.ts +0 -0
  668. /package/dist/{cjs → types}/types/data-structures/graph/index.d.ts +0 -0
  669. /package/dist/{cjs → types}/types/data-structures/graph/map-graph.d.ts +0 -0
  670. /package/dist/{cjs → types}/types/data-structures/graph/undirected-graph.d.ts +0 -0
  671. /package/dist/{cjs → types}/types/data-structures/hash/hash-map.d.ts +0 -0
  672. /package/dist/{cjs → types}/types/data-structures/hash/index.d.ts +0 -0
  673. /package/dist/{cjs → types}/types/data-structures/heap/heap.d.ts +0 -0
  674. /package/dist/{cjs → types}/types/data-structures/heap/index.d.ts +0 -0
  675. /package/dist/{cjs → types}/types/data-structures/heap/max-heap.d.ts +0 -0
  676. /package/dist/{cjs → types}/types/data-structures/heap/min-heap.d.ts +0 -0
  677. /package/dist/{cjs → types}/types/data-structures/index.d.ts +0 -0
  678. /package/dist/{cjs → types}/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -0
  679. /package/dist/{cjs → types}/types/data-structures/linked-list/index.d.ts +0 -0
  680. /package/dist/{cjs → types}/types/data-structures/linked-list/singly-linked-list.d.ts +0 -0
  681. /package/dist/{cjs → types}/types/data-structures/linked-list/skip-linked-list.d.ts +0 -0
  682. /package/dist/{cjs → types}/types/data-structures/matrix/index.d.ts +0 -0
  683. /package/dist/{cjs → types}/types/data-structures/matrix/matrix.d.ts +0 -0
  684. /package/dist/{cjs → types}/types/data-structures/matrix/navigator.d.ts +0 -0
  685. /package/dist/{cjs → types}/types/data-structures/priority-queue/index.d.ts +0 -0
  686. /package/dist/{cjs → types}/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -0
  687. /package/dist/{cjs → types}/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -0
  688. /package/dist/{cjs → types}/types/data-structures/priority-queue/priority-queue.d.ts +0 -0
  689. /package/dist/{cjs → types}/types/data-structures/queue/deque.d.ts +0 -0
  690. /package/dist/{cjs → types}/types/data-structures/queue/index.d.ts +0 -0
  691. /package/dist/{cjs → types}/types/data-structures/queue/queue.d.ts +0 -0
  692. /package/dist/{cjs → types}/types/data-structures/stack/index.d.ts +0 -0
  693. /package/dist/{cjs → types}/types/data-structures/stack/stack.d.ts +0 -0
  694. /package/dist/{cjs → types}/types/data-structures/tree/index.d.ts +0 -0
  695. /package/dist/{cjs → types}/types/data-structures/tree/tree.d.ts +0 -0
  696. /package/dist/{cjs → types}/types/data-structures/trie/index.d.ts +0 -0
  697. /package/dist/{cjs → types}/types/data-structures/trie/trie.d.ts +0 -0
  698. /package/dist/{cjs → types}/types/index.d.ts +0 -0
  699. /package/dist/{cjs → types}/types/utils/index.d.ts +0 -0
  700. /package/dist/{cjs → types}/types/utils/utils.d.ts +0 -0
  701. /package/dist/{cjs → types}/types/utils/validate-type.d.ts +0 -0
  702. /package/dist/{cjs → types}/utils/index.d.ts +0 -0
  703. /package/dist/{cjs → types}/utils/number.d.ts +0 -0
  704. /package/dist/{cjs → types}/utils/utils.d.ts +0 -0
@@ -1,904 +0,0 @@
1
- "use strict";
2
- /**
3
- * data-structure-typed
4
- *
5
- * @author Pablo Zeng
6
- * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
7
- * @license MIT License
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.BST = exports.BSTNode = void 0;
11
- const binary_tree_1 = require("./binary-tree");
12
- const queue_1 = require("../queue");
13
- const utils_1 = require("../../utils");
14
- const common_1 = require("../../common");
15
- /**
16
- * Represents a Node in a Binary Search Tree.
17
- *
18
- * @template K - The type of the key.
19
- * @template V - The type of the value.
20
- */
21
- class BSTNode extends binary_tree_1.BinaryTreeNode {
22
- /**
23
- * Creates an instance of BSTNode.
24
- * @remarks Time O(1), Space O(1)
25
- *
26
- * @param key - The key of the node.
27
- * @param [value] - The value associated with the key.
28
- */
29
- constructor(key, value) {
30
- super(key, value);
31
- this.parent = undefined;
32
- this._left = undefined;
33
- this._right = undefined;
34
- }
35
- /**
36
- * Gets the left child of the node.
37
- * @remarks Time O(1), Space O(1)
38
- *
39
- * @returns The left child.
40
- */
41
- get left() {
42
- return this._left;
43
- }
44
- /**
45
- * Sets the left child of the node and updates its parent reference.
46
- * @remarks Time O(1), Space O(1)
47
- *
48
- * @param v - The node to set as the left child.
49
- */
50
- set left(v) {
51
- if (v)
52
- v.parent = this;
53
- this._left = v;
54
- }
55
- /**
56
- * Gets the right child of the node.
57
- * @remarks Time O(1), Space O(1)
58
- *
59
- * @returns The right child.
60
- */
61
- get right() {
62
- return this._right;
63
- }
64
- /**
65
- * Sets the right child of the node and updates its parent reference.
66
- * @remarks Time O(1), Space O(1)
67
- *
68
- * @param v - The node to set as the right child.
69
- */
70
- set right(v) {
71
- if (v)
72
- v.parent = this;
73
- this._right = v;
74
- }
75
- }
76
- exports.BSTNode = BSTNode;
77
- /**
78
- * Represents a Binary Search Tree (BST).
79
- * Keys are ordered, allowing for faster search operations compared to a standard Binary Tree.
80
- * @template K - The type of the key.
81
- * @template V - The type of the value.
82
- * @template R - The type of the raw data object (if using `toEntryFn`).
83
- *
84
- * 1. Node Order: Each node's left child has a lesser value, and the right child has a greater value.
85
- * 2. Unique Keys: No duplicate keys in a standard BST.
86
- * 3. Efficient Search: Enables quick search, minimum, and maximum operations.
87
- * 4. Inorder Traversal: Yields nodes in ascending order.
88
- * 5. Logarithmic Operations: Ideal operations like insertion, deletion, and searching are O(log n) time-efficient.
89
- * 6. Balance Variability: Can become unbalanced; special types maintain balance.
90
- * 7. No Auto-Balancing: Standard BSTs don't automatically balance themselves.
91
- * @example
92
- * // Merge 3 sorted datasets
93
- * const dataset1 = new BST<number, string>([
94
- * [1, 'A'],
95
- * [7, 'G']
96
- * ]);
97
- * const dataset2 = [
98
- * [2, 'B'],
99
- * [6, 'F']
100
- * ];
101
- * const dataset3 = new BST<number, string>([
102
- * [3, 'C'],
103
- * [5, 'E'],
104
- * [4, 'D']
105
- * ]);
106
- *
107
- * // Merge datasets into a single BinarySearchTree
108
- * const merged = new BST<number, string>(dataset1);
109
- * merged.addMany(dataset2);
110
- * merged.merge(dataset3);
111
- *
112
- * // Verify merged dataset is in sorted order
113
- * console.log([...merged.values()]); // ['A', 'B', 'C', 'D', 'E', 'F', 'G']
114
- * @example
115
- * // Find elements in a range
116
- * const bst = new BST<number>([10, 5, 15, 3, 7, 12, 18]);
117
- * console.log(bst.search(new Range(5, 10))); // [5, 7, 10]
118
- * console.log(bst.rangeSearch([4, 12], node => node.key.toString())); // ['5', '7', '10', '12']
119
- * console.log(bst.search(new Range(4, 12, true, false))); // [5, 7, 10]
120
- * console.log(bst.rangeSearch([15, 20])); // [15, 18]
121
- * console.log(bst.search(new Range(15, 20, false))); // [18]
122
- * @example
123
- * // Find lowest common ancestor
124
- * const bst = new BST<number>([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 18]);
125
- *
126
- * // LCA helper function
127
- * const findLCA = (num1: number, num2: number): number | undefined => {
128
- * const path1 = bst.getPathToRoot(num1);
129
- * const path2 = bst.getPathToRoot(num2);
130
- * // Find the first common ancestor
131
- * return findFirstCommon(path1, path2);
132
- * };
133
- *
134
- * function findFirstCommon(arr1: number[], arr2: number[]): number | undefined {
135
- * for (const num of arr1) {
136
- * if (arr2.indexOf(num) !== -1) {
137
- * return num;
138
- * }
139
- * }
140
- * return undefined;
141
- * }
142
- *
143
- * // Assertions
144
- * console.log(findLCA(3, 10)); // 7
145
- * console.log(findLCA(5, 35)); // 15
146
- * console.log(findLCA(20, 30)); // 25
147
- */
148
- class BST extends binary_tree_1.BinaryTree {
149
- /**
150
- * Creates an instance of BST.
151
- * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).
152
- *
153
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
154
- * @param [options] - Configuration options for the BST, including comparator.
155
- */
156
- constructor(keysNodesEntriesOrRaws = [], options) {
157
- super([], options);
158
- this._root = undefined;
159
- this._isReverse = false;
160
- /**
161
- * The default comparator function.
162
- * @remarks Time O(1) (or O(C) if `specifyComparable` is used, C is complexity of that function).
163
- */
164
- this._comparator = (a, b) => {
165
- if ((0, utils_1.isComparable)(a) && (0, utils_1.isComparable)(b)) {
166
- if (a > b)
167
- return 1;
168
- if (a < b)
169
- return -1;
170
- return 0;
171
- }
172
- if (this._specifyComparable) {
173
- const va = this._specifyComparable(a);
174
- const vb = this._specifyComparable(b);
175
- if (va > vb)
176
- return 1;
177
- if (va < vb)
178
- return -1;
179
- return 0;
180
- }
181
- if (typeof a === 'object' || typeof b === 'object') {
182
- throw TypeError(`When comparing object types, a custom specifyComparable must be defined in the constructor's options.`);
183
- }
184
- return 0;
185
- };
186
- if (options) {
187
- const { specifyComparable, isReverse } = options;
188
- if (typeof specifyComparable === 'function')
189
- this._specifyComparable = specifyComparable;
190
- if (isReverse !== undefined)
191
- this._isReverse = isReverse;
192
- }
193
- if (keysNodesEntriesOrRaws)
194
- this.addMany(keysNodesEntriesOrRaws);
195
- }
196
- /**
197
- * Gets the root node of the tree.
198
- * @remarks Time O(1)
199
- *
200
- * @returns The root node.
201
- */
202
- get root() {
203
- return this._root;
204
- }
205
- /**
206
- * Gets whether the tree's comparison logic is reversed.
207
- * @remarks Time O(1)
208
- *
209
- * @returns True if the tree is reversed (e.g., a max-heap logic).
210
- */
211
- get isReverse() {
212
- return this._isReverse;
213
- }
214
- /**
215
- * Gets the comparator function used by the tree.
216
- * @remarks Time O(1)
217
- *
218
- * @returns The comparator function.
219
- */
220
- get comparator() {
221
- return this._comparator;
222
- }
223
- /**
224
- * Gets the function used to extract a comparable value from a complex key.
225
- * @remarks Time O(1)
226
- *
227
- * @returns The key-to-comparable conversion function.
228
- */
229
- get specifyComparable() {
230
- return this._specifyComparable;
231
- }
232
- /**
233
- * (Protected) Creates a new BST node.
234
- * @remarks Time O(1), Space O(1)
235
- *
236
- * @param key - The key for the new node.
237
- * @param [value] - The value for the new node (used if not in Map mode).
238
- * @returns The newly created BSTNode.
239
- */
240
- _createNode(key, value) {
241
- return new BSTNode(key, this._isMapMode ? undefined : value);
242
- }
243
- /**
244
- * Ensures the input is a node. If it's a key or entry, it searches for the node.
245
- * @remarks Time O(log N) (height of the tree), O(N) worst-case.
246
- *
247
- * @param keyNodeOrEntry - The item to resolve to a node.
248
- * @param [iterationType=this.iterationType] - The traversal method to use if searching.
249
- * @returns The resolved node, or undefined if not found.
250
- */
251
- ensureNode(keyNodeOrEntry, iterationType = this.iterationType) {
252
- var _a;
253
- return (_a = super.ensureNode(keyNodeOrEntry, iterationType)) !== null && _a !== void 0 ? _a : undefined;
254
- }
255
- /**
256
- * Checks if the given item is a `BSTNode` instance.
257
- * @remarks Time O(1), Space O(1)
258
- *
259
- * @param keyNodeOrEntry - The item to check.
260
- * @returns True if it's a BSTNode, false otherwise.
261
- */
262
- isNode(keyNodeOrEntry) {
263
- return keyNodeOrEntry instanceof BSTNode;
264
- }
265
- /**
266
- * Checks if the given key is valid (comparable).
267
- * @remarks Time O(1)
268
- *
269
- * @param key - The key to validate.
270
- * @returns True if the key is valid, false otherwise.
271
- */
272
- isValidKey(key) {
273
- return (0, utils_1.isComparable)(key, this._specifyComparable !== undefined);
274
- }
275
- /**
276
- * Performs a Depth-First Search (DFS) traversal.
277
- * @remarks Time O(N), visits every node. Space O(log N) for the call/explicit stack. O(N) worst-case.
278
- *
279
- * @template C - The type of the callback function.
280
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.
281
- * @param [pattern='IN'] - The traversal order ('IN', 'PRE', 'POST').
282
- * @param [onlyOne=false] - If true, stops after the first callback.
283
- * @param [startNode=this._root] - The node to start from.
284
- * @param [iterationType=this.iterationType] - The traversal method.
285
- * @returns An array of callback results.
286
- */
287
- dfs(callback = this._DEFAULT_NODE_CALLBACK, pattern = 'IN', onlyOne = false, startNode = this._root, iterationType = this.iterationType) {
288
- return super.dfs(callback, pattern, onlyOne, startNode, iterationType);
289
- }
290
- /**
291
- * Performs a Breadth-First Search (BFS) or Level-Order traversal.
292
- * @remarks Time O(N), visits every node. Space O(N) in the worst case for the queue.
293
- *
294
- * @template C - The type of the callback function.
295
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.
296
- * @param [startNode=this._root] - The node to start from.
297
- * @param [iterationType=this.iterationType] - The traversal method.
298
- * @returns An array of callback results.
299
- */
300
- bfs(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
301
- return super.bfs(callback, startNode, iterationType, false);
302
- }
303
- /**
304
- * Returns a 2D array of nodes, grouped by level.
305
- * @remarks Time O(N), visits every node. Space O(N) for the result array and the queue/stack.
306
- *
307
- * @template C - The type of the callback function.
308
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each node.
309
- * @param [startNode=this._root] - The node to start from.
310
- * @param [iterationType=this.iterationType] - The traversal method.
311
- * @returns A 2D array of callback results.
312
- */
313
- listLevels(callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
314
- return super.listLevels(callback, startNode, iterationType, false);
315
- }
316
- /**
317
- * Gets the first node matching a predicate.
318
- * @remarks Time O(log N) if searching by key, O(N) if searching by predicate. Space O(log N) or O(N).
319
- *
320
- * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
321
- * @param [startNode=this._root] - The node to start the search from.
322
- * @param [iterationType=this.iterationType] - The traversal method.
323
- * @returns The first matching node, or undefined if not found.
324
- */
325
- getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
326
- var _a;
327
- return (_a = this.getNodes(keyNodeEntryOrPredicate, true, startNode, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
328
- }
329
- /**
330
- * Searches the tree for nodes matching a predicate, key, or range.
331
- * @remarks This is an optimized search for a BST. If searching by key or range, it prunes branches.
332
- * Time O(H + M) for key/range search (H=height, M=matches). O(N) for predicate search.
333
- * Space O(log N) for the stack.
334
- *
335
- * @template C - The type of the callback function.
336
- * @param keyNodeEntryOrPredicate - The key, node, entry, predicate, or range to search for.
337
- * @param [onlyOne=false] - If true, stops after finding the first match.
338
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on matching nodes.
339
- * @param [startNode=this._root] - The node to start the search from.
340
- * @param [iterationType=this.iterationType] - Whether to use 'RECURSIVE' or 'ITERATIVE' search.
341
- * @returns An array of results from the callback function for each matching node.
342
- */
343
- search(keyNodeEntryOrPredicate, onlyOne = false, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
344
- if (keyNodeEntryOrPredicate === undefined)
345
- return [];
346
- if (keyNodeEntryOrPredicate === null)
347
- return [];
348
- startNode = this.ensureNode(startNode);
349
- if (!startNode)
350
- return [];
351
- let predicate;
352
- const isRange = this.isRange(keyNodeEntryOrPredicate);
353
- if (isRange) {
354
- predicate = node => {
355
- if (!node)
356
- return false;
357
- return keyNodeEntryOrPredicate.isInRange(node.key, this._comparator);
358
- };
359
- }
360
- else {
361
- predicate = this._ensurePredicate(keyNodeEntryOrPredicate);
362
- }
363
- // Optimization: Pruning logic
364
- const shouldVisitLeft = (cur) => {
365
- if (!cur)
366
- return false;
367
- if (!this.isRealNode(cur.left))
368
- return false;
369
- if (isRange) {
370
- // Range search: Only go left if the current key is >= the lower bound
371
- const range = keyNodeEntryOrPredicate;
372
- const leftS = this.isReverse ? range.high : range.low;
373
- const leftI = this.isReverse ? range.includeHigh : range.includeLow;
374
- return (leftI && this._compare(cur.key, leftS) >= 0) || (!leftI && this._compare(cur.key, leftS) > 0);
375
- }
376
- if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {
377
- // Key search: Only go left if current key > target key
378
- const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
379
- return benchmarkKey !== null && benchmarkKey !== undefined && this._compare(cur.key, benchmarkKey) > 0;
380
- }
381
- return true; // Predicate search: must visit all
382
- };
383
- const shouldVisitRight = (cur) => {
384
- if (!cur)
385
- return false;
386
- if (!this.isRealNode(cur.right))
387
- return false;
388
- if (isRange) {
389
- // Range search: Only go right if current key <= upper bound
390
- const range = keyNodeEntryOrPredicate;
391
- const rightS = this.isReverse ? range.low : range.high;
392
- const rightI = this.isReverse ? range.includeLow : range.includeHigh;
393
- return (rightI && this._compare(cur.key, rightS) <= 0) || (!rightI && this._compare(cur.key, rightS) < 0);
394
- }
395
- if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {
396
- // Key search: Only go right if current key < target key
397
- const benchmarkKey = this._extractKey(keyNodeEntryOrPredicate);
398
- return benchmarkKey !== null && benchmarkKey !== undefined && this._compare(cur.key, benchmarkKey) < 0;
399
- }
400
- return true; // Predicate search: must visit all
401
- };
402
- return super._dfs(callback, 'IN', // In-order is efficient for range/key search
403
- onlyOne, startNode, iterationType, false, shouldVisitLeft, shouldVisitRight, () => true, // shouldVisitRoot (always visit)
404
- // shouldVisitRoot (always visit)
405
- cur => !!cur && predicate(cur) // shouldProcessRoot (only process if predicate matches)
406
- );
407
- }
408
- /**
409
- * Performs an optimized search for nodes within a given key range.
410
- * @remarks Time O(H + M), where H is tree height and M is the number of matches.
411
- *
412
- * @template C - The type of the callback function.
413
- * @param range - A `Range` object or a `[low, high]` tuple.
414
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - A function to call on matching nodes.
415
- * @param [startNode=this._root] - The node to start the search from.
416
- * @param [iterationType=this.iterationType] - The traversal method.
417
- * @returns An array of callback results.
418
- */
419
- rangeSearch(range, callback = this._DEFAULT_NODE_CALLBACK, startNode = this._root, iterationType = this.iterationType) {
420
- const searchRange = range instanceof common_1.Range ? range : new common_1.Range(range[0], range[1]);
421
- return this.search(searchRange, false, callback, startNode, iterationType);
422
- }
423
- /**
424
- * Adds a new node to the BST based on key comparison.
425
- * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
426
- *
427
- * @param keyNodeOrEntry - The key, node, or entry to add.
428
- * @param [value] - The value, if providing just a key.
429
- * @returns True if the addition was successful, false otherwise.
430
- */
431
- add(keyNodeOrEntry, value) {
432
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
433
- if (newNode === undefined)
434
- return false;
435
- if (this._root === undefined) {
436
- this._setRoot(newNode);
437
- if (this._isMapMode)
438
- this._setValue(newNode === null || newNode === void 0 ? void 0 : newNode.key, newValue);
439
- this._size++;
440
- return true;
441
- }
442
- let current = this._root;
443
- while (current !== undefined) {
444
- if (this._compare(current.key, newNode.key) === 0) {
445
- // Key exists, replace node
446
- this._replaceNode(current, newNode);
447
- if (this._isMapMode)
448
- this._setValue(current.key, newValue);
449
- return true;
450
- }
451
- else if (this._compare(current.key, newNode.key) > 0) {
452
- // Go left
453
- if (current.left === undefined) {
454
- current.left = newNode;
455
- if (this._isMapMode)
456
- this._setValue(newNode === null || newNode === void 0 ? void 0 : newNode.key, newValue);
457
- this._size++;
458
- return true;
459
- }
460
- if (current.left !== null)
461
- current = current.left;
462
- }
463
- else {
464
- // Go right
465
- if (current.right === undefined) {
466
- current.right = newNode;
467
- if (this._isMapMode)
468
- this._setValue(newNode === null || newNode === void 0 ? void 0 : newNode.key, newValue);
469
- this._size++;
470
- return true;
471
- }
472
- if (current.right !== null)
473
- current = current.right;
474
- }
475
- }
476
- return false;
477
- }
478
- /**
479
- * Adds multiple items to the tree.
480
- * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced add).
481
- * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.
482
- * Space O(N) for sorting and recursion/iteration stack.
483
- *
484
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
485
- * @param [values] - An optional parallel iterable of values.
486
- * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
487
- * @param [iterationType=this.iterationType] - The traversal method for balanced add (recursive or iterative).
488
- * @returns An array of booleans indicating the success of each individual `add` operation.
489
- */
490
- addMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
491
- const inserted = [];
492
- const valuesIterator = values === null || values === void 0 ? void 0 : values[Symbol.iterator]();
493
- if (!isBalanceAdd) {
494
- // Standard O(N*H) insertion
495
- for (let kve of keysNodesEntriesOrRaws) {
496
- const val = valuesIterator === null || valuesIterator === void 0 ? void 0 : valuesIterator.next().value;
497
- if (this.isRaw(kve))
498
- kve = this._toEntryFn(kve);
499
- inserted.push(this.add(kve, val));
500
- }
501
- return inserted;
502
- }
503
- // Balanced O(N log N) insertion
504
- const realBTNExemplars = [];
505
- let i = 0;
506
- for (const kve of keysNodesEntriesOrRaws) {
507
- realBTNExemplars.push({ key: kve, value: valuesIterator === null || valuesIterator === void 0 ? void 0 : valuesIterator.next().value, orgIndex: i++ });
508
- }
509
- // Sort items by key
510
- const sorted = realBTNExemplars.sort(({ key: a }, { key: b }) => {
511
- let keyA, keyB;
512
- if (this.isRaw(a))
513
- keyA = this._toEntryFn(a)[0];
514
- else if (this.isEntry(a))
515
- keyA = a[0];
516
- else if (this.isRealNode(a))
517
- keyA = a.key;
518
- else
519
- keyA = a;
520
- if (this.isRaw(b))
521
- keyB = this._toEntryFn(b)[0];
522
- else if (this.isEntry(b))
523
- keyB = b[0];
524
- else if (this.isRealNode(b))
525
- keyB = b.key;
526
- else
527
- keyB = b;
528
- if (keyA != null && keyB != null)
529
- return this._compare(keyA, keyB);
530
- return 0;
531
- });
532
- // Recursive balanced build
533
- const _dfs = (arr) => {
534
- if (arr.length === 0)
535
- return;
536
- const mid = Math.floor((arr.length - 1) / 2);
537
- const { key, value, orgIndex } = arr[mid];
538
- if (this.isRaw(key)) {
539
- const entry = this._toEntryFn(key);
540
- inserted[orgIndex] = this.add(entry);
541
- }
542
- else {
543
- inserted[orgIndex] = this.add(key, value);
544
- }
545
- _dfs(arr.slice(0, mid));
546
- _dfs(arr.slice(mid + 1));
547
- };
548
- // Iterative balanced build
549
- const _iterate = () => {
550
- const n = sorted.length;
551
- const stack = [[0, n - 1]];
552
- while (stack.length > 0) {
553
- const popped = stack.pop();
554
- if (!popped)
555
- continue;
556
- const [l, r] = popped;
557
- if (l > r)
558
- continue;
559
- const m = l + Math.floor((r - l) / 2);
560
- const { key, value, orgIndex } = sorted[m];
561
- if (this.isRaw(key)) {
562
- const entry = this._toEntryFn(key);
563
- inserted[orgIndex] = this.add(entry);
564
- }
565
- else {
566
- inserted[orgIndex] = this.add(key, value);
567
- }
568
- stack.push([m + 1, r]);
569
- stack.push([l, m - 1]);
570
- }
571
- };
572
- if (iterationType === 'RECURSIVE')
573
- _dfs(sorted);
574
- else
575
- _iterate();
576
- return inserted;
577
- }
578
- /**
579
- * Traverses the tree and returns nodes that are lesser or greater than a target node.
580
- * @remarks Time O(N), as it performs a full traversal. Space O(log N) or O(N).
581
- *
582
- * @template C - The type of the callback function.
583
- * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on matching nodes.
584
- * @param [lesserOrGreater=-1] - -1 for lesser, 1 for greater, 0 for equal.
585
- * @param [targetNode=this._root] - The node to compare against.
586
- * @param [iterationType=this.iterationType] - The traversal method.
587
- * @returns An array of callback results.
588
- */
589
- lesserOrGreaterTraverse(callback = this._DEFAULT_NODE_CALLBACK, lesserOrGreater = -1, targetNode = this._root, iterationType = this.iterationType) {
590
- const targetNodeEnsured = this.ensureNode(targetNode);
591
- const ans = [];
592
- if (!this._root || !targetNodeEnsured)
593
- return ans;
594
- const targetKey = targetNodeEnsured.key;
595
- if (iterationType === 'RECURSIVE') {
596
- const dfs = (cur) => {
597
- const compared = this._compare(cur.key, targetKey);
598
- if (Math.sign(compared) == lesserOrGreater)
599
- ans.push(callback(cur));
600
- if (this.isRealNode(cur.left))
601
- dfs(cur.left);
602
- if (this.isRealNode(cur.right))
603
- dfs(cur.right);
604
- };
605
- dfs(this._root);
606
- return ans;
607
- }
608
- else {
609
- const queue = new queue_1.Queue([this._root]);
610
- while (queue.length > 0) {
611
- const cur = queue.shift();
612
- if (this.isRealNode(cur)) {
613
- const compared = this._compare(cur.key, targetKey);
614
- if (Math.sign(compared) == lesserOrGreater)
615
- ans.push(callback(cur));
616
- if (this.isRealNode(cur.left))
617
- queue.push(cur.left);
618
- if (this.isRealNode(cur.right))
619
- queue.push(cur.right);
620
- }
621
- }
622
- return ans;
623
- }
624
- }
625
- /**
626
- * Rebuilds the tree to be perfectly balanced.
627
- * @remarks Time O(N) (O(N) for DFS, O(N) for sorted build). Space O(N) for node array and recursion stack.
628
- *
629
- * @param [iterationType=this.iterationType] - The traversal method for the initial node export.
630
- * @returns True if successful, false if the tree was empty.
631
- */
632
- perfectlyBalance(iterationType = this.iterationType) {
633
- const nodes = this.dfs(node => node, 'IN', false, this._root, iterationType);
634
- const n = nodes.length;
635
- this._clearNodes();
636
- if (n === 0)
637
- return false;
638
- // Build balanced tree from sorted array
639
- const build = (l, r, parent) => {
640
- if (l > r)
641
- return undefined;
642
- const m = l + ((r - l) >> 1);
643
- const root = nodes[m];
644
- const leftChild = build(l, m - 1, root);
645
- const rightChild = build(m + 1, r, root);
646
- root.left = leftChild;
647
- root.right = rightChild;
648
- root.parent = parent;
649
- return root;
650
- };
651
- const newRoot = build(0, n - 1, undefined);
652
- this._setRoot(newRoot);
653
- this._size = n;
654
- return true;
655
- }
656
- /**
657
- * Checks if the tree meets the AVL balance condition (height difference <= 1).
658
- * @remarks Time O(N), as it must visit every node to compute height. Space O(log N) for recursion or O(N) for iterative map.
659
- *
660
- * @param [iterationType=this.iterationType] - The traversal method.
661
- * @returns True if the tree is AVL balanced, false otherwise.
662
- */
663
- isAVLBalanced(iterationType = this.iterationType) {
664
- if (!this._root)
665
- return true;
666
- let balanced = true;
667
- if (iterationType === 'RECURSIVE') {
668
- // Recursive height check
669
- const _height = (cur) => {
670
- if (!cur)
671
- return 0;
672
- const leftHeight = _height(cur.left);
673
- const rightHeight = _height(cur.right);
674
- if (Math.abs(leftHeight - rightHeight) > 1)
675
- balanced = false;
676
- return Math.max(leftHeight, rightHeight) + 1;
677
- };
678
- _height(this._root);
679
- }
680
- else {
681
- // Iterative post-order height check
682
- const stack = [];
683
- let node = this._root, last = undefined;
684
- const depths = new Map();
685
- while (stack.length > 0 || node) {
686
- if (node) {
687
- stack.push(node);
688
- if (node.left !== null)
689
- node = node.left;
690
- }
691
- else {
692
- node = stack[stack.length - 1];
693
- if (!node.right || last === node.right) {
694
- node = stack.pop();
695
- if (node) {
696
- const left = node.left ? depths.get(node.left) : -1;
697
- const right = node.right ? depths.get(node.right) : -1;
698
- if (Math.abs(left - right) > 1)
699
- return false;
700
- depths.set(node, 1 + Math.max(left, right));
701
- last = node;
702
- node = undefined;
703
- }
704
- }
705
- else
706
- node = node.right;
707
- }
708
- }
709
- }
710
- return balanced;
711
- }
712
- /**
713
- * Creates a new BST by mapping each [key, value] pair to a new entry.
714
- * @remarks Time O(N * H), where N is nodes in this tree, and H is height of the new tree during insertion.
715
- * Space O(N) for the new tree.
716
- *
717
- * @template MK - New key type.
718
- * @template MV - New value type.
719
- * @template MR - New raw type.
720
- * @param callback - A function to map each [key, value] pair.
721
- * @param [options] - Options for the new BST.
722
- * @param [thisArg] - `this` context for the callback.
723
- * @returns A new, mapped BST.
724
- */
725
- map(callback, options, thisArg) {
726
- const out = this._createLike([], options);
727
- let index = 0;
728
- // Iterates in-order
729
- for (const [key, value] of this) {
730
- out.add(callback.call(thisArg, key, value, index++, this));
731
- }
732
- return out;
733
- }
734
- /**
735
- * Deletes the first node found that satisfies the predicate.
736
- * @remarks Performs an in-order traversal. Time O(N) worst-case (O(log N) to find + O(log N) to delete). Space O(log N) for stack.
737
- *
738
- * @param predicate - A function to test each [key, value] pair.
739
- * @returns True if a node was deleted, false otherwise.
740
- */
741
- deleteWhere(predicate) {
742
- const stack = [];
743
- let cur = this._root;
744
- let index = 0;
745
- // In-order traversal to find the node
746
- while (stack.length > 0 || cur !== undefined) {
747
- while (cur !== undefined && cur !== null) {
748
- stack.push(cur);
749
- cur = cur.left;
750
- }
751
- const node = stack.pop();
752
- if (!node)
753
- break;
754
- const key = node.key;
755
- const val = node.value;
756
- if (predicate(key, val, index++, this)) {
757
- return this._deleteByKey(key); // Found, now delete
758
- }
759
- cur = node.right;
760
- }
761
- return false;
762
- }
763
- /**
764
- * (Protected) Creates a new, empty instance of the same BST constructor.
765
- * @remarks Time O(1)
766
- *
767
- * @template TK, TV, TR - Generic types for the new instance.
768
- * @param [options] - Options for the new BST.
769
- * @returns A new, empty BST.
770
- */
771
- _createInstance(options) {
772
- const Ctor = this.constructor;
773
- return new Ctor([], Object.assign(Object.assign({}, this._snapshotOptions()), (options !== null && options !== void 0 ? options : {})));
774
- }
775
- /**
776
- * (Protected) Creates a new instance of the same BST constructor, potentially with different generic types.
777
- * @remarks Time O(N log N) or O(N^2) (from constructor) due to processing the iterable.
778
- *
779
- * @template TK, TV, TR - Generic types for the new instance.
780
- * @param [iter=[]] - An iterable to populate the new BST.
781
- * @param [options] - Options for the new BST.
782
- * @returns A new BST.
783
- */
784
- _createLike(iter = [], options) {
785
- const Ctor = this.constructor;
786
- return new Ctor(iter, Object.assign(Object.assign({}, this._snapshotOptions()), (options !== null && options !== void 0 ? options : {})));
787
- }
788
- /**
789
- * (Protected) Snapshots the current BST's configuration options.
790
- * @remarks Time O(1)
791
- *
792
- * @template TK, TV, TR - Generic types for the options.
793
- * @returns The options object.
794
- */
795
- _snapshotOptions() {
796
- return Object.assign(Object.assign({}, super._snapshotOptions()), { specifyComparable: this.specifyComparable, isReverse: this.isReverse });
797
- }
798
- /**
799
- * (Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
800
- * @remarks Time O(1)
801
- *
802
- * @param keyNodeOrEntry - The input item.
803
- * @param [value] - An optional value (used if input is just a key).
804
- * @returns A tuple of [node, value].
805
- */
806
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value) {
807
- const [node, entryValue] = super._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
808
- if (node === null)
809
- return [undefined, undefined]; // BST handles null differently (as undefined)
810
- return [node, value !== null && value !== void 0 ? value : entryValue];
811
- }
812
- /**
813
- * (Protected) Sets the root node and clears its parent reference.
814
- * @remarks Time O(1)
815
- *
816
- * @param v - The node to set as root.
817
- */
818
- _setRoot(v) {
819
- if (v)
820
- v.parent = undefined;
821
- this._root = v;
822
- }
823
- /**
824
- * (Protected) Compares two keys using the tree's comparator and reverse setting.
825
- * @remarks Time O(1) (or O(C) if `specifyComparable` is used).
826
- *
827
- * @param a - The first key.
828
- * @param b - The second key.
829
- * @returns A number (1, -1, or 0) representing the comparison.
830
- */
831
- _compare(a, b) {
832
- return this._isReverse ? -this._comparator(a, b) : this._comparator(a, b);
833
- }
834
- /**
835
- * (Private) Deletes a node by its key.
836
- * @remarks Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
837
- *
838
- * @param key - The key of the node to delete.
839
- * @returns True if the node was found and deleted, false otherwise.
840
- */
841
- _deleteByKey(key) {
842
- var _a;
843
- let node = this._root;
844
- // 1. Find the node
845
- while (node) {
846
- const cmp = this._compare(node.key, key);
847
- if (cmp === 0)
848
- break;
849
- node = cmp > 0 ? node.left : node.right;
850
- }
851
- if (!node)
852
- return false; // Not found
853
- // Helper to replace node `u` with node `v`
854
- const transplant = (u, v) => {
855
- const p = u === null || u === void 0 ? void 0 : u.parent;
856
- if (!p) {
857
- this._setRoot(v);
858
- }
859
- else if (p.left === u) {
860
- p.left = v;
861
- }
862
- else {
863
- p.right = v;
864
- }
865
- if (v)
866
- v.parent = p;
867
- };
868
- // Helper to find the minimum node in a subtree
869
- const minNode = (x) => {
870
- if (!x)
871
- return undefined;
872
- while (x.left !== undefined && x.left !== null)
873
- x = x.left;
874
- return x;
875
- };
876
- // 2. Perform deletion
877
- if (node.left === undefined) {
878
- // Case 1: No left child
879
- transplant(node, node.right);
880
- }
881
- else if (node.right === undefined) {
882
- // Case 2: No right child
883
- transplant(node, node.left);
884
- }
885
- else {
886
- // Case 3: Two children
887
- const succ = minNode(node.right); // Find successor
888
- if (succ.parent !== node) {
889
- transplant(succ, succ.right);
890
- succ.right = node.right;
891
- if (succ.right)
892
- succ.right.parent = succ;
893
- }
894
- transplant(node, succ);
895
- succ.left = node.left;
896
- if (succ.left)
897
- succ.left.parent = succ;
898
- }
899
- this._size = Math.max(0, ((_a = this._size) !== null && _a !== void 0 ? _a : 0) - 1);
900
- return true;
901
- }
902
- }
903
- exports.BST = BST;
904
- //# sourceMappingURL=bst.js.map