data-structure-typed 2.3.0 → 2.4.0

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 (676) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/CMakeLists.txt +52 -0
  3. package/README.md +4 -4
  4. package/README_CN.md +5 -5
  5. package/benchmark/report.html +141 -12
  6. package/benchmark/report.json +1969 -38
  7. package/build/CMakeCache.txt +603 -0
  8. package/build/CMakeFiles/4.0.3/CMakeCXXCompiler.cmake +104 -0
  9. package/build/CMakeFiles/4.0.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
  10. package/build/CMakeFiles/4.0.3/CMakeSystem.cmake +15 -0
  11. package/build/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
  12. package/build/CMakeFiles/4.0.3/CompilerIdCXX/a.out +0 -0
  13. package/build/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
  14. package/build/CMakeFiles/CMakeConfigureLog.yaml +2146 -0
  15. package/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  16. package/build/CMakeFiles/InstallScripts.json +9 -0
  17. package/build/CMakeFiles/Makefile.cmake +100 -0
  18. package/build/CMakeFiles/Makefile2 +720 -0
  19. package/build/CMakeFiles/TargetDirectories.txt +23 -0
  20. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/DependInfo.cmake +23 -0
  21. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/build.make +114 -0
  22. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/cmake_clean.cmake +11 -0
  23. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.internal +839 -0
  24. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.make +2506 -0
  25. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/compiler_depend.ts +2 -0
  26. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/depend.make +2 -0
  27. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/flags.make +10 -0
  28. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/link.txt +1 -0
  29. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/progress.make +3 -0
  30. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp.o +0 -0
  31. package/build/CMakeFiles/avl-rb-range-search-benchmark.dir/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp.o.d +835 -0
  32. package/build/CMakeFiles/avl-tree-benchmark.dir/DependInfo.cmake +23 -0
  33. package/build/CMakeFiles/avl-tree-benchmark.dir/build.make +114 -0
  34. package/build/CMakeFiles/avl-tree-benchmark.dir/cmake_clean.cmake +11 -0
  35. package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.internal +839 -0
  36. package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.make +2506 -0
  37. package/build/CMakeFiles/avl-tree-benchmark.dir/compiler_depend.ts +2 -0
  38. package/build/CMakeFiles/avl-tree-benchmark.dir/depend.make +2 -0
  39. package/build/CMakeFiles/avl-tree-benchmark.dir/flags.make +10 -0
  40. package/build/CMakeFiles/avl-tree-benchmark.dir/link.txt +1 -0
  41. package/build/CMakeFiles/avl-tree-benchmark.dir/progress.make +3 -0
  42. package/build/CMakeFiles/avl-tree-benchmark.dir/test/performance/data-structures/binary-tree/avl-tree.test.cpp.o +0 -0
  43. package/build/CMakeFiles/avl-tree-benchmark.dir/test/performance/data-structures/binary-tree/avl-tree.test.cpp.o.d +835 -0
  44. package/build/CMakeFiles/cmake.check_cache +1 -0
  45. package/build/CMakeFiles/deque-benchmark.dir/DependInfo.cmake +23 -0
  46. package/build/CMakeFiles/deque-benchmark.dir/build.make +114 -0
  47. package/build/CMakeFiles/deque-benchmark.dir/cmake_clean.cmake +11 -0
  48. package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.internal +791 -0
  49. package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.make +2362 -0
  50. package/build/CMakeFiles/deque-benchmark.dir/compiler_depend.ts +2 -0
  51. package/build/CMakeFiles/deque-benchmark.dir/depend.make +2 -0
  52. package/build/CMakeFiles/deque-benchmark.dir/flags.make +10 -0
  53. package/build/CMakeFiles/deque-benchmark.dir/link.txt +1 -0
  54. package/build/CMakeFiles/deque-benchmark.dir/progress.make +3 -0
  55. package/build/CMakeFiles/deque-benchmark.dir/test/performance/data-structures/queue/deque.test.cpp.o +0 -0
  56. package/build/CMakeFiles/deque-benchmark.dir/test/performance/data-structures/queue/deque.test.cpp.o.d +787 -0
  57. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/DependInfo.cmake +23 -0
  58. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/build.make +114 -0
  59. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/cmake_clean.cmake +11 -0
  60. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.internal +790 -0
  61. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.make +2359 -0
  62. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/compiler_depend.ts +2 -0
  63. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/depend.make +2 -0
  64. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/flags.make +10 -0
  65. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/link.txt +1 -0
  66. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/progress.make +3 -0
  67. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp.o +0 -0
  68. package/build/CMakeFiles/doubly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp.o.d +786 -0
  69. package/build/CMakeFiles/hash-map-benchmark.dir/DependInfo.cmake +23 -0
  70. package/build/CMakeFiles/hash-map-benchmark.dir/build.make +114 -0
  71. package/build/CMakeFiles/hash-map-benchmark.dir/cmake_clean.cmake +11 -0
  72. package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.internal +790 -0
  73. package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.make +2359 -0
  74. package/build/CMakeFiles/hash-map-benchmark.dir/compiler_depend.ts +2 -0
  75. package/build/CMakeFiles/hash-map-benchmark.dir/depend.make +2 -0
  76. package/build/CMakeFiles/hash-map-benchmark.dir/flags.make +10 -0
  77. package/build/CMakeFiles/hash-map-benchmark.dir/link.txt +1 -0
  78. package/build/CMakeFiles/hash-map-benchmark.dir/progress.make +3 -0
  79. package/build/CMakeFiles/hash-map-benchmark.dir/test/performance/data-structures/hash/hash-map.test.cpp.o +0 -0
  80. package/build/CMakeFiles/hash-map-benchmark.dir/test/performance/data-structures/hash/hash-map.test.cpp.o.d +786 -0
  81. package/build/CMakeFiles/heap-benchmark.dir/DependInfo.cmake +23 -0
  82. package/build/CMakeFiles/heap-benchmark.dir/build.make +114 -0
  83. package/build/CMakeFiles/heap-benchmark.dir/cmake_clean.cmake +11 -0
  84. package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.internal +843 -0
  85. package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.make +2518 -0
  86. package/build/CMakeFiles/heap-benchmark.dir/compiler_depend.ts +2 -0
  87. package/build/CMakeFiles/heap-benchmark.dir/depend.make +2 -0
  88. package/build/CMakeFiles/heap-benchmark.dir/flags.make +10 -0
  89. package/build/CMakeFiles/heap-benchmark.dir/link.txt +1 -0
  90. package/build/CMakeFiles/heap-benchmark.dir/progress.make +3 -0
  91. package/build/CMakeFiles/heap-benchmark.dir/test/performance/data-structures/heap/heap.test.cpp.o +0 -0
  92. package/build/CMakeFiles/heap-benchmark.dir/test/performance/data-structures/heap/heap.test.cpp.o.d +839 -0
  93. package/build/CMakeFiles/priority-queue-benchmark.dir/DependInfo.cmake +23 -0
  94. package/build/CMakeFiles/priority-queue-benchmark.dir/build.make +114 -0
  95. package/build/CMakeFiles/priority-queue-benchmark.dir/cmake_clean.cmake +11 -0
  96. package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.internal +793 -0
  97. package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.make +2368 -0
  98. package/build/CMakeFiles/priority-queue-benchmark.dir/compiler_depend.ts +2 -0
  99. package/build/CMakeFiles/priority-queue-benchmark.dir/depend.make +2 -0
  100. package/build/CMakeFiles/priority-queue-benchmark.dir/flags.make +10 -0
  101. package/build/CMakeFiles/priority-queue-benchmark.dir/link.txt +1 -0
  102. package/build/CMakeFiles/priority-queue-benchmark.dir/progress.make +3 -0
  103. package/build/CMakeFiles/priority-queue-benchmark.dir/test/performance/data-structures/priority-queue/priority-queue.test.cpp.o +0 -0
  104. package/build/CMakeFiles/priority-queue-benchmark.dir/test/performance/data-structures/priority-queue/priority-queue.test.cpp.o.d +789 -0
  105. package/build/CMakeFiles/progress.marks +1 -0
  106. package/build/CMakeFiles/queue-benchmark.dir/DependInfo.cmake +23 -0
  107. package/build/CMakeFiles/queue-benchmark.dir/build.make +114 -0
  108. package/build/CMakeFiles/queue-benchmark.dir/cmake_clean.cmake +11 -0
  109. package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.internal +793 -0
  110. package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.make +2368 -0
  111. package/build/CMakeFiles/queue-benchmark.dir/compiler_depend.ts +2 -0
  112. package/build/CMakeFiles/queue-benchmark.dir/depend.make +2 -0
  113. package/build/CMakeFiles/queue-benchmark.dir/flags.make +10 -0
  114. package/build/CMakeFiles/queue-benchmark.dir/link.txt +1 -0
  115. package/build/CMakeFiles/queue-benchmark.dir/progress.make +3 -0
  116. package/build/CMakeFiles/queue-benchmark.dir/test/performance/data-structures/queue/queue.test.cpp.o +0 -0
  117. package/build/CMakeFiles/queue-benchmark.dir/test/performance/data-structures/queue/queue.test.cpp.o.d +789 -0
  118. package/build/CMakeFiles/red-black-tree-benchmark.dir/DependInfo.cmake +23 -0
  119. package/build/CMakeFiles/red-black-tree-benchmark.dir/build.make +114 -0
  120. package/build/CMakeFiles/red-black-tree-benchmark.dir/cmake_clean.cmake +11 -0
  121. package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.internal +839 -0
  122. package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.make +2506 -0
  123. package/build/CMakeFiles/red-black-tree-benchmark.dir/compiler_depend.ts +2 -0
  124. package/build/CMakeFiles/red-black-tree-benchmark.dir/depend.make +2 -0
  125. package/build/CMakeFiles/red-black-tree-benchmark.dir/flags.make +10 -0
  126. package/build/CMakeFiles/red-black-tree-benchmark.dir/link.txt +1 -0
  127. package/build/CMakeFiles/red-black-tree-benchmark.dir/progress.make +3 -0
  128. package/build/CMakeFiles/red-black-tree-benchmark.dir/test/performance/data-structures/binary-tree/red-black-tree.test.cpp.o +0 -0
  129. package/build/CMakeFiles/red-black-tree-benchmark.dir/test/performance/data-structures/binary-tree/red-black-tree.test.cpp.o.d +835 -0
  130. package/build/CMakeFiles/singly-linked-list-benchmark.dir/DependInfo.cmake +23 -0
  131. package/build/CMakeFiles/singly-linked-list-benchmark.dir/build.make +114 -0
  132. package/build/CMakeFiles/singly-linked-list-benchmark.dir/cmake_clean.cmake +11 -0
  133. package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.internal +790 -0
  134. package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.make +2359 -0
  135. package/build/CMakeFiles/singly-linked-list-benchmark.dir/compiler_depend.ts +2 -0
  136. package/build/CMakeFiles/singly-linked-list-benchmark.dir/depend.make +2 -0
  137. package/build/CMakeFiles/singly-linked-list-benchmark.dir/flags.make +10 -0
  138. package/build/CMakeFiles/singly-linked-list-benchmark.dir/link.txt +1 -0
  139. package/build/CMakeFiles/singly-linked-list-benchmark.dir/progress.make +3 -0
  140. package/build/CMakeFiles/singly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/singly-linked-list.test.cpp.o +0 -0
  141. package/build/CMakeFiles/singly-linked-list-benchmark.dir/test/performance/data-structures/linked-list/singly-linked-list.test.cpp.o.d +786 -0
  142. package/build/CMakeFiles/stack-benchmark.dir/DependInfo.cmake +23 -0
  143. package/build/CMakeFiles/stack-benchmark.dir/build.make +114 -0
  144. package/build/CMakeFiles/stack-benchmark.dir/cmake_clean.cmake +11 -0
  145. package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.internal +793 -0
  146. package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.make +2368 -0
  147. package/build/CMakeFiles/stack-benchmark.dir/compiler_depend.ts +2 -0
  148. package/build/CMakeFiles/stack-benchmark.dir/depend.make +2 -0
  149. package/build/CMakeFiles/stack-benchmark.dir/flags.make +10 -0
  150. package/build/CMakeFiles/stack-benchmark.dir/link.txt +1 -0
  151. package/build/CMakeFiles/stack-benchmark.dir/progress.make +3 -0
  152. package/build/CMakeFiles/stack-benchmark.dir/test/performance/data-structures/stack/stack.test.cpp.o +0 -0
  153. package/build/CMakeFiles/stack-benchmark.dir/test/performance/data-structures/stack/stack.test.cpp.o.d +789 -0
  154. package/build/CMakeFiles/tree-map-benchmark.dir/DependInfo.cmake +23 -0
  155. package/build/CMakeFiles/tree-map-benchmark.dir/build.make +114 -0
  156. package/build/CMakeFiles/tree-map-benchmark.dir/cmake_clean.cmake +11 -0
  157. package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.internal +839 -0
  158. package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.make +2506 -0
  159. package/build/CMakeFiles/tree-map-benchmark.dir/compiler_depend.ts +2 -0
  160. package/build/CMakeFiles/tree-map-benchmark.dir/depend.make +2 -0
  161. package/build/CMakeFiles/tree-map-benchmark.dir/flags.make +10 -0
  162. package/build/CMakeFiles/tree-map-benchmark.dir/link.txt +1 -0
  163. package/build/CMakeFiles/tree-map-benchmark.dir/progress.make +3 -0
  164. package/build/CMakeFiles/tree-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-map.test.cpp.o +0 -0
  165. package/build/CMakeFiles/tree-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-map.test.cpp.o.d +835 -0
  166. package/build/CMakeFiles/tree-multi-map-benchmark.dir/DependInfo.cmake +23 -0
  167. package/build/CMakeFiles/tree-multi-map-benchmark.dir/build.make +114 -0
  168. package/build/CMakeFiles/tree-multi-map-benchmark.dir/cmake_clean.cmake +11 -0
  169. package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.internal +839 -0
  170. package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.make +2506 -0
  171. package/build/CMakeFiles/tree-multi-map-benchmark.dir/compiler_depend.ts +2 -0
  172. package/build/CMakeFiles/tree-multi-map-benchmark.dir/depend.make +2 -0
  173. package/build/CMakeFiles/tree-multi-map-benchmark.dir/flags.make +10 -0
  174. package/build/CMakeFiles/tree-multi-map-benchmark.dir/link.txt +1 -0
  175. package/build/CMakeFiles/tree-multi-map-benchmark.dir/progress.make +3 -0
  176. package/build/CMakeFiles/tree-multi-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp.o +0 -0
  177. package/build/CMakeFiles/tree-multi-map-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp.o.d +835 -0
  178. package/build/CMakeFiles/tree-multi-set-benchmark.dir/DependInfo.cmake +23 -0
  179. package/build/CMakeFiles/tree-multi-set-benchmark.dir/build.make +114 -0
  180. package/build/CMakeFiles/tree-multi-set-benchmark.dir/cmake_clean.cmake +11 -0
  181. package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.internal +839 -0
  182. package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.make +2506 -0
  183. package/build/CMakeFiles/tree-multi-set-benchmark.dir/compiler_depend.ts +2 -0
  184. package/build/CMakeFiles/tree-multi-set-benchmark.dir/depend.make +2 -0
  185. package/build/CMakeFiles/tree-multi-set-benchmark.dir/flags.make +10 -0
  186. package/build/CMakeFiles/tree-multi-set-benchmark.dir/link.txt +1 -0
  187. package/build/CMakeFiles/tree-multi-set-benchmark.dir/progress.make +3 -0
  188. package/build/CMakeFiles/tree-multi-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp.o +0 -0
  189. package/build/CMakeFiles/tree-multi-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp.o.d +835 -0
  190. package/build/CMakeFiles/tree-set-benchmark.dir/DependInfo.cmake +23 -0
  191. package/build/CMakeFiles/tree-set-benchmark.dir/build.make +114 -0
  192. package/build/CMakeFiles/tree-set-benchmark.dir/cmake_clean.cmake +11 -0
  193. package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.internal +839 -0
  194. package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.make +2506 -0
  195. package/build/CMakeFiles/tree-set-benchmark.dir/compiler_depend.ts +2 -0
  196. package/build/CMakeFiles/tree-set-benchmark.dir/depend.make +2 -0
  197. package/build/CMakeFiles/tree-set-benchmark.dir/flags.make +10 -0
  198. package/build/CMakeFiles/tree-set-benchmark.dir/link.txt +1 -0
  199. package/build/CMakeFiles/tree-set-benchmark.dir/progress.make +3 -0
  200. package/build/CMakeFiles/tree-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-set.test.cpp.o +0 -0
  201. package/build/CMakeFiles/tree-set-benchmark.dir/test/performance/data-structures/binary-tree/tree-set.test.cpp.o.d +835 -0
  202. package/build/Makefile +783 -0
  203. package/build/_deps/benchmark-build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  204. package/build/_deps/benchmark-build/CMakeFiles/progress.marks +1 -0
  205. package/build/_deps/benchmark-build/Makefile +140 -0
  206. package/build/_deps/benchmark-build/benchmark.pc +12 -0
  207. package/build/_deps/benchmark-build/benchmarkConfig.cmake +14 -0
  208. package/build/_deps/benchmark-build/benchmarkConfigVersion.cmake +65 -0
  209. package/build/_deps/benchmark-build/benchmarkTargets.cmake +84 -0
  210. package/build/_deps/benchmark-build/cmake_install.cmake +50 -0
  211. package/build/_deps/benchmark-build/src/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  212. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/DependInfo.cmake +41 -0
  213. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark.cc.o +0 -0
  214. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark.cc.o.d +875 -0
  215. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_api_internal.cc.o +0 -0
  216. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_api_internal.cc.o.d +802 -0
  217. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_name.cc.o +0 -0
  218. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_name.cc.o.d +772 -0
  219. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o +0 -0
  220. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o.d +841 -0
  221. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_runner.cc.o +0 -0
  222. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/benchmark_runner.cc.o.d +833 -0
  223. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/build.make +402 -0
  224. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/check.cc.o +0 -0
  225. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/check.cc.o.d +784 -0
  226. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/cmake_clean.cmake +47 -0
  227. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/cmake_clean_target.cmake +3 -0
  228. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/colorprint.cc.o +0 -0
  229. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/colorprint.cc.o.d +791 -0
  230. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/commandlineflags.cc.o +0 -0
  231. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/commandlineflags.cc.o.d +795 -0
  232. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.internal +15519 -0
  233. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.make +17500 -0
  234. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/compiler_depend.ts +2 -0
  235. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/complexity.cc.o +0 -0
  236. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/complexity.cc.o.d +793 -0
  237. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/console_reporter.cc.o +0 -0
  238. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/console_reporter.cc.o.d +802 -0
  239. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/counter.cc.o +0 -0
  240. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/counter.cc.o.d +773 -0
  241. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/csv_reporter.cc.o +0 -0
  242. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/csv_reporter.cc.o.d +799 -0
  243. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/depend.make +2 -0
  244. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/flags.make +10 -0
  245. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/json_reporter.cc.o +0 -0
  246. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/json_reporter.cc.o.d +800 -0
  247. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/link.txt +2 -0
  248. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/perf_counters.cc.o +0 -0
  249. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/perf_counters.cc.o.d +807 -0
  250. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/progress.make +21 -0
  251. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/reporter.cc.o +0 -0
  252. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/reporter.cc.o.d +798 -0
  253. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/statistics.cc.o +0 -0
  254. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/statistics.cc.o.d +800 -0
  255. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/string_util.cc.o +0 -0
  256. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/string_util.cc.o.d +795 -0
  257. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/sysinfo.cc.o +0 -0
  258. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/sysinfo.cc.o.d +933 -0
  259. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/timers.cc.o +0 -0
  260. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark.dir/timers.cc.o.d +904 -0
  261. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/DependInfo.cmake +23 -0
  262. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o +0 -0
  263. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o.d +772 -0
  264. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/build.make +114 -0
  265. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/cmake_clean.cmake +11 -0
  266. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/cmake_clean_target.cmake +3 -0
  267. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.internal +776 -0
  268. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.make +2317 -0
  269. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/compiler_depend.ts +2 -0
  270. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/depend.make +2 -0
  271. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/flags.make +10 -0
  272. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/link.txt +2 -0
  273. package/build/_deps/benchmark-build/src/CMakeFiles/benchmark_main.dir/progress.make +3 -0
  274. package/build/_deps/benchmark-build/src/CMakeFiles/progress.marks +1 -0
  275. package/build/_deps/benchmark-build/src/Makefile +710 -0
  276. package/build/_deps/benchmark-build/src/cmake_install.cmake +45 -0
  277. package/build/_deps/benchmark-build/src/libbenchmark.a +0 -0
  278. package/build/_deps/benchmark-build/src/libbenchmark_main.a +0 -0
  279. package/build/_deps/benchmark-src/.clang-format +5 -0
  280. package/build/_deps/benchmark-src/.clang-tidy +7 -0
  281. package/build/_deps/benchmark-src/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  282. package/build/_deps/benchmark-src/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  283. package/build/_deps/benchmark-src/.github/install_bazel.sh +13 -0
  284. package/build/_deps/benchmark-src/.github/libcxx-setup.sh +26 -0
  285. package/build/_deps/benchmark-src/.github/workflows/bazel.yml +35 -0
  286. package/build/_deps/benchmark-src/.github/workflows/build-and-test-min-cmake.yml +46 -0
  287. package/build/_deps/benchmark-src/.github/workflows/build-and-test-perfcounters.yml +51 -0
  288. package/build/_deps/benchmark-src/.github/workflows/build-and-test.yml +114 -0
  289. package/build/_deps/benchmark-src/.github/workflows/clang-format-lint.yml +17 -0
  290. package/build/_deps/benchmark-src/.github/workflows/clang-tidy.yml +38 -0
  291. package/build/_deps/benchmark-src/.github/workflows/doxygen.yml +28 -0
  292. package/build/_deps/benchmark-src/.github/workflows/pylint.yml +28 -0
  293. package/build/_deps/benchmark-src/.github/workflows/sanitizer.yml +96 -0
  294. package/build/_deps/benchmark-src/.github/workflows/test_bindings.yml +29 -0
  295. package/build/_deps/benchmark-src/.github/workflows/wheels.yml +79 -0
  296. package/build/_deps/benchmark-src/.travis.yml +208 -0
  297. package/build/_deps/benchmark-src/.ycm_extra_conf.py +115 -0
  298. package/build/_deps/benchmark-src/AUTHORS +71 -0
  299. package/build/_deps/benchmark-src/BUILD.bazel +87 -0
  300. package/build/_deps/benchmark-src/CMakeLists.txt +340 -0
  301. package/build/_deps/benchmark-src/CONTRIBUTING.md +58 -0
  302. package/build/_deps/benchmark-src/CONTRIBUTORS +95 -0
  303. package/build/_deps/benchmark-src/LICENSE +202 -0
  304. package/build/_deps/benchmark-src/MODULE.bazel +24 -0
  305. package/build/_deps/benchmark-src/README.md +223 -0
  306. package/build/_deps/benchmark-src/WORKSPACE +22 -0
  307. package/build/_deps/benchmark-src/WORKSPACE.bzlmod +2 -0
  308. package/build/_deps/benchmark-src/_config.yml +2 -0
  309. package/build/_deps/benchmark-src/appveyor.yml +50 -0
  310. package/build/_deps/benchmark-src/bazel/benchmark_deps.bzl +65 -0
  311. package/build/_deps/benchmark-src/bindings/python/BUILD +3 -0
  312. package/build/_deps/benchmark-src/bindings/python/build_defs.bzl +25 -0
  313. package/build/_deps/benchmark-src/bindings/python/google_benchmark/BUILD +40 -0
  314. package/build/_deps/benchmark-src/bindings/python/google_benchmark/__init__.py +162 -0
  315. package/build/_deps/benchmark-src/bindings/python/google_benchmark/benchmark.cc +184 -0
  316. package/build/_deps/benchmark-src/bindings/python/google_benchmark/example.py +136 -0
  317. package/build/_deps/benchmark-src/bindings/python/nanobind.BUILD +17 -0
  318. package/build/_deps/benchmark-src/bindings/python/python_headers.BUILD +6 -0
  319. package/build/_deps/benchmark-src/cmake/AddCXXCompilerFlag.cmake +78 -0
  320. package/build/_deps/benchmark-src/cmake/CXXFeatureCheck.cmake +82 -0
  321. package/build/_deps/benchmark-src/cmake/Config.cmake.in +7 -0
  322. package/build/_deps/benchmark-src/cmake/GetGitVersion.cmake +58 -0
  323. package/build/_deps/benchmark-src/cmake/GoogleTest.cmake +58 -0
  324. package/build/_deps/benchmark-src/cmake/GoogleTest.cmake.in +59 -0
  325. package/build/_deps/benchmark-src/cmake/benchmark.pc.in +12 -0
  326. package/build/_deps/benchmark-src/cmake/gnu_posix_regex.cpp +12 -0
  327. package/build/_deps/benchmark-src/cmake/llvm-toolchain.cmake +8 -0
  328. package/build/_deps/benchmark-src/cmake/posix_regex.cpp +14 -0
  329. package/build/_deps/benchmark-src/cmake/pthread_affinity.cpp +16 -0
  330. package/build/_deps/benchmark-src/cmake/split_list.cmake +3 -0
  331. package/build/_deps/benchmark-src/cmake/std_regex.cpp +10 -0
  332. package/build/_deps/benchmark-src/cmake/steady_clock.cpp +7 -0
  333. package/build/_deps/benchmark-src/cmake/thread_safety_attributes.cpp +4 -0
  334. package/build/_deps/benchmark-src/docs/AssemblyTests.md +149 -0
  335. package/build/_deps/benchmark-src/docs/_config.yml +3 -0
  336. package/build/_deps/benchmark-src/docs/assets/images/icon.png +0 -0
  337. package/build/_deps/benchmark-src/docs/assets/images/icon.xcf +0 -0
  338. package/build/_deps/benchmark-src/docs/assets/images/icon_black.png +0 -0
  339. package/build/_deps/benchmark-src/docs/assets/images/icon_black.xcf +0 -0
  340. package/build/_deps/benchmark-src/docs/dependencies.md +13 -0
  341. package/build/_deps/benchmark-src/docs/index.md +12 -0
  342. package/build/_deps/benchmark-src/docs/perf_counters.md +35 -0
  343. package/build/_deps/benchmark-src/docs/platform_specific_build_instructions.md +48 -0
  344. package/build/_deps/benchmark-src/docs/python_bindings.md +34 -0
  345. package/build/_deps/benchmark-src/docs/random_interleaving.md +13 -0
  346. package/build/_deps/benchmark-src/docs/reducing_variance.md +100 -0
  347. package/build/_deps/benchmark-src/docs/releasing.md +41 -0
  348. package/build/_deps/benchmark-src/docs/tools.md +343 -0
  349. package/build/_deps/benchmark-src/docs/user_guide.md +1266 -0
  350. package/build/_deps/benchmark-src/include/benchmark/benchmark.h +1991 -0
  351. package/build/_deps/benchmark-src/include/benchmark/export.h +47 -0
  352. package/build/_deps/benchmark-src/pyproject.toml +50 -0
  353. package/build/_deps/benchmark-src/setup.py +113 -0
  354. package/build/_deps/benchmark-src/src/CMakeLists.txt +170 -0
  355. package/build/_deps/benchmark-src/src/arraysize.h +33 -0
  356. package/build/_deps/benchmark-src/src/benchmark.cc +779 -0
  357. package/build/_deps/benchmark-src/src/benchmark_api_internal.cc +118 -0
  358. package/build/_deps/benchmark-src/src/benchmark_api_internal.h +87 -0
  359. package/build/_deps/benchmark-src/src/benchmark_main.cc +18 -0
  360. package/build/_deps/benchmark-src/src/benchmark_name.cc +59 -0
  361. package/build/_deps/benchmark-src/src/benchmark_register.cc +520 -0
  362. package/build/_deps/benchmark-src/src/benchmark_register.h +109 -0
  363. package/build/_deps/benchmark-src/src/benchmark_runner.cc +497 -0
  364. package/build/_deps/benchmark-src/src/benchmark_runner.h +131 -0
  365. package/build/_deps/benchmark-src/src/check.cc +11 -0
  366. package/build/_deps/benchmark-src/src/check.h +106 -0
  367. package/build/_deps/benchmark-src/src/colorprint.cc +200 -0
  368. package/build/_deps/benchmark-src/src/colorprint.h +33 -0
  369. package/build/_deps/benchmark-src/src/commandlineflags.cc +298 -0
  370. package/build/_deps/benchmark-src/src/commandlineflags.h +133 -0
  371. package/build/_deps/benchmark-src/src/complexity.cc +244 -0
  372. package/build/_deps/benchmark-src/src/complexity.h +55 -0
  373. package/build/_deps/benchmark-src/src/console_reporter.cc +206 -0
  374. package/build/_deps/benchmark-src/src/counter.cc +80 -0
  375. package/build/_deps/benchmark-src/src/counter.h +32 -0
  376. package/build/_deps/benchmark-src/src/csv_reporter.cc +161 -0
  377. package/build/_deps/benchmark-src/src/cycleclock.h +230 -0
  378. package/build/_deps/benchmark-src/src/internal_macros.h +115 -0
  379. package/build/_deps/benchmark-src/src/json_reporter.cc +320 -0
  380. package/build/_deps/benchmark-src/src/log.h +88 -0
  381. package/build/_deps/benchmark-src/src/mutex.h +155 -0
  382. package/build/_deps/benchmark-src/src/perf_counters.cc +282 -0
  383. package/build/_deps/benchmark-src/src/perf_counters.h +200 -0
  384. package/build/_deps/benchmark-src/src/re.h +158 -0
  385. package/build/_deps/benchmark-src/src/reporter.cc +118 -0
  386. package/build/_deps/benchmark-src/src/statistics.cc +209 -0
  387. package/build/_deps/benchmark-src/src/statistics.h +44 -0
  388. package/build/_deps/benchmark-src/src/string_util.cc +254 -0
  389. package/build/_deps/benchmark-src/src/string_util.h +70 -0
  390. package/build/_deps/benchmark-src/src/sysinfo.cc +855 -0
  391. package/build/_deps/benchmark-src/src/thread_manager.h +63 -0
  392. package/build/_deps/benchmark-src/src/thread_timer.h +86 -0
  393. package/build/_deps/benchmark-src/src/timers.cc +272 -0
  394. package/build/_deps/benchmark-src/src/timers.h +48 -0
  395. package/build/_deps/benchmark-src/test/AssemblyTests.cmake +67 -0
  396. package/build/_deps/benchmark-src/test/BUILD +127 -0
  397. package/build/_deps/benchmark-src/test/CMakeLists.txt +309 -0
  398. package/build/_deps/benchmark-src/test/args_product_test.cc +77 -0
  399. package/build/_deps/benchmark-src/test/basic_test.cc +180 -0
  400. package/build/_deps/benchmark-src/test/benchmark_gtest.cc +169 -0
  401. package/build/_deps/benchmark-src/test/benchmark_min_time_flag_iters_test.cc +66 -0
  402. package/build/_deps/benchmark-src/test/benchmark_min_time_flag_time_test.cc +90 -0
  403. package/build/_deps/benchmark-src/test/benchmark_name_gtest.cc +82 -0
  404. package/build/_deps/benchmark-src/test/benchmark_random_interleaving_gtest.cc +126 -0
  405. package/build/_deps/benchmark-src/test/benchmark_setup_teardown_test.cc +157 -0
  406. package/build/_deps/benchmark-src/test/benchmark_test.cc +274 -0
  407. package/build/_deps/benchmark-src/test/clobber_memory_assembly_test.cc +64 -0
  408. package/build/_deps/benchmark-src/test/commandlineflags_gtest.cc +228 -0
  409. package/build/_deps/benchmark-src/test/complexity_test.cc +228 -0
  410. package/build/_deps/benchmark-src/test/cxx03_test.cc +62 -0
  411. package/build/_deps/benchmark-src/test/diagnostics_test.cc +91 -0
  412. package/build/_deps/benchmark-src/test/display_aggregates_only_test.cc +45 -0
  413. package/build/_deps/benchmark-src/test/donotoptimize_assembly_test.cc +201 -0
  414. package/build/_deps/benchmark-src/test/donotoptimize_test.cc +69 -0
  415. package/build/_deps/benchmark-src/test/filter_test.cc +117 -0
  416. package/build/_deps/benchmark-src/test/fixture_test.cc +51 -0
  417. package/build/_deps/benchmark-src/test/internal_threading_test.cc +185 -0
  418. package/build/_deps/benchmark-src/test/link_main_test.cc +9 -0
  419. package/build/_deps/benchmark-src/test/map_test.cc +59 -0
  420. package/build/_deps/benchmark-src/test/memory_manager_test.cc +47 -0
  421. package/build/_deps/benchmark-src/test/min_time_parse_gtest.cc +30 -0
  422. package/build/_deps/benchmark-src/test/multiple_ranges_test.cc +96 -0
  423. package/build/_deps/benchmark-src/test/options_test.cc +77 -0
  424. package/build/_deps/benchmark-src/test/output_test.h +211 -0
  425. package/build/_deps/benchmark-src/test/output_test_helper.cc +519 -0
  426. package/build/_deps/benchmark-src/test/perf_counters_gtest.cc +307 -0
  427. package/build/_deps/benchmark-src/test/perf_counters_test.cc +92 -0
  428. package/build/_deps/benchmark-src/test/register_benchmark_test.cc +196 -0
  429. package/build/_deps/benchmark-src/test/repetitions_test.cc +214 -0
  430. package/build/_deps/benchmark-src/test/report_aggregates_only_test.cc +41 -0
  431. package/build/_deps/benchmark-src/test/reporter_output_test.cc +1130 -0
  432. package/build/_deps/benchmark-src/test/skip_with_error_test.cc +199 -0
  433. package/build/_deps/benchmark-src/test/spec_arg_test.cc +105 -0
  434. package/build/_deps/benchmark-src/test/spec_arg_verbosity_test.cc +43 -0
  435. package/build/_deps/benchmark-src/test/state_assembly_test.cc +68 -0
  436. package/build/_deps/benchmark-src/test/statistics_gtest.cc +35 -0
  437. package/build/_deps/benchmark-src/test/string_util_gtest.cc +199 -0
  438. package/build/_deps/benchmark-src/test/templated_fixture_test.cc +28 -0
  439. package/build/_deps/benchmark-src/test/time_unit_gtest.cc +37 -0
  440. package/build/_deps/benchmark-src/test/user_counters_tabular_test.cc +558 -0
  441. package/build/_deps/benchmark-src/test/user_counters_test.cc +561 -0
  442. package/build/_deps/benchmark-src/test/user_counters_thousands_test.cc +186 -0
  443. package/build/_deps/benchmark-src/tools/BUILD.bazel +19 -0
  444. package/build/_deps/benchmark-src/tools/compare.py +432 -0
  445. package/build/_deps/benchmark-src/tools/gbench/Inputs/test1_run1.json +127 -0
  446. package/build/_deps/benchmark-src/tools/gbench/Inputs/test1_run2.json +127 -0
  447. package/build/_deps/benchmark-src/tools/gbench/Inputs/test2_run.json +81 -0
  448. package/build/_deps/benchmark-src/tools/gbench/Inputs/test3_run0.json +65 -0
  449. package/build/_deps/benchmark-src/tools/gbench/Inputs/test3_run1.json +65 -0
  450. package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run.json +96 -0
  451. package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run0.json +21 -0
  452. package/build/_deps/benchmark-src/tools/gbench/Inputs/test4_run1.json +21 -0
  453. package/build/_deps/benchmark-src/tools/gbench/__init__.py +8 -0
  454. package/build/_deps/benchmark-src/tools/gbench/report.py +1201 -0
  455. package/build/_deps/benchmark-src/tools/gbench/util.py +203 -0
  456. package/build/_deps/benchmark-src/tools/libpfm.BUILD.bazel +22 -0
  457. package/build/_deps/benchmark-src/tools/requirements.txt +2 -0
  458. package/build/_deps/benchmark-src/tools/strip_asm.py +151 -0
  459. package/build/_deps/benchmark-subbuild/CMakeCache.txt +133 -0
  460. package/build/_deps/benchmark-subbuild/CMakeFiles/4.0.3/CMakeSystem.cmake +15 -0
  461. package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeConfigureLog.yaml +11 -0
  462. package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  463. package/build/_deps/benchmark-subbuild/CMakeFiles/CMakeRuleHashes.txt +11 -0
  464. package/build/_deps/benchmark-subbuild/CMakeFiles/InstallScripts.json +7 -0
  465. package/build/_deps/benchmark-subbuild/CMakeFiles/Makefile.cmake +52 -0
  466. package/build/_deps/benchmark-subbuild/CMakeFiles/Makefile2 +122 -0
  467. package/build/_deps/benchmark-subbuild/CMakeFiles/TargetDirectories.txt +3 -0
  468. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/DependInfo.cmake +22 -0
  469. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/Labels.json +46 -0
  470. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/Labels.txt +14 -0
  471. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/build.make +162 -0
  472. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/cmake_clean.cmake +17 -0
  473. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/compiler_depend.make +2 -0
  474. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/compiler_depend.ts +2 -0
  475. package/build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate.dir/progress.make +10 -0
  476. package/build/_deps/benchmark-subbuild/CMakeFiles/cmake.check_cache +1 -0
  477. package/build/_deps/benchmark-subbuild/CMakeFiles/progress.marks +1 -0
  478. package/build/_deps/benchmark-subbuild/CMakeLists.txt +42 -0
  479. package/build/_deps/benchmark-subbuild/Makefile +162 -0
  480. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-gitclone-lastrun.txt +15 -0
  481. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-gitinfo.txt +15 -0
  482. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-patch-info.txt +6 -0
  483. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-update-info.txt +7 -0
  484. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-cfgcmd.txt +1 -0
  485. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-gitclone.cmake +87 -0
  486. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-gitupdate.cmake +317 -0
  487. package/build/_deps/benchmark-subbuild/benchmark-populate-prefix/tmp/benchmark-populate-mkdirs.cmake +27 -0
  488. package/build/_deps/benchmark-subbuild/cmake_install.cmake +56 -0
  489. package/build/bin/avl-rb-range-search-benchmark +0 -0
  490. package/build/bin/avl-tree-benchmark +0 -0
  491. package/build/bin/deque-benchmark +0 -0
  492. package/build/bin/doubly-linked-list-benchmark +0 -0
  493. package/build/bin/hash-map-benchmark +0 -0
  494. package/build/bin/heap-benchmark +0 -0
  495. package/build/bin/priority-queue-benchmark +0 -0
  496. package/build/bin/queue-benchmark +0 -0
  497. package/build/bin/red-black-tree-benchmark +0 -0
  498. package/build/bin/singly-linked-list-benchmark +0 -0
  499. package/build/bin/stack-benchmark +0 -0
  500. package/build/bin/tree-map-benchmark +0 -0
  501. package/build/bin/tree-multi-map-benchmark +0 -0
  502. package/build/bin/tree-multi-set-benchmark +0 -0
  503. package/build/bin/tree-set-benchmark +0 -0
  504. package/build/cmake_install.cmake +66 -0
  505. package/dist/cjs/index.cjs +1270 -1201
  506. package/dist/cjs/index.cjs.map +1 -1
  507. package/dist/cjs-legacy/index.cjs +1309 -1210
  508. package/dist/cjs-legacy/index.cjs.map +1 -1
  509. package/dist/esm/index.mjs +1268 -1196
  510. package/dist/esm/index.mjs.map +1 -1
  511. package/dist/esm-legacy/index.mjs +1307 -1205
  512. package/dist/esm-legacy/index.mjs.map +1 -1
  513. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +3 -3
  514. package/dist/types/data-structures/binary-tree/index.d.ts +3 -3
  515. package/dist/types/data-structures/binary-tree/tree-map.d.ts +177 -0
  516. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +230 -147
  517. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +263 -0
  518. package/dist/types/data-structures/binary-tree/tree-set.d.ts +170 -0
  519. package/dist/types/interfaces/binary-tree.d.ts +1 -1
  520. package/dist/types/types/data-structures/binary-tree/index.d.ts +3 -3
  521. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +28 -0
  522. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +11 -0
  523. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +28 -0
  524. package/dist/umd/data-structure-typed.js +1303 -1194
  525. package/dist/umd/data-structure-typed.js.map +1 -1
  526. package/dist/umd/data-structure-typed.min.js +10 -3
  527. package/dist/umd/data-structure-typed.min.js.map +1 -1
  528. package/eslint.config.mjs +5 -1
  529. package/package.json +4 -3
  530. package/src/data-structures/binary-tree/avl-tree.ts +1 -1
  531. package/src/data-structures/binary-tree/binary-tree.ts +40 -16
  532. package/src/data-structures/binary-tree/bst.ts +6 -6
  533. package/src/data-structures/binary-tree/index.ts +3 -3
  534. package/src/data-structures/binary-tree/red-black-tree.ts +34 -52
  535. package/src/data-structures/binary-tree/tree-map.ts +417 -0
  536. package/src/data-structures/binary-tree/tree-multi-map.ts +467 -325
  537. package/src/data-structures/binary-tree/tree-multi-set.ts +491 -0
  538. package/src/data-structures/binary-tree/tree-set.ts +394 -0
  539. package/src/interfaces/binary-tree.ts +1 -1
  540. package/src/types/data-structures/binary-tree/index.ts +3 -3
  541. package/src/types/data-structures/binary-tree/tree-map.ts +39 -0
  542. package/src/types/data-structures/binary-tree/tree-multi-set.ts +13 -0
  543. package/src/types/data-structures/binary-tree/tree-set.ts +33 -0
  544. package/test/config.ts +2 -2
  545. package/test/performance/benchmark-runner-enhanced.mjs +818 -0
  546. package/test/performance/cmake-benchmark-runner.mjs +234 -0
  547. package/test/performance/data-structures/binary-tree/avl-rb-range-search.test.cpp +112 -0
  548. package/test/performance/data-structures/binary-tree/avl-rb-range-search.test.mjs +51 -0
  549. package/test/performance/data-structures/binary-tree/avl-tree.test.cpp +181 -0
  550. package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +138 -0
  551. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.mjs +85 -0
  552. package/test/performance/data-structures/binary-tree/binary-tree.test.mjs +100 -0
  553. package/test/performance/data-structures/binary-tree/bst.test.mjs +61 -0
  554. package/test/performance/data-structures/binary-tree/red-black-tree-cjs.test.mjs +259 -0
  555. package/test/performance/data-structures/binary-tree/red-black-tree.test.cpp +213 -0
  556. package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +275 -0
  557. package/test/performance/data-structures/binary-tree/tree-map.test.cpp +129 -0
  558. package/test/performance/data-structures/binary-tree/tree-map.test.mjs +171 -0
  559. package/test/performance/data-structures/binary-tree/tree-multi-map.test.cpp +205 -0
  560. package/test/performance/data-structures/binary-tree/tree-multi-map.test.mjs +106 -0
  561. package/test/performance/data-structures/binary-tree/tree-multi-set.test.cpp +217 -0
  562. package/test/performance/data-structures/binary-tree/tree-multi-set.test.mjs +91 -0
  563. package/test/performance/data-structures/binary-tree/tree-set.test.cpp +127 -0
  564. package/test/performance/data-structures/binary-tree/tree-set.test.mjs +174 -0
  565. package/test/performance/data-structures/comparison/{comparison.test.ts → comparison.test.mjs} +17 -17
  566. package/test/performance/data-structures/graph/{directed-graph.test.ts → directed-graph.test.mjs} +4 -4
  567. package/test/performance/data-structures/hash/hash-map.test.cpp +183 -0
  568. package/test/performance/data-structures/hash/hash-map.test.mjs +187 -0
  569. package/test/performance/data-structures/heap/heap.test.cpp +61 -0
  570. package/test/performance/data-structures/heap/heap.test.mjs +31 -0
  571. package/test/performance/data-structures/linked-list/doubly-linked-list.test.cpp +84 -0
  572. package/test/performance/data-structures/linked-list/doubly-linked-list.test.mjs +125 -0
  573. package/test/performance/data-structures/linked-list/singly-linked-list.test.cpp +77 -0
  574. package/test/performance/data-structures/linked-list/singly-linked-list.test.mjs +84 -0
  575. package/test/performance/data-structures/priority-queue/max-priority-queue.test.mjs +40 -0
  576. package/test/performance/data-structures/priority-queue/priority-queue.test.cpp +59 -0
  577. package/test/performance/data-structures/priority-queue/priority-queue.test.mjs +64 -0
  578. package/test/performance/data-structures/queue/deque.test.cpp +119 -0
  579. package/test/performance/data-structures/queue/deque.test.mjs +144 -0
  580. package/test/performance/data-structures/queue/queue.test.cpp +59 -0
  581. package/test/performance/data-structures/queue/queue.test.mjs +77 -0
  582. package/test/performance/data-structures/stack/stack.test.cpp +40 -0
  583. package/test/performance/data-structures/stack/stack.test.mjs +69 -0
  584. package/test/performance/data-structures/trie/trie.test.mjs +43 -0
  585. package/test/performance/reportor-enhanced.mjs +871 -0
  586. package/test/performance/runner-config.json +33 -21
  587. package/test/unit/data-structures/base/iterable-element-base.more-branches.coverage.test.ts +6 -6
  588. package/test/unit/data-structures/base/linear-base.array.coverage.test.ts +5 -5
  589. package/test/unit/data-structures/base/linear-base.concat-else.coverage.test.ts +10 -10
  590. package/test/unit/data-structures/base/linear-base.more-branches.coverage.test.ts +7 -10
  591. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +5 -5
  592. package/test/unit/data-structures/binary-tree/binary-tree.remaining-branches.coverage.test.ts +7 -4
  593. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +7 -7
  594. package/test/unit/data-structures/binary-tree/bst.more-branches-3.coverage.test.ts +1 -1
  595. package/test/unit/data-structures/binary-tree/bst.test.ts +4 -4
  596. package/test/unit/data-structures/binary-tree/overall.test.ts +18 -31
  597. package/test/unit/data-structures/binary-tree/red-black-tree.boundary-max-update.coverage.test.ts +1 -1
  598. package/test/unit/data-structures/binary-tree/red-black-tree.cache-stale-insert.coverage.test.ts +2 -2
  599. package/test/unit/data-structures/binary-tree/red-black-tree.hint-mapmode-defined.coverage.test.ts +4 -4
  600. package/test/unit/data-structures/binary-tree/red-black-tree.hint-mapmode-undefined.coverage.test.ts +5 -5
  601. package/test/unit/data-structures/binary-tree/red-black-tree.hint-more.coverage.test.ts +3 -3
  602. package/test/unit/data-structures/binary-tree/red-black-tree.remaining-branches.coverage.test.ts +2 -2
  603. package/test/unit/data-structures/binary-tree/red-black-tree.set-inputs.coverage.test.ts +1 -1
  604. package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-parent-cache.coverage.test.ts +1 -1
  605. package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-remaining.coverage.test.ts +4 -4
  606. package/test/unit/data-structures/binary-tree/red-black-tree.setkvnode-uncovered.coverage.test.ts +1 -1
  607. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +2 -2
  608. package/test/unit/data-structures/binary-tree/red-black-tree.update-branches.coverage.test.ts +4 -4
  609. package/test/unit/data-structures/binary-tree/tree-map.test.ts +270 -0
  610. package/test/unit/data-structures/binary-tree/tree-multi-map.coverage.test.ts +144 -3
  611. package/test/unit/data-structures/binary-tree/{tree-multi-map.test.ts → tree-multi-map.legacy.test.ts.skip} +16 -16
  612. package/test/unit/data-structures/binary-tree/tree-multi-map.rfc.test.ts +99 -0
  613. package/test/unit/data-structures/binary-tree/tree-multi-map.simplified.test.ts +482 -0
  614. package/test/unit/data-structures/binary-tree/tree-multi-set.test.ts +545 -0
  615. package/test/unit/data-structures/binary-tree/tree-set.test.ts +187 -0
  616. package/test/unit/unrestricted-interconversion.test.ts +12 -10
  617. package/test/utils/patch.ts +3 -3
  618. package/test/utils/perf.mjs +34 -0
  619. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -236
  620. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -197
  621. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +0 -243
  622. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +0 -2
  623. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -2
  624. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +0 -2
  625. package/src/data-structures/binary-tree/avl-tree-counter.ts +0 -539
  626. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +0 -438
  627. package/src/data-structures/binary-tree/tree-counter.ts +0 -587
  628. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +0 -3
  629. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +0 -3
  630. package/src/types/data-structures/binary-tree/tree-counter.ts +0 -3
  631. package/test/performance/benchmark-runner.ts +0 -531
  632. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +0 -40
  633. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +0 -37
  634. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +0 -40
  635. package/test/performance/data-structures/binary-tree/bst.test.ts +0 -28
  636. package/test/performance/data-structures/binary-tree/red-black-tree.test.ts +0 -60
  637. package/test/performance/data-structures/hash/hash-map.test.ts +0 -99
  638. package/test/performance/data-structures/heap/heap.test.ts +0 -26
  639. package/test/performance/data-structures/heap/min-heap.test.ts +0 -0
  640. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +0 -59
  641. package/test/performance/data-structures/linked-list/linked-list.test.ts +0 -0
  642. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +0 -35
  643. package/test/performance/data-structures/linked-list/skip-linked-list.test.ts +0 -0
  644. package/test/performance/data-structures/linked-list/skip-list.test.ts +0 -0
  645. package/test/performance/data-structures/matrix/matrix.test.ts +0 -0
  646. package/test/performance/data-structures/matrix/navigator.test.ts +0 -0
  647. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +0 -17
  648. package/test/performance/data-structures/priority-queue/min-priority-queue.test.ts +0 -0
  649. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +0 -34
  650. package/test/performance/data-structures/queue/deque.test.ts +0 -59
  651. package/test/performance/data-structures/queue/queue.test.ts +0 -35
  652. package/test/performance/data-structures/stack/stack.test.ts +0 -37
  653. package/test/performance/data-structures/trie/trie.test.ts +0 -18
  654. package/test/performance/reportor.ts +0 -279
  655. package/test/performance/single-suite-runner.ts +0 -72
  656. package/test/performance/types/index.ts +0 -1
  657. package/test/performance/types/reportor.ts +0 -7
  658. package/test/unit/data-structures/binary-tree/avl-tree-counter.more-branches-3.coverage.test.ts +0 -146
  659. package/test/unit/data-structures/binary-tree/avl-tree-counter.more-branches.coverage.test.ts +0 -93
  660. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +0 -878
  661. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.coverage.test.ts +0 -108
  662. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.more-branches-2.coverage.test.ts +0 -85
  663. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +0 -740
  664. package/test/unit/data-structures/binary-tree/tree-counter.coverage.test.ts +0 -115
  665. package/test/unit/data-structures/binary-tree/tree-counter.more-branches.coverage.test.ts +0 -244
  666. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +0 -979
  667. /package/{test/performance/data-structures/binary-tree/binary-index-tree.test.ts → build/_deps/benchmark-subbuild/CMakeFiles/benchmark-populate-complete} +0 -0
  668. /package/{test/performance/data-structures/binary-tree/segment-tree.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-build} +0 -0
  669. /package/{test/performance/data-structures/binary-tree/tree-multimap.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-configure} +0 -0
  670. /package/{test/performance/data-structures/graph/abstract-graph.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-done} +0 -0
  671. /package/{test/performance/data-structures/graph/map-graph.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-download} +0 -0
  672. /package/{test/performance/data-structures/graph/overall.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-install} +0 -0
  673. /package/{test/performance/data-structures/graph/undirected-graph.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-mkdir} +0 -0
  674. /package/{test/performance/data-structures/hash/hash-table.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-patch} +0 -0
  675. /package/{test/performance/data-structures/heap/max-heap.test.ts → build/_deps/benchmark-subbuild/benchmark-populate-prefix/src/benchmark-populate-stamp/benchmark-populate-test} +0 -0
  676. /package/test/unit/data-structures/binary-tree/{tree-multi-map.more-branches-2.coverage.test.ts → tree-multi-map.more-branches-2.coverage.test.ts.skip} +0 -0
@@ -7044,6 +7044,9 @@ var BinaryTree = class extends IterableEntryBase {
7044
7044
  get isDuplicate() {
7045
7045
  return this._isDuplicate;
7046
7046
  }
7047
+ // Map mode acceleration store:
7048
+ // - isMapMode=false: unused
7049
+ // - isMapMode=true: key -> node reference (O(1) has/getNode + fast get)
7047
7050
  _store = /* @__PURE__ */ new Map();
7048
7051
  /**
7049
7052
  * Gets the external value store (used in Map mode).
@@ -7103,7 +7106,7 @@ var BinaryTree = class extends IterableEntryBase {
7103
7106
  * @returns The newly created node.
7104
7107
  */
7105
7108
  createNode(key, value) {
7106
- return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
7109
+ return new BinaryTreeNode(key, value);
7107
7110
  }
7108
7111
  /**
7109
7112
  * Creates a new, empty tree of the same type and configuration.
@@ -7250,11 +7253,11 @@ var BinaryTree = class extends IterableEntryBase {
7250
7253
  * @returns True if the addition was successful, false otherwise.
7251
7254
  */
7252
7255
  set(keyNodeOrEntry, value) {
7253
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7256
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7254
7257
  if (newNode === void 0) return false;
7255
7258
  if (!this._root) {
7256
7259
  this._setRoot(newNode);
7257
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
7260
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7258
7261
  this._size = 1;
7259
7262
  return true;
7260
7263
  }
@@ -7266,7 +7269,7 @@ var BinaryTree = class extends IterableEntryBase {
7266
7269
  if (!this._isDuplicate) {
7267
7270
  if (newNode !== null && cur.key === newNode.key) {
7268
7271
  this._replaceNode(cur, newNode);
7269
- if (this._isMapMode) this._setValue(cur.key, newValue);
7272
+ if (this._isMapMode && newNode !== null) this._store.set(cur.key, newNode);
7270
7273
  return true;
7271
7274
  }
7272
7275
  }
@@ -7286,7 +7289,7 @@ var BinaryTree = class extends IterableEntryBase {
7286
7289
  } else if (potentialParent.right === void 0) {
7287
7290
  potentialParent.right = newNode;
7288
7291
  }
7289
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
7292
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7290
7293
  this._size++;
7291
7294
  return true;
7292
7295
  }
@@ -7371,6 +7374,10 @@ var BinaryTree = class extends IterableEntryBase {
7371
7374
  if (leftSubTreeRightMost) {
7372
7375
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
7373
7376
  orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
7377
+ if (this._isMapMode) {
7378
+ this._store.set(curr.key, curr);
7379
+ this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
7380
+ }
7374
7381
  if (parentOfLeftSubTreeMax) {
7375
7382
  if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
7376
7383
  parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
@@ -7454,6 +7461,13 @@ var BinaryTree = class extends IterableEntryBase {
7454
7461
  * @returns The first matching node, or undefined if not found.
7455
7462
  */
7456
7463
  getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7464
+ if (this._isMapMode && keyNodeEntryOrPredicate !== null && keyNodeEntryOrPredicate !== void 0) {
7465
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7466
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7467
+ if (key === null || key === void 0) return;
7468
+ return this._store.get(key);
7469
+ }
7470
+ }
7457
7471
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType)[0];
7458
7472
  }
7459
7473
  /**
@@ -7469,11 +7483,18 @@ var BinaryTree = class extends IterableEntryBase {
7469
7483
  if (this._isMapMode) {
7470
7484
  const key = this._extractKey(keyNodeEntryOrPredicate);
7471
7485
  if (key === null || key === void 0) return;
7472
- return this._store.get(key);
7486
+ return this._store.get(key)?.value;
7473
7487
  }
7474
7488
  return this.getNode(keyNodeEntryOrPredicate, startNode, iterationType)?.value;
7475
7489
  }
7476
7490
  has(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7491
+ if (this._isMapMode && keyNodeEntryOrPredicate !== void 0 && keyNodeEntryOrPredicate !== null) {
7492
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7493
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7494
+ if (key === null || key === void 0) return false;
7495
+ return this._store.has(key);
7496
+ }
7497
+ }
7477
7498
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType).length > 0;
7478
7499
  }
7479
7500
  /**
@@ -8216,8 +8237,7 @@ var BinaryTree = class extends IterableEntryBase {
8216
8237
  }
8217
8238
  current = stack.pop();
8218
8239
  if (this.isRealNode(current)) {
8219
- if (this._isMapMode) yield [current.key, this._store.get(current.key)];
8220
- else yield [current.key, current.value];
8240
+ yield [current.key, current.value];
8221
8241
  current = current.right;
8222
8242
  }
8223
8243
  }
@@ -8225,8 +8245,7 @@ var BinaryTree = class extends IterableEntryBase {
8225
8245
  if (node.left && this.isRealNode(node)) {
8226
8246
  yield* this[Symbol.iterator](node.left);
8227
8247
  }
8228
- if (this._isMapMode) yield [node.key, this._store.get(node.key)];
8229
- else yield [node.key, node.value];
8248
+ yield [node.key, node.value];
8230
8249
  if (node.right && this.isRealNode(node)) {
8231
8250
  yield* this[Symbol.iterator](node.right);
8232
8251
  }
@@ -8312,8 +8331,7 @@ var BinaryTree = class extends IterableEntryBase {
8312
8331
  (node) => {
8313
8332
  if (node === null) cloned.set(null);
8314
8333
  else {
8315
- if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
8316
- else cloned.set([node.key, node.value]);
8334
+ cloned.set([node.key, node.value]);
8317
8335
  }
8318
8336
  },
8319
8337
  this._root,
@@ -8321,7 +8339,6 @@ var BinaryTree = class extends IterableEntryBase {
8321
8339
  true
8322
8340
  // Include nulls
8323
8341
  );
8324
- if (this._isMapMode) cloned._store = this._store;
8325
8342
  }
8326
8343
  /**
8327
8344
  * (Protected) Recursive helper for `toVisual`.
@@ -8484,8 +8501,10 @@ var BinaryTree = class extends IterableEntryBase {
8484
8501
  */
8485
8502
  _setValue(key, value) {
8486
8503
  if (key === null || key === void 0) return false;
8487
- if (value === void 0) return false;
8488
- return this._store.set(key, value);
8504
+ const node = this._store.get(key);
8505
+ if (!node) return false;
8506
+ node.value = value;
8507
+ return true;
8489
8508
  }
8490
8509
  /**
8491
8510
  * (Protected) Clears all nodes from the tree.
@@ -8696,7 +8715,7 @@ var BST = class extends BinaryTree {
8696
8715
  * @returns The newly created BSTNode.
8697
8716
  */
8698
8717
  createNode(key, value) {
8699
- return new BSTNode(key, this._isMapMode ? void 0 : value);
8718
+ return new BSTNode(key, value);
8700
8719
  }
8701
8720
  /**
8702
8721
  * Ensures the input is a node. If it's a key or entry, it searches for the node.
@@ -8935,11 +8954,11 @@ var BST = class extends BinaryTree {
8935
8954
  * @returns True if the addition was successful, false otherwise.
8936
8955
  */
8937
8956
  set(keyNodeOrEntry, value) {
8938
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8957
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8939
8958
  if (newNode === void 0) return false;
8940
8959
  if (this._root === void 0) {
8941
8960
  this._setRoot(newNode);
8942
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8961
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8943
8962
  this._size++;
8944
8963
  return true;
8945
8964
  }
@@ -8947,12 +8966,12 @@ var BST = class extends BinaryTree {
8947
8966
  while (current !== void 0) {
8948
8967
  if (this._compare(current.key, newNode.key) === 0) {
8949
8968
  this._replaceNode(current, newNode);
8950
- if (this._isMapMode) this._setValue(current.key, newValue);
8969
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(current.key, newNode);
8951
8970
  return true;
8952
8971
  } else if (this._compare(current.key, newNode.key) > 0) {
8953
8972
  if (current.left === void 0) {
8954
8973
  current.left = newNode;
8955
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8974
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8956
8975
  this._size++;
8957
8976
  return true;
8958
8977
  }
@@ -8960,7 +8979,7 @@ var BST = class extends BinaryTree {
8960
8979
  } else {
8961
8980
  if (current.right === void 0) {
8962
8981
  current.right = newNode;
8963
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8982
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8964
8983
  this._size++;
8965
8984
  return true;
8966
8985
  }
@@ -10517,7 +10536,7 @@ var AVLTree = class extends BST {
10517
10536
  * @returns The newly created AVLTreeNode.
10518
10537
  */
10519
10538
  createNode(key, value) {
10520
- return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
10539
+ return new AVLTreeNode(key, value);
10521
10540
  }
10522
10541
  /**
10523
10542
  * Checks if the given item is an `AVLTreeNode` instance.
@@ -11073,7 +11092,7 @@ var RedBlackTree = class extends BST {
11073
11092
  * @returns A new RedBlackTreeNode instance.
11074
11093
  */
11075
11094
  createNode(key, value, color = "BLACK") {
11076
- return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
11095
+ return new RedBlackTreeNode(key, value, color);
11077
11096
  }
11078
11097
  /**
11079
11098
  * Type guard: check whether the input is a RedBlackTreeNode.
@@ -11222,20 +11241,15 @@ var RedBlackTree = class extends BST {
11222
11241
  if (minN !== NIL) {
11223
11242
  const cMin = comparator(key, minN.key);
11224
11243
  if (cMin === 0) {
11225
- if (this._isMapMode) {
11226
- if (nextValue !== void 0) this._store.set(key, nextValue);
11227
- else this._setValue(key, nextValue);
11228
- } else minN.value = nextValue;
11244
+ minN.value = nextValue;
11245
+ if (this._isMapMode) this._store.set(key, minN);
11229
11246
  return { node: minN, created: false };
11230
11247
  }
11231
11248
  const minL = minN.left;
11232
11249
  if (cMin < 0 && (minL === NIL || minL === null || minL === void 0)) {
11233
11250
  const newNode2 = this.createNode(key, nextValue);
11234
11251
  this._attachNewNode(minN, "left", newNode2);
11235
- if (this._isMapMode) {
11236
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11237
- else this._setValue(newNode2.key, nextValue);
11238
- }
11252
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11239
11253
  this._size++;
11240
11254
  this._setMinCache(newNode2);
11241
11255
  if (header._right === NIL) this._setMaxCache(newNode2);
@@ -11245,20 +11259,15 @@ var RedBlackTree = class extends BST {
11245
11259
  const maxN = header._right ?? NIL;
11246
11260
  const cMax = comparator(key, maxN.key);
11247
11261
  if (cMax === 0) {
11248
- if (this._isMapMode) {
11249
- if (nextValue !== void 0) this._store.set(key, nextValue);
11250
- else this._setValue(key, nextValue);
11251
- } else maxN.value = nextValue;
11262
+ maxN.value = nextValue;
11263
+ if (this._isMapMode) this._store.set(key, maxN);
11252
11264
  return { node: maxN, created: false };
11253
11265
  }
11254
11266
  const maxR = maxN.right;
11255
11267
  if (cMax > 0 && (maxR === NIL || maxR === null || maxR === void 0)) {
11256
11268
  const newNode2 = this.createNode(key, nextValue);
11257
11269
  this._attachNewNode(maxN, "right", newNode2);
11258
- if (this._isMapMode) {
11259
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11260
- else this._setValue(newNode2.key, nextValue);
11261
- }
11270
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11262
11271
  this._size++;
11263
11272
  this._setMaxCache(newNode2);
11264
11273
  if (header._left === NIL) this._setMinCache(newNode2);
@@ -11278,12 +11287,8 @@ var RedBlackTree = class extends BST {
11278
11287
  if (lastCompared < 0) current = current.left ?? NIL;
11279
11288
  else if (lastCompared > 0) current = current.right ?? NIL;
11280
11289
  else {
11281
- if (isMapMode) {
11282
- if (nextValue !== void 0) store.set(key, nextValue);
11283
- else this._setValue(key, nextValue);
11284
- } else {
11285
- current.value = nextValue;
11286
- }
11290
+ current.value = nextValue;
11291
+ if (isMapMode) store.set(key, current);
11287
11292
  return { node: current, created: false };
11288
11293
  }
11289
11294
  }
@@ -11302,10 +11307,7 @@ var RedBlackTree = class extends BST {
11302
11307
  this._insertFixup(newNode);
11303
11308
  if (this.isRealNode(this._root)) this._root.color = "BLACK";
11304
11309
  else return void 0;
11305
- if (isMapMode) {
11306
- if (nextValue !== void 0) store.set(newNode.key, nextValue);
11307
- else this._setValue(newNode.key, nextValue);
11308
- }
11310
+ if (isMapMode) store.set(newNode.key, newNode);
11309
11311
  this._size++;
11310
11312
  const hMin = this._header._left ?? NIL;
11311
11313
  const hMax = this._header._right ?? NIL;
@@ -11333,10 +11335,11 @@ var RedBlackTree = class extends BST {
11333
11335
  * @remarks Time O(log n) average, Space O(1)
11334
11336
  */
11335
11337
  _setKV(key, nextValue) {
11336
- if (this._isMapMode && nextValue !== void 0) {
11338
+ if (this._isMapMode) {
11337
11339
  const store = this._store;
11338
- if (store.has(key)) {
11339
- store.set(key, nextValue);
11340
+ const node = store.get(key);
11341
+ if (node) {
11342
+ node.value = nextValue;
11340
11343
  return true;
11341
11344
  }
11342
11345
  }
@@ -11360,10 +11363,8 @@ var RedBlackTree = class extends BST {
11360
11363
  const cmp = this._compare.bind(this);
11361
11364
  const c0 = cmp(key, hint.key);
11362
11365
  if (c0 === 0) {
11363
- if (this._isMapMode) {
11364
- if (value !== void 0) this._store.set(key, value);
11365
- else this._setValue(key, value);
11366
- } else hint.value = value;
11366
+ hint.value = value;
11367
+ if (this._isMapMode) this._store.set(key, hint);
11367
11368
  return hint;
11368
11369
  }
11369
11370
  if (c0 < 0) {
@@ -11371,10 +11372,7 @@ var RedBlackTree = class extends BST {
11371
11372
  const newNode = this.createNode(key, value);
11372
11373
  if (!this.isRealNode(newNode)) return void 0;
11373
11374
  this._attachNewNode(hint, "left", newNode);
11374
- if (this._isMapMode) {
11375
- if (value !== void 0) this._store.set(key, value);
11376
- else this._setValue(key, value);
11377
- }
11375
+ if (this._isMapMode) this._store.set(key, newNode);
11378
11376
  this._size++;
11379
11377
  const NIL = this.NIL;
11380
11378
  const hMin = this._header._left ?? NIL;
@@ -11391,10 +11389,7 @@ var RedBlackTree = class extends BST {
11391
11389
  const newNode = this.createNode(key, value);
11392
11390
  if (!this.isRealNode(newNode)) return void 0;
11393
11391
  this._attachNewNode(pred, "right", newNode);
11394
- if (this._isMapMode) {
11395
- if (value !== void 0) this._store.set(key, value);
11396
- else this._setValue(key, value);
11397
- }
11392
+ if (this._isMapMode) this._store.set(key, newNode);
11398
11393
  this._size++;
11399
11394
  const NIL = this.NIL;
11400
11395
  const hMin = this._header._left ?? NIL;
@@ -11409,10 +11404,7 @@ var RedBlackTree = class extends BST {
11409
11404
  const newNode = this.createNode(key, value);
11410
11405
  if (!this.isRealNode(newNode)) return void 0;
11411
11406
  this._attachNewNode(hint, "right", newNode);
11412
- if (this._isMapMode) {
11413
- if (value !== void 0) this._store.set(key, value);
11414
- else this._setValue(key, value);
11415
- }
11407
+ if (this._isMapMode) this._store.set(key, newNode);
11416
11408
  this._size++;
11417
11409
  const NIL = this.NIL;
11418
11410
  const hMin = this._header._left ?? NIL;
@@ -11429,10 +11421,7 @@ var RedBlackTree = class extends BST {
11429
11421
  const newNode = this.createNode(key, value);
11430
11422
  if (!this.isRealNode(newNode)) return void 0;
11431
11423
  this._attachNewNode(succ, "left", newNode);
11432
- if (this._isMapMode) {
11433
- if (value !== void 0) this._store.set(key, value);
11434
- else this._setValue(key, value);
11435
- }
11424
+ if (this._isMapMode) this._store.set(key, newNode);
11436
11425
  this._size++;
11437
11426
  const NIL = this.NIL;
11438
11427
  const hMin = this._header._left ?? NIL;
@@ -11479,12 +11468,24 @@ var RedBlackTree = class extends BST {
11479
11468
  } else {
11480
11469
  return false;
11481
11470
  }
11482
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11471
+ if (this._isMapMode) {
11472
+ const n = this.getNode(newNode.key);
11473
+ if (this.isRealNode(n)) {
11474
+ n.value = newValue;
11475
+ this._store.set(n.key, n);
11476
+ }
11477
+ }
11483
11478
  this._size++;
11484
11479
  return true;
11485
11480
  }
11486
11481
  if (insertStatus === "UPDATED") {
11487
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11482
+ if (this._isMapMode) {
11483
+ const n = this.getNode(newNode.key);
11484
+ if (this.isRealNode(n)) {
11485
+ n.value = newValue;
11486
+ this._store.set(n.key, n);
11487
+ }
11488
+ }
11488
11489
  return true;
11489
11490
  }
11490
11491
  return false;
@@ -11850,1457 +11851,1521 @@ var RedBlackTree = class extends BST {
11850
11851
  }
11851
11852
  };
11852
11853
 
11853
- // src/data-structures/binary-tree/avl-tree-multi-map.ts
11854
- var AVLTreeMultiMapNode = class {
11854
+ // src/data-structures/binary-tree/tree-set.ts
11855
+ var TreeSet = class _TreeSet {
11855
11856
  static {
11856
- __name(this, "AVLTreeMultiMapNode");
11857
+ __name(this, "TreeSet");
11857
11858
  }
11858
- key;
11859
- value;
11860
- parent = void 0;
11859
+ #core;
11860
+ #isDefaultComparator;
11861
+ #userComparator;
11861
11862
  /**
11862
- * Create an AVLTreeMultiMap node with a value bucket.
11863
- * @remarks Time O(1), Space O(1)
11864
- * @param key - Key of the node.
11865
- * @param value - Initial array of values.
11866
- * @returns New AVLTreeMultiMapNode instance.
11863
+ * Create a TreeSet from an iterable of keys.
11864
+ *
11865
+ * @throws {TypeError} When using the default comparator and encountering unsupported key types,
11866
+ * or invalid keys (e.g. `NaN`, invalid `Date`).
11867
11867
  */
11868
- constructor(key, value = []) {
11869
- this.key = key;
11870
- this.value = value;
11868
+ constructor(elements = [], options = {}) {
11869
+ this.#userComparator = options.comparator;
11870
+ const comparator = options.comparator ?? _TreeSet.createDefaultComparator();
11871
+ this.#isDefaultComparator = options.comparator === void 0;
11872
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
11873
+ for (const k of elements) this.add(k);
11871
11874
  }
11872
- _left = void 0;
11873
11875
  /**
11874
- * Get the left child pointer.
11875
- * @remarks Time O(1), Space O(1)
11876
- * @returns Left child node, or null/undefined.
11876
+ * Create the strict default comparator.
11877
+ *
11878
+ * Supports:
11879
+ * - `number` (rejects `NaN`; treats `-0` and `0` as equal)
11880
+ * - `string`
11881
+ * - `Date` (orders by `getTime()`, rejects invalid dates)
11882
+ *
11883
+ * For other key types, a custom comparator must be provided.
11877
11884
  */
11878
- get left() {
11879
- return this._left;
11885
+ static createDefaultComparator() {
11886
+ return (a, b) => {
11887
+ if (typeof a === "number" && typeof b === "number") {
11888
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeSet: NaN is not a valid key");
11889
+ const aa = Object.is(a, -0) ? 0 : a;
11890
+ const bb = Object.is(b, -0) ? 0 : b;
11891
+ return aa > bb ? 1 : aa < bb ? -1 : 0;
11892
+ }
11893
+ if (typeof a === "string" && typeof b === "string") {
11894
+ return a > b ? 1 : a < b ? -1 : 0;
11895
+ }
11896
+ if (a instanceof Date && b instanceof Date) {
11897
+ const ta = a.getTime();
11898
+ const tb = b.getTime();
11899
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeSet: invalid Date key");
11900
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
11901
+ }
11902
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11903
+ };
11880
11904
  }
11881
11905
  /**
11882
- * Set the left child and update its parent pointer.
11883
- * @remarks Time O(1), Space O(1)
11884
- * @param v - New left child node, or null/undefined.
11885
- * @returns void
11906
+ * Number of elements in the set.
11886
11907
  */
11887
- set left(v) {
11888
- if (v) {
11889
- v.parent = this;
11908
+ get size() {
11909
+ return this.#core.size;
11910
+ }
11911
+ /**
11912
+ * Whether the set is empty.
11913
+ */
11914
+ isEmpty() {
11915
+ return this.size === 0;
11916
+ }
11917
+ _validateKey(key) {
11918
+ if (!this.#isDefaultComparator) return;
11919
+ if (typeof key === "number") {
11920
+ if (Number.isNaN(key)) throw new TypeError("TreeSet: NaN is not a valid key");
11921
+ return;
11890
11922
  }
11891
- this._left = v;
11923
+ if (typeof key === "string") return;
11924
+ if (key instanceof Date) {
11925
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeSet: invalid Date key");
11926
+ return;
11927
+ }
11928
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11892
11929
  }
11893
- _right = void 0;
11894
11930
  /**
11895
- * Get the right child pointer.
11896
- * @remarks Time O(1), Space O(1)
11897
- * @returns Right child node, or null/undefined.
11931
+ * Add a key to the set (no-op if already present).
11932
+ * @remarks Expected time O(log n)
11898
11933
  */
11899
- get right() {
11900
- return this._right;
11934
+ add(key) {
11935
+ this._validateKey(key);
11936
+ this.#core.set(key, void 0);
11937
+ return this;
11901
11938
  }
11902
11939
  /**
11903
- * Set the right child and update its parent pointer.
11904
- * @remarks Time O(1), Space O(1)
11905
- * @param v - New right child node, or null/undefined.
11906
- * @returns void
11940
+ * Test whether a key exists.
11941
+ * @remarks Expected time O(log n)
11907
11942
  */
11908
- set right(v) {
11909
- if (v) {
11910
- v.parent = this;
11911
- }
11912
- this._right = v;
11943
+ has(key) {
11944
+ this._validateKey(key);
11945
+ return this.#core.has(key);
11913
11946
  }
11914
- _height = 0;
11915
11947
  /**
11916
- * Gets the height of the node (used in self-balancing trees).
11917
- * @remarks Time O(1), Space O(1)
11918
- *
11919
- * @returns The height.
11948
+ * Delete a key.
11949
+ * @returns `true` if the key existed; otherwise `false`.
11950
+ * @remarks Expected time O(log n)
11920
11951
  */
11921
- get height() {
11922
- return this._height;
11952
+ delete(key) {
11953
+ this._validateKey(key);
11954
+ const res = this.#core.delete(key);
11955
+ return Array.isArray(res) && res.length > 0 && !!res[0]?.deleted;
11923
11956
  }
11924
11957
  /**
11925
- * Sets the height of the node.
11926
- * @remarks Time O(1), Space O(1)
11927
- *
11928
- * @param value - The new height.
11958
+ * Remove all keys.
11929
11959
  */
11930
- set height(value) {
11931
- this._height = value;
11960
+ clear() {
11961
+ this.#core.clear();
11932
11962
  }
11933
- _color = "BLACK";
11934
11963
  /**
11935
- * Gets the color of the node (used in Red-Black trees).
11936
- * @remarks Time O(1), Space O(1)
11937
- *
11938
- * @returns The node's color.
11964
+ * Iterate over keys in ascending order.
11939
11965
  */
11940
- get color() {
11941
- return this._color;
11966
+ keys() {
11967
+ return this.#core.keys();
11942
11968
  }
11943
11969
  /**
11944
- * Sets the color of the node.
11945
- * @remarks Time O(1), Space O(1)
11970
+ * Iterate over values in ascending order.
11946
11971
  *
11947
- * @param value - The new color.
11972
+ * Note: for Set-like containers, `values()` is the same as `keys()`.
11948
11973
  */
11949
- set color(value) {
11950
- this._color = value;
11974
+ values() {
11975
+ return this.keys();
11951
11976
  }
11952
- _count = 1;
11953
11977
  /**
11954
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
11955
- * @remarks Time O(1), Space O(1)
11978
+ * Iterate over `[value, value]` pairs (native Set convention).
11956
11979
  *
11957
- * @returns The subtree node count.
11980
+ * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
11958
11981
  */
11959
- get count() {
11960
- return this._count;
11982
+ *entries() {
11983
+ for (const k of this.keys()) yield [k, k];
11984
+ }
11985
+ [Symbol.iterator]() {
11986
+ return this.keys();
11961
11987
  }
11962
11988
  /**
11963
- * Sets the count of nodes in the subtree.
11964
- * @remarks Time O(1), Space O(1)
11989
+ * Visit each value in ascending order.
11965
11990
  *
11966
- * @param value - The new count.
11991
+ * Callback follows native Set convention: `(value, value2, set)`.
11967
11992
  */
11968
- set count(value) {
11969
- this._count = value;
11993
+ forEach(cb, thisArg) {
11994
+ for (const k of this) cb.call(thisArg, k, k, this);
11970
11995
  }
11971
11996
  /**
11972
- * Gets the position of the node relative to its parent.
11973
- * @remarks Time O(1), Space O(1)
11997
+ * Create a new TreeSet by mapping each value to a new key.
11974
11998
  *
11975
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
11999
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
12000
+ * @remarks Time O(n log n) expected, Space O(n)
11976
12001
  */
11977
- get familyPosition() {
11978
- if (!this.parent) {
11979
- return this.left || this.right ? "ROOT" : "ISOLATED";
11980
- }
11981
- if (this.parent.left === this) {
11982
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
11983
- } else if (this.parent.right === this) {
11984
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12002
+ map(callbackfn, options = {}, thisArg) {
12003
+ const out = new _TreeSet([], options);
12004
+ let index = 0;
12005
+ for (const v of this) {
12006
+ const mk = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12007
+ out.add(mk);
11985
12008
  }
11986
- return "MAL_NODE";
11987
- }
11988
- };
11989
- var AVLTreeMultiMap = class extends AVLTree {
11990
- static {
11991
- __name(this, "AVLTreeMultiMap");
12009
+ return out;
11992
12010
  }
11993
12011
  /**
11994
- * Create an AVLTreeMultiMap and optionally bulk-insert items.
11995
- * @remarks Time O(N log N), Space O(N)
11996
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
11997
- * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
11998
- * @returns New AVLTreeMultiMap instance.
12012
+ * Create a new TreeSet containing only values that satisfy the predicate.
12013
+ * @remarks Time O(n log n) expected, Space O(n)
11999
12014
  */
12000
- constructor(keysNodesEntriesOrRaws = [], options) {
12001
- super([], { ...options, isMapMode: true });
12002
- if (keysNodesEntriesOrRaws) {
12003
- this.setMany(keysNodesEntriesOrRaws);
12015
+ filter(callbackfn, thisArg) {
12016
+ const out = new _TreeSet([], { comparator: this.#userComparator });
12017
+ let index = 0;
12018
+ for (const v of this) {
12019
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12020
+ if (ok) out.add(v);
12004
12021
  }
12005
- }
12006
- createNode(key, value = []) {
12007
- return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
12022
+ return out;
12008
12023
  }
12009
12024
  /**
12010
- * Checks if the given item is a `AVLTreeMultiMapNode` instance.
12011
- * @remarks Time O(1), Space O(1)
12012
- *
12013
- * @param keyNodeOrEntry - The item to check.
12014
- * @returns True if it's a AVLTreeMultiMapNode, false otherwise.
12025
+ * Reduce values into a single accumulator.
12026
+ * @remarks Time O(n), Space O(1)
12015
12027
  */
12016
- isNode(keyNodeOrEntry) {
12017
- return keyNodeOrEntry instanceof AVLTreeMultiMapNode;
12028
+ reduce(callbackfn, initialValue) {
12029
+ let acc = initialValue;
12030
+ let index = 0;
12031
+ for (const v of this) acc = callbackfn(acc, v, index++, this);
12032
+ return acc;
12018
12033
  }
12019
12034
  /**
12020
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12021
- * @remarks Time O(log N + M), Space O(1)
12022
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12023
- * @param [value] - Single value to set when a bare key is provided.
12024
- * @returns True if inserted or appended; false if ignored.
12035
+ * Test whether all values satisfy a predicate.
12036
+ * @remarks Time O(n), Space O(1)
12025
12037
  */
12026
- set(keyNodeOrEntry, value) {
12027
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12028
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12029
- if (key === void 0 || key === null) return false;
12030
- const _setToValues = /* @__PURE__ */ __name(() => {
12031
- const existingValues = this.get(key);
12032
- if (existingValues !== void 0 && values !== void 0) {
12033
- for (const value2 of values) existingValues.push(value2);
12034
- return true;
12035
- }
12036
- return false;
12037
- }, "_setToValues");
12038
- const _setByNode = /* @__PURE__ */ __name(() => {
12039
- const existingNode = this.getNode(key);
12040
- if (this.isRealNode(existingNode)) {
12041
- const existingValues = this.get(existingNode);
12042
- if (existingValues === void 0) {
12043
- super.set(key, values);
12044
- return true;
12045
- }
12046
- if (values !== void 0) {
12047
- for (const value2 of values) existingValues.push(value2);
12048
- return true;
12049
- } else {
12050
- return false;
12051
- }
12052
- } else {
12053
- return super.set(key, values);
12054
- }
12055
- }, "_setByNode");
12056
- if (this._isMapMode) {
12057
- return _setByNode() || _setToValues();
12058
- }
12059
- return _setToValues() || _setByNode();
12060
- }, "_commonAdd");
12061
- if (this.isEntry(keyNodeOrEntry)) {
12062
- const [key, values] = keyNodeOrEntry;
12063
- return _commonAdd(key, value !== void 0 ? [value] : values);
12038
+ every(callbackfn, thisArg) {
12039
+ let index = 0;
12040
+ for (const v of this) {
12041
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12042
+ if (!ok) return false;
12064
12043
  }
12065
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12044
+ return true;
12066
12045
  }
12067
12046
  /**
12068
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12069
- * @remarks Time O(log N), Space O(1)
12070
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12071
- * @param value - Value to remove from the bucket.
12072
- * @returns True if the value was removed; false if not found.
12073
- */
12074
- deleteValue(keyNodeOrEntry, value) {
12075
- const values = this.get(keyNodeOrEntry);
12076
- if (Array.isArray(values)) {
12077
- const index = values.indexOf(value);
12078
- if (index === -1) return false;
12079
- values.splice(index, 1);
12080
- if (values.length === 0) this.delete(keyNodeOrEntry);
12081
- return true;
12047
+ * Test whether any value satisfies a predicate.
12048
+ * @remarks Time O(n), Space O(1)
12049
+ */
12050
+ some(callbackfn, thisArg) {
12051
+ let index = 0;
12052
+ for (const v of this) {
12053
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12054
+ if (ok) return true;
12082
12055
  }
12083
12056
  return false;
12084
12057
  }
12085
12058
  /**
12086
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12087
- * @remarks Time O(N), Space O(N)
12088
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12089
- * @returns True if rebalancing succeeded (tree not empty).
12059
+ * Find the first value that satisfies a predicate.
12060
+ * @remarks Time O(n), Space O(1)
12090
12061
  */
12091
- perfectlyBalance(iterationType = this.iterationType) {
12092
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12093
- const n = nodes.length;
12094
- if (n === 0) return false;
12095
- this._clearNodes();
12096
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12097
- if (l > r) return void 0;
12098
- const m = l + (r - l >> 1);
12099
- const root = nodes[m];
12100
- root.left = build(l, m - 1, root);
12101
- root.right = build(m + 1, r, root);
12102
- root.parent = parent;
12103
- const lh = root.left ? root.left.height : -1;
12104
- const rh = root.right ? root.right.height : -1;
12105
- root.height = Math.max(lh, rh) + 1;
12106
- return root;
12107
- }, "build");
12108
- const newRoot = build(0, n - 1, void 0);
12109
- this._setRoot(newRoot);
12110
- this._size = n;
12111
- return true;
12062
+ find(callbackfn, thisArg) {
12063
+ let index = 0;
12064
+ for (const v of this) {
12065
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12066
+ if (ok) return v;
12067
+ }
12068
+ return void 0;
12112
12069
  }
12113
12070
  /**
12114
- * Create a new tree by mapping each [key, values] bucket.
12115
- * @remarks Time O(N log N), Space O(N)
12116
- * @template MK
12117
- * @template MV
12118
- * @template MR
12119
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12120
- * @param [options] - Options for the output tree.
12121
- * @param [thisArg] - Value for `this` inside the callback.
12122
- * @returns The mapped AVLTree or AVLTreeMultiMap depending on MV; see overloads.
12071
+ * Materialize the set into an array of keys.
12072
+ * @remarks Time O(n), Space O(n)
12123
12073
  */
12124
- map(callback, options, thisArg) {
12125
- const out = this._createLike([], options);
12126
- let i = 0;
12127
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12128
- return out;
12074
+ toArray() {
12075
+ return [...this];
12129
12076
  }
12130
12077
  /**
12131
- * (Protected) Create an empty instance of the same concrete class.
12132
- * @remarks Time O(1), Space O(1)
12133
- * @template TK
12134
- * @template TV
12135
- * @template TR
12136
- * @param [options] - Optional constructor options for the like-kind instance.
12137
- * @returns An empty like-kind instance.
12078
+ * Print a human-friendly representation.
12079
+ * @remarks Time O(n), Space O(n)
12138
12080
  */
12139
- _createInstance(options) {
12140
- const Ctor = this.constructor;
12141
- return new Ctor([], { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12081
+ print() {
12082
+ this.#core.print();
12142
12083
  }
12084
+ // Navigable operations
12143
12085
  /**
12144
- * (Protected) Create a like-kind instance and seed it from an iterable.
12145
- * @remarks Time O(N log N), Space O(N)
12146
- * @template TK
12147
- * @template TV
12148
- * @template TR
12149
- * @param iter - Iterable used to seed the new tree.
12150
- * @param [options] - Options merged with the current snapshot.
12151
- * @returns A like-kind AVLTree built from the iterable.
12086
+ * Smallest key in the set.
12152
12087
  */
12153
- _createLike(iter = [], options) {
12154
- const Ctor = this.constructor;
12155
- return new Ctor(iter, { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12156
- }
12157
- };
12158
-
12159
- // src/data-structures/binary-tree/tree-multi-map.ts
12160
- var TreeMultiMapNode = class {
12161
- static {
12162
- __name(this, "TreeMultiMapNode");
12088
+ first() {
12089
+ return this.#core.getLeftMost();
12163
12090
  }
12164
- key;
12165
- value;
12166
- parent = void 0;
12167
12091
  /**
12168
- * Create a TreeMultiMap node with an optional value bucket.
12169
- * @remarks Time O(1), Space O(1)
12170
- * @param key - Key of the node.
12171
- * @param [value] - Initial array of values.
12172
- * @returns New TreeMultiMapNode instance.
12092
+ * Largest key in the set.
12173
12093
  */
12174
- constructor(key, value = [], color = "BLACK") {
12175
- this.key = key;
12176
- this.value = value;
12177
- this.color = color;
12094
+ last() {
12095
+ return this.#core.getRightMost();
12178
12096
  }
12179
- _left = void 0;
12180
12097
  /**
12181
- * Get the left child pointer.
12182
- * @remarks Time O(1), Space O(1)
12183
- * @returns Left child node, or null/undefined.
12098
+ * Remove and return the smallest key.
12184
12099
  */
12185
- get left() {
12186
- return this._left;
12100
+ pollFirst() {
12101
+ const k = this.first();
12102
+ if (k === void 0) return void 0;
12103
+ this.delete(k);
12104
+ return k;
12187
12105
  }
12188
12106
  /**
12189
- * Set the left child and update its parent pointer.
12190
- * @remarks Time O(1), Space O(1)
12191
- * @param v - New left child node, or null/undefined.
12192
- * @returns void
12107
+ * Remove and return the largest key.
12193
12108
  */
12194
- set left(v) {
12195
- if (v) {
12196
- v.parent = this;
12197
- }
12198
- this._left = v;
12109
+ pollLast() {
12110
+ const k = this.last();
12111
+ if (k === void 0) return void 0;
12112
+ this.delete(k);
12113
+ return k;
12199
12114
  }
12200
- _right = void 0;
12201
12115
  /**
12202
- * Get the right child pointer.
12203
- * @remarks Time O(1), Space O(1)
12204
- * @returns Right child node, or null/undefined.
12116
+ * Smallest key that is >= the given key.
12205
12117
  */
12206
- get right() {
12207
- return this._right;
12118
+ ceiling(key) {
12119
+ this._validateKey(key);
12120
+ return this.#core.ceiling(key);
12208
12121
  }
12209
12122
  /**
12210
- * Set the right child and update its parent pointer.
12211
- * @remarks Time O(1), Space O(1)
12212
- * @param v - New right child node, or null/undefined.
12213
- * @returns void
12123
+ * Largest key that is <= the given key.
12214
12124
  */
12215
- set right(v) {
12216
- if (v) {
12217
- v.parent = this;
12218
- }
12219
- this._right = v;
12125
+ floor(key) {
12126
+ this._validateKey(key);
12127
+ return this.#core.floor(key);
12220
12128
  }
12221
- _height = 0;
12222
12129
  /**
12223
- * Gets the height of the node (used in self-balancing trees).
12224
- * @remarks Time O(1), Space O(1)
12225
- *
12226
- * @returns The height.
12130
+ * Smallest key that is > the given key.
12227
12131
  */
12228
- get height() {
12229
- return this._height;
12132
+ higher(key) {
12133
+ this._validateKey(key);
12134
+ return this.#core.higher(key);
12230
12135
  }
12231
12136
  /**
12232
- * Sets the height of the node.
12233
- * @remarks Time O(1), Space O(1)
12234
- *
12235
- * @param value - The new height.
12137
+ * Largest key that is < the given key.
12236
12138
  */
12237
- set height(value) {
12238
- this._height = value;
12139
+ lower(key) {
12140
+ this._validateKey(key);
12141
+ return this.#core.lower(key);
12239
12142
  }
12240
- _color = "BLACK";
12241
12143
  /**
12242
- * Gets the color of the node (used in Red-Black trees).
12243
- * @remarks Time O(1), Space O(1)
12144
+ * Return all keys in a given range.
12244
12145
  *
12245
- * @returns The node's color.
12146
+ * @param range `[low, high]`
12147
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12246
12148
  */
12247
- get color() {
12248
- return this._color;
12149
+ rangeSearch(range, options = {}) {
12150
+ const { lowInclusive = true, highInclusive = true } = options;
12151
+ const [low, high] = range;
12152
+ this._validateKey(low);
12153
+ this._validateKey(high);
12154
+ const keys = this.#core.rangeSearch([low, high]);
12155
+ const out = [];
12156
+ const cmp = this.#core.comparator;
12157
+ for (const k of keys) {
12158
+ if (k === void 0) continue;
12159
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12160
+ if (!highInclusive && cmp(k, high) === 0) continue;
12161
+ out.push(k);
12162
+ }
12163
+ return out;
12164
+ }
12165
+ };
12166
+
12167
+ // src/data-structures/binary-tree/tree-multi-map.ts
12168
+ var TreeMultiMapNode = class extends RedBlackTreeNode {
12169
+ static {
12170
+ __name(this, "TreeMultiMapNode");
12171
+ }
12172
+ constructor(key, value = []) {
12173
+ super(key, value);
12174
+ }
12175
+ };
12176
+ var TreeMultiMap = class _TreeMultiMap {
12177
+ static {
12178
+ __name(this, "TreeMultiMap");
12179
+ }
12180
+ #core;
12181
+ #isDefaultComparator;
12182
+ /**
12183
+ * Creates a new TreeMultiMap.
12184
+ * @param keysNodesEntriesOrRaws - Initial entries
12185
+ * @param options - Configuration options
12186
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial entries
12187
+ */
12188
+ constructor(keysNodesEntriesOrRaws = [], options = {}) {
12189
+ const comparator = options.comparator ?? TreeSet.createDefaultComparator();
12190
+ this.#isDefaultComparator = options.comparator === void 0;
12191
+ this.#core = new RedBlackTree([], { ...options, comparator, isMapMode: options.isMapMode });
12192
+ for (const x of keysNodesEntriesOrRaws) {
12193
+ if (x === null || x === void 0) continue;
12194
+ if (Array.isArray(x)) {
12195
+ const [k, bucket] = x;
12196
+ if (k === null || k === void 0) continue;
12197
+ if (bucket !== void 0) {
12198
+ this.#core.set(k, [...bucket]);
12199
+ } else {
12200
+ this.#core.set(k, []);
12201
+ }
12202
+ continue;
12203
+ }
12204
+ this.#core.set(x, []);
12205
+ }
12249
12206
  }
12250
12207
  /**
12251
- * Sets the color of the node.
12208
+ * Validates the key against the default comparator rules.
12252
12209
  * @remarks Time O(1), Space O(1)
12253
- *
12254
- * @param value - The new color.
12255
12210
  */
12256
- set color(value) {
12257
- this._color = value;
12211
+ _validateKey(key) {
12212
+ if (!this.#isDefaultComparator) return;
12213
+ if (typeof key === "number") {
12214
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiMap: NaN is not a valid key");
12215
+ return;
12216
+ }
12217
+ if (typeof key === "string") return;
12218
+ if (key instanceof Date) {
12219
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiMap: invalid Date key");
12220
+ return;
12221
+ }
12222
+ throw new TypeError("TreeMultiMap: comparator is required for non-number/non-string/non-Date keys");
12258
12223
  }
12259
- _count = 1;
12260
12224
  /**
12261
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12225
+ * Number of distinct keys.
12262
12226
  * @remarks Time O(1), Space O(1)
12263
- *
12264
- * @returns The subtree node count.
12265
12227
  */
12266
- get count() {
12267
- return this._count;
12228
+ get size() {
12229
+ return this.#core.size;
12268
12230
  }
12269
12231
  /**
12270
- * Sets the count of nodes in the subtree.
12232
+ * Whether the map is empty.
12271
12233
  * @remarks Time O(1), Space O(1)
12272
- *
12273
- * @param value - The new count.
12274
12234
  */
12275
- set count(value) {
12276
- this._count = value;
12235
+ isEmpty() {
12236
+ return this.size === 0;
12277
12237
  }
12278
12238
  /**
12279
- * Gets the position of the node relative to its parent.
12239
+ * Removes all entries from the map.
12280
12240
  * @remarks Time O(1), Space O(1)
12281
- *
12282
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12283
12241
  */
12284
- get familyPosition() {
12285
- if (!this.parent) {
12286
- return this.left || this.right ? "ROOT" : "ISOLATED";
12287
- }
12288
- if (this.parent.left === this) {
12289
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12290
- } else if (this.parent.right === this) {
12291
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12292
- }
12293
- return "MAL_NODE";
12242
+ clear() {
12243
+ this.#core.clear();
12294
12244
  }
12295
- };
12296
- var TreeMultiMap = class extends RedBlackTree {
12297
- static {
12298
- __name(this, "TreeMultiMap");
12245
+ /**
12246
+ * Bucket length for a key (missing => 0).
12247
+ * @remarks Time O(log n), Space O(1)
12248
+ */
12249
+ count(key) {
12250
+ const b = this.get(key);
12251
+ return Array.isArray(b) ? b.length : 0;
12299
12252
  }
12300
12253
  /**
12301
- * Create a TreeMultiMap and optionally bulk-insert items.
12302
- * @remarks Time O(N log N), Space O(N)
12303
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12304
- * @param [options] - Options for TreeMultiMap (comparator, reverse, map mode).
12305
- * @returns New TreeMultiMap instance.
12254
+ * Total number of values across all buckets (Σ bucket.length).
12255
+ * @remarks Time O(n), Space O(1)
12306
12256
  */
12307
- constructor(keysNodesEntriesOrRaws = [], options) {
12308
- super([], { ...options });
12309
- if (keysNodesEntriesOrRaws) {
12310
- this.setMany(keysNodesEntriesOrRaws);
12311
- }
12257
+ get totalSize() {
12258
+ let sum = 0;
12259
+ for (const [, bucket] of this) sum += bucket.length;
12260
+ return sum;
12312
12261
  }
12313
- createNode(key, value = []) {
12314
- return new TreeMultiMapNode(key, this._isMapMode ? [] : value);
12262
+ /**
12263
+ * Whether the map contains the given key.
12264
+ * @remarks Time O(log n), Space O(1)
12265
+ */
12266
+ has(key) {
12267
+ this._validateKey(key);
12268
+ return this.#core.has(key);
12315
12269
  }
12316
12270
  /**
12317
- * Checks if the given item is a `TreeMultiMapNode` instance.
12318
- * @remarks Time O(1), Space O(1)
12319
- *
12320
- * @param keyNodeOrEntry - The item to check.
12321
- * @returns True if it's a TreeMultiMapNode, false otherwise.
12271
+ * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
12272
+ * @remarks Time O(log n), Space O(1)
12322
12273
  */
12323
- isNode(keyNodeOrEntry) {
12324
- return keyNodeOrEntry instanceof TreeMultiMapNode;
12274
+ get(key) {
12275
+ this._validateKey(key);
12276
+ return this.#core.get(key);
12325
12277
  }
12326
12278
  /**
12327
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12328
- * @remarks Time O(log N + M), Space O(1)
12329
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12330
- * @param [value] - Single value to set when a bare key is provided.
12331
- * @returns True if inserted or appended; false if ignored.
12279
+ * Append a single value.
12280
+ * @remarks Time O(log n), Space O(1)
12332
12281
  */
12333
- set(keyNodeOrEntry, value) {
12334
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12335
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12336
- if (key === void 0 || key === null) return false;
12337
- const _setToValues = /* @__PURE__ */ __name(() => {
12338
- const existingValues = this.get(key);
12339
- if (existingValues !== void 0 && values !== void 0) {
12340
- for (const value2 of values) existingValues.push(value2);
12341
- return true;
12342
- }
12343
- return false;
12344
- }, "_setToValues");
12345
- const _setByNode = /* @__PURE__ */ __name(() => {
12346
- const existingNode = this.getNode(key);
12347
- if (this.isRealNode(existingNode)) {
12348
- const existingValues = this.get(existingNode);
12349
- if (existingValues === void 0) {
12350
- super.set(key, values);
12351
- return true;
12352
- }
12353
- if (values !== void 0) {
12354
- for (const value2 of values) existingValues.push(value2);
12355
- return true;
12356
- } else {
12357
- return false;
12358
- }
12359
- } else {
12360
- return super.set(key, values);
12361
- }
12362
- }, "_setByNode");
12363
- if (this._isMapMode) {
12364
- return _setByNode() || _setToValues();
12282
+ add(key, value) {
12283
+ this._validateKey(key);
12284
+ const bucket = this.#core.get(key);
12285
+ if (bucket) {
12286
+ bucket.push(value);
12287
+ return true;
12288
+ }
12289
+ return this.#core.set(key, [value]);
12290
+ }
12291
+ set(entry, value) {
12292
+ if (entry === null || entry === void 0) return false;
12293
+ if (Array.isArray(entry)) {
12294
+ const [k, bucket] = entry;
12295
+ if (k === null || k === void 0) return false;
12296
+ if (value !== void 0) return this.add(k, value);
12297
+ if (bucket === void 0) {
12298
+ return this.#core.set(k, []);
12365
12299
  }
12366
- return _setToValues() || _setByNode();
12367
- }, "_commonAdd");
12368
- if (this.isEntry(keyNodeOrEntry)) {
12369
- const [key, values] = keyNodeOrEntry;
12370
- return _commonAdd(key, value !== void 0 ? [value] : values);
12300
+ const existing = this.#core.get(k);
12301
+ if (existing) {
12302
+ existing.push(...bucket);
12303
+ return true;
12304
+ }
12305
+ return this.#core.set(k, [...bucket]);
12371
12306
  }
12372
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12307
+ if (value !== void 0) return this.add(entry, value);
12308
+ return this.#core.set(entry, []);
12373
12309
  }
12374
12310
  /**
12375
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12376
- * @remarks Time O(log N), Space O(1)
12377
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12378
- * @param value - Value to remove from the bucket.
12379
- * @returns True if the value was removed; false if not found.
12380
- */
12381
- deleteValue(keyNodeOrEntry, value) {
12382
- const values = this.get(keyNodeOrEntry);
12383
- if (Array.isArray(values)) {
12384
- const index = values.indexOf(value);
12385
- if (index === -1) return false;
12386
- values.splice(index, 1);
12387
- if (values.length === 0) this.delete(keyNodeOrEntry);
12388
- return true;
12389
- }
12390
- return false;
12311
+ * Deletes a key and its entire bucket.
12312
+ * @remarks Time O(log n), Space O(1)
12313
+ */
12314
+ delete(key) {
12315
+ this._validateKey(key);
12316
+ return this.#core.delete(key).length > 0;
12391
12317
  }
12392
12318
  /**
12393
- * Create a new tree by mapping each [key, values] bucket.
12394
- * @remarks Time O(N log N), Space O(N)
12395
- * @template MK
12396
- * @template MV
12397
- * @template MR
12398
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12399
- * @param [options] - Options for the output tree.
12400
- * @param [thisArg] - Value for `this` inside the callback.
12401
- * @returns A new RedBlackTree (or TreeMultiMap when mapping to array values; see overloads).
12319
+ * Check if a specific value exists in a key's bucket.
12320
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12402
12321
  */
12403
- map(callback, options, thisArg) {
12404
- const out = this._createLike([], options);
12405
- let i = 0;
12406
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12407
- return out;
12322
+ hasEntry(key, value, eq = Object.is) {
12323
+ const bucket = this.get(key);
12324
+ if (!Array.isArray(bucket)) return false;
12325
+ return bucket.some((v) => eq(v, value));
12408
12326
  }
12409
12327
  /**
12410
- * (Protected) Create an empty instance of the same concrete class.
12411
- * @remarks Time O(1), Space O(1)
12412
- * @template TK
12413
- * @template TV
12414
- * @template TR
12415
- * @param [options] - Optional constructor options for the like-kind instance.
12416
- * @returns An empty like-kind instance.
12328
+ * Delete a single occurrence of a value from a key's bucket.
12329
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12417
12330
  */
12418
- _createInstance(options) {
12419
- const Ctor = this.constructor;
12420
- return new Ctor([], { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12331
+ deleteValue(key, value, eq = Object.is) {
12332
+ const bucket = this.get(key);
12333
+ if (!Array.isArray(bucket)) return false;
12334
+ const idx = bucket.findIndex((v) => eq(v, value));
12335
+ if (idx === -1) return false;
12336
+ bucket.splice(idx, 1);
12337
+ if (bucket.length === 0) this.delete(key);
12338
+ return true;
12421
12339
  }
12422
12340
  /**
12423
- * (Protected) Create a like-kind instance and seed it from an iterable.
12424
- * @remarks Time O(N log N), Space O(N)
12425
- * @template TK
12426
- * @template TV
12427
- * @template TR
12428
- * @param iter - Iterable used to seed the new tree.
12429
- * @param [options] - Options merged with the current snapshot.
12430
- * @returns A like-kind RedBlackTree built from the iterable.
12341
+ * Delete all occurrences of a value from a key's bucket.
12342
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12431
12343
  */
12432
- _createLike(iter = [], options) {
12433
- const Ctor = this.constructor;
12434
- return new Ctor(iter, { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12344
+ deleteValues(key, value, eq = Object.is) {
12345
+ const bucket = this.get(key);
12346
+ if (!Array.isArray(bucket) || bucket.length === 0) return 0;
12347
+ let removed = 0;
12348
+ for (let i = bucket.length - 1; i >= 0; i--) {
12349
+ if (eq(bucket[i], value)) {
12350
+ bucket.splice(i, 1);
12351
+ removed++;
12352
+ }
12353
+ }
12354
+ if (bucket.length === 0 && removed > 0) this.delete(key);
12355
+ return removed;
12435
12356
  }
12436
- };
12437
-
12438
- // src/data-structures/binary-tree/tree-counter.ts
12439
- var TreeCounterNode = class {
12440
- static {
12441
- __name(this, "TreeCounterNode");
12357
+ // ---- iteration (bucket view) ----
12358
+ /**
12359
+ * Iterates over all entries as [key, bucket] pairs.
12360
+ * @remarks Time O(n), Space O(1)
12361
+ */
12362
+ *[Symbol.iterator]() {
12363
+ for (const [k, v] of this.#core) {
12364
+ yield [k, v ?? []];
12365
+ }
12442
12366
  }
12443
- key;
12444
- value;
12445
- parent = void 0;
12446
12367
  /**
12447
- * Create a tree counter node.
12448
- * @remarks Time O(1), Space O(1)
12449
- * @param key - Key of the node.
12450
- * @param [value] - Value associated with the key (ignored in map mode).
12451
- * @param [count] - Initial count for this node (default 1).
12452
- * @param color - Initial color ('RED' or 'BLACK').
12453
- * @returns New TreeCounterNode instance.
12368
+ * Iterates over all keys.
12369
+ * @remarks Time O(n), Space O(1)
12454
12370
  */
12455
- constructor(key, value, count = 1, color = "BLACK") {
12456
- this.key = key;
12457
- this.value = value;
12458
- this.color = color;
12459
- this.count = count;
12371
+ *keys() {
12372
+ yield* this.#core.keys();
12460
12373
  }
12461
- _left = void 0;
12462
12374
  /**
12463
- * Get the left child pointer.
12464
- * @remarks Time O(1), Space O(1)
12465
- * @returns Left child node, or null/undefined.
12375
+ * Iterates over all buckets.
12376
+ * @remarks Time O(n), Space O(1)
12466
12377
  */
12467
- get left() {
12468
- return this._left;
12378
+ *values() {
12379
+ for (const [, bucket] of this) yield bucket;
12469
12380
  }
12381
+ // ---- entry-flat views ----
12470
12382
  /**
12471
- * Set the left child and update its parent pointer.
12472
- * @remarks Time O(1), Space O(1)
12473
- * @param v - New left child node, or null/undefined.
12474
- * @returns void
12383
+ * Iterates over all entries for a specific key.
12384
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12475
12385
  */
12476
- set left(v) {
12477
- if (v) {
12478
- v.parent = this;
12479
- }
12480
- this._left = v;
12386
+ *entriesOf(key) {
12387
+ const bucket = this.get(key);
12388
+ if (!Array.isArray(bucket)) return;
12389
+ for (const v of bucket) yield [key, v];
12481
12390
  }
12482
- _right = void 0;
12483
12391
  /**
12484
- * Get the right child pointer.
12485
- * @remarks Time O(1), Space O(1)
12486
- * @returns Right child node, or null/undefined.
12392
+ * Iterates over all values for a specific key.
12393
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12487
12394
  */
12488
- get right() {
12489
- return this._right;
12395
+ *valuesOf(key) {
12396
+ const bucket = this.get(key);
12397
+ if (!Array.isArray(bucket)) return;
12398
+ yield* bucket;
12490
12399
  }
12491
12400
  /**
12492
- * Set the right child and update its parent pointer.
12493
- * @remarks Time O(1), Space O(1)
12494
- * @param v - New right child node, or null/undefined.
12495
- * @returns void
12401
+ * Iterates over all [key, value] pairs (flattened from buckets).
12402
+ * @remarks Time O(T), Space O(1) where T is totalSize
12496
12403
  */
12497
- set right(v) {
12498
- if (v) {
12499
- v.parent = this;
12404
+ *flatEntries() {
12405
+ for (const [k, bucket] of this) {
12406
+ for (const v of bucket) yield [k, v];
12500
12407
  }
12501
- this._right = v;
12502
12408
  }
12503
- _height = 0;
12409
+ // ━━━ Navigable methods (return [K, V[]] | undefined) ━━━
12504
12410
  /**
12505
- * Gets the height of the node (used in self-balancing trees).
12506
- * @remarks Time O(1), Space O(1)
12507
- *
12508
- * @returns The height.
12411
+ * Returns the entry with the smallest key.
12412
+ * @remarks Time O(log n), Space O(1)
12413
+ * @example
12414
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12415
+ * map.first(); // [1, ['a']]
12509
12416
  */
12510
- get height() {
12511
- return this._height;
12417
+ first() {
12418
+ const k = this.#core.getLeftMost();
12419
+ if (k === void 0) return void 0;
12420
+ const b = this.get(k);
12421
+ return b === void 0 ? void 0 : [k, b];
12512
12422
  }
12513
12423
  /**
12514
- * Sets the height of the node.
12515
- * @remarks Time O(1), Space O(1)
12516
- *
12517
- * @param value - The new height.
12424
+ * Returns the entry with the largest key.
12425
+ * @remarks Time O(log n), Space O(1)
12426
+ * @example
12427
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12428
+ * map.last(); // [2, ['b']]
12518
12429
  */
12519
- set height(value) {
12520
- this._height = value;
12430
+ last() {
12431
+ const k = this.#core.getRightMost();
12432
+ if (k === void 0) return void 0;
12433
+ const b = this.get(k);
12434
+ return b === void 0 ? void 0 : [k, b];
12521
12435
  }
12522
- _color = "BLACK";
12523
12436
  /**
12524
- * Gets the color of the node (used in Red-Black trees).
12525
- * @remarks Time O(1), Space O(1)
12526
- *
12527
- * @returns The node's color.
12437
+ * Removes and returns the entry with the smallest key.
12438
+ * @remarks Time O(log n), Space O(1)
12439
+ * @example
12440
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12441
+ * map.pollFirst(); // [1, ['a']]
12442
+ * map.has(1); // false
12528
12443
  */
12529
- get color() {
12530
- return this._color;
12444
+ pollFirst() {
12445
+ const e = this.first();
12446
+ if (!e) return void 0;
12447
+ this.delete(e[0]);
12448
+ return e;
12531
12449
  }
12532
12450
  /**
12533
- * Sets the color of the node.
12534
- * @remarks Time O(1), Space O(1)
12535
- *
12536
- * @param value - The new color.
12451
+ * Removes and returns the entry with the largest key.
12452
+ * @remarks Time O(log n), Space O(1)
12453
+ * @example
12454
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12455
+ * map.pollLast(); // [2, ['b']]
12456
+ * map.has(2); // false
12537
12457
  */
12538
- set color(value) {
12539
- this._color = value;
12458
+ pollLast() {
12459
+ const e = this.last();
12460
+ if (!e) return void 0;
12461
+ this.delete(e[0]);
12462
+ return e;
12540
12463
  }
12541
- _count = 1;
12542
12464
  /**
12543
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12544
- * @remarks Time O(1), Space O(1)
12545
- *
12546
- * @returns The subtree node count.
12465
+ * Returns the entry with the smallest key >= given key.
12466
+ * @remarks Time O(log n), Space O(1)
12467
+ * @example
12468
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12469
+ * map.ceiling(15); // [20, ['b']]
12470
+ * map.ceiling(20); // [20, ['b']]
12547
12471
  */
12548
- get count() {
12549
- return this._count;
12472
+ ceiling(key) {
12473
+ this._validateKey(key);
12474
+ const k = this.#core.ceiling(key);
12475
+ if (k === void 0) return void 0;
12476
+ const b = this.get(k);
12477
+ return b === void 0 ? void 0 : [k, b];
12550
12478
  }
12551
12479
  /**
12552
- * Sets the count of nodes in the subtree.
12553
- * @remarks Time O(1), Space O(1)
12554
- *
12555
- * @param value - The new count.
12480
+ * Returns the entry with the largest key <= given key.
12481
+ * @remarks Time O(log n), Space O(1)
12482
+ * @example
12483
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12484
+ * map.floor(25); // [20, ['b']]
12485
+ * map.floor(20); // [20, ['b']]
12486
+ */
12487
+ floor(key) {
12488
+ this._validateKey(key);
12489
+ const k = this.#core.floor(key);
12490
+ if (k === void 0) return void 0;
12491
+ const b = this.get(k);
12492
+ return b === void 0 ? void 0 : [k, b];
12493
+ }
12494
+ /**
12495
+ * Returns the entry with the smallest key > given key.
12496
+ * @remarks Time O(log n), Space O(1)
12497
+ * @example
12498
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12499
+ * map.higher(10); // [20, ['b']]
12500
+ * map.higher(15); // [20, ['b']]
12556
12501
  */
12557
- set count(value) {
12558
- this._count = value;
12502
+ higher(key) {
12503
+ this._validateKey(key);
12504
+ const k = this.#core.higher(key);
12505
+ if (k === void 0) return void 0;
12506
+ const b = this.get(k);
12507
+ return b === void 0 ? void 0 : [k, b];
12559
12508
  }
12560
12509
  /**
12561
- * Gets the position of the node relative to its parent.
12562
- * @remarks Time O(1), Space O(1)
12563
- *
12564
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12510
+ * Returns the entry with the largest key < given key.
12511
+ * @remarks Time O(log n), Space O(1)
12512
+ * @example
12513
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12514
+ * map.lower(20); // [10, ['a']]
12515
+ * map.lower(15); // [10, ['a']]
12565
12516
  */
12566
- get familyPosition() {
12567
- if (!this.parent) {
12568
- return this.left || this.right ? "ROOT" : "ISOLATED";
12517
+ lower(key) {
12518
+ this._validateKey(key);
12519
+ const k = this.#core.lower(key);
12520
+ if (k === void 0) return void 0;
12521
+ const b = this.get(k);
12522
+ return b === void 0 ? void 0 : [k, b];
12523
+ }
12524
+ // ━━━ Tree utilities ━━━
12525
+ /**
12526
+ * Prints the internal tree structure (for debugging).
12527
+ * @remarks Time O(n), Space O(n)
12528
+ */
12529
+ print(...args) {
12530
+ return this.#core.print(...args);
12531
+ }
12532
+ /**
12533
+ * Executes a callback for each entry.
12534
+ * @remarks Time O(n), Space O(1)
12535
+ */
12536
+ forEach(callback) {
12537
+ for (const [k, v] of this) {
12538
+ callback(v, k, this);
12569
12539
  }
12570
- if (this.parent.left === this) {
12571
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12572
- } else if (this.parent.right === this) {
12573
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12540
+ }
12541
+ /**
12542
+ * Creates a new map with entries that pass the predicate.
12543
+ * @remarks Time O(n), Space O(n)
12544
+ */
12545
+ filter(predicate) {
12546
+ const filtered = [];
12547
+ for (const [k, v] of this) {
12548
+ if (predicate(v, k, this)) filtered.push([k, v]);
12574
12549
  }
12575
- return "MAL_NODE";
12550
+ return new _TreeMultiMap(filtered, { comparator: this.comparator });
12576
12551
  }
12577
- };
12578
- var TreeCounter = class extends RedBlackTree {
12579
- static {
12580
- __name(this, "TreeCounter");
12552
+ /**
12553
+ * Creates a new map by transforming each entry.
12554
+ * @remarks Time O(n log n), Space O(n)
12555
+ */
12556
+ map(mapper) {
12557
+ const mapped = [];
12558
+ for (const [k, v] of this) {
12559
+ mapped.push(mapper(v, k, this));
12560
+ }
12561
+ return new _TreeMultiMap(mapped, { comparator: this.comparator });
12581
12562
  }
12582
12563
  /**
12583
- * Create a TreeCounter and optionally bulk-insert items.
12584
- * @remarks Time O(N log N), Space O(N)
12585
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12586
- * @param [options] - Options for TreeCounter (comparator, reverse, map mode).
12587
- * @returns New TreeCounter instance.
12564
+ * Reduces all entries to a single value.
12565
+ * @remarks Time O(n), Space O(1)
12588
12566
  */
12589
- constructor(keysNodesEntriesOrRaws = [], options) {
12590
- super([], options);
12591
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
12567
+ reduce(callback, initialValue) {
12568
+ let acc = initialValue;
12569
+ for (const [k, v] of this) {
12570
+ acc = callback(acc, v, k, this);
12571
+ }
12572
+ return acc;
12592
12573
  }
12593
- _count = 0;
12594
12574
  /**
12595
- * Get the total aggregate count across all nodes.
12596
- * @remarks Time O(1), Space O(1)
12597
- * @returns Total count.
12575
+ * Sets multiple entries at once.
12576
+ * @remarks Time O(m log n), Space O(m) where m is input size
12598
12577
  */
12599
- get count() {
12600
- return this._count;
12578
+ setMany(keysNodesEntriesOrRaws) {
12579
+ const results = [];
12580
+ for (const x of keysNodesEntriesOrRaws) {
12581
+ results.push(this.set(x, void 0));
12582
+ }
12583
+ return results;
12601
12584
  }
12602
12585
  /**
12603
- * Compute the total count by traversing the tree (sums node.count).
12604
- * @remarks Time O(N), Space O(H)
12605
- * @returns Total count recomputed from nodes.
12586
+ * Searches for entries within a key range.
12587
+ * @remarks Time O(log n + k), Space O(k) where k is result size
12606
12588
  */
12607
- getComputedCount() {
12608
- let sum = 0;
12609
- this.dfs((node) => sum += node ? node.count : 0);
12610
- return sum;
12589
+ rangeSearch(range, callback, isBalanced) {
12590
+ return this.#core.rangeSearch(range, callback, isBalanced);
12611
12591
  }
12612
- createNode(key, value, color = "BLACK", count) {
12613
- return new TreeCounterNode(key, this._isMapMode ? void 0 : value, count, color);
12592
+ /**
12593
+ * Creates a shallow clone of this map.
12594
+ * @remarks Time O(n log n), Space O(n)
12595
+ */
12596
+ clone() {
12597
+ return new _TreeMultiMap(this, { comparator: this.comparator, isMapMode: this.#core._isMapMode });
12614
12598
  }
12615
12599
  /**
12616
- * Type guard: check whether the input is a TreeCounterNode.
12600
+ * Expose comparator for advanced usage/testing (read-only).
12617
12601
  * @remarks Time O(1), Space O(1)
12618
- * @returns True if the value is a TreeCounterNode.
12619
12602
  */
12620
- isNode(keyNodeOrEntry) {
12621
- return keyNodeOrEntry instanceof TreeCounterNode;
12603
+ get comparator() {
12604
+ return this.#core._comparator;
12605
+ }
12606
+ };
12607
+
12608
+ // src/data-structures/binary-tree/tree-map.ts
12609
+ var TreeMap = class _TreeMap {
12610
+ static {
12611
+ __name(this, "TreeMap");
12622
12612
  }
12613
+ #core;
12614
+ #isDefaultComparator;
12615
+ #userComparator;
12623
12616
  /**
12624
- * Insert or increment a node and update aggregate count.
12625
- * @remarks Time O(log N), Space O(1)
12626
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
12627
- * @param [value] - Value when a bare key is provided (ignored in map mode).
12628
- * @param [count] - How much to increase the node's count (default 1).
12629
- * @returns True if inserted/updated; false if ignored.
12630
- */
12631
- set(keyNodeOrEntry, value, count = 1) {
12632
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
12633
- const orgCount = newNode?.count || 0;
12634
- const isSuccessAdded = super.set(newNode, newValue);
12635
- if (isSuccessAdded) {
12636
- this._count += orgCount;
12637
- return true;
12638
- } else {
12639
- return false;
12617
+ * Create a TreeMap from an iterable of `[key, value]` entries.
12618
+ *
12619
+ * @throws {TypeError} If any entry is not a 2-tuple-like value, or when using the default comparator
12620
+ * and encountering unsupported/invalid keys (e.g. `NaN`, invalid `Date`).
12621
+ */
12622
+ constructor(entries = [], options = {}) {
12623
+ this.#userComparator = options.comparator;
12624
+ const comparator = options.comparator ?? _TreeMap.createDefaultComparator();
12625
+ this.#isDefaultComparator = options.comparator === void 0;
12626
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
12627
+ for (const item of entries) {
12628
+ if (!Array.isArray(item) || item.length < 2) {
12629
+ throw new TypeError("TreeMap: each entry must be a [key, value] tuple");
12630
+ }
12631
+ const k = item[0];
12632
+ const v = item[1];
12633
+ this.set(k, v);
12640
12634
  }
12641
12635
  }
12642
12636
  /**
12643
- * Delete a node (or decrement its count) and rebalance if needed.
12644
- * @remarks Time O(log N), Space O(1)
12645
- * @param keyNodeEntryRawOrPredicate - Key, node, or [key, value] entry identifying the node.
12646
- * @param [ignoreCount] - If true, remove the node regardless of its count.
12647
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
12637
+ * Create the strict default comparator.
12638
+ *
12639
+ * Supports:
12640
+ * - `number` (rejects `NaN`; treats `-0` and `0` as equal)
12641
+ * - `string`
12642
+ * - `Date` (orders by `getTime()`, rejects invalid dates)
12643
+ *
12644
+ * For other key types, a custom comparator must be provided.
12648
12645
  */
12649
- delete(keyNodeEntryRawOrPredicate, ignoreCount = false) {
12650
- if (keyNodeEntryRawOrPredicate === null) return [];
12651
- const results = [];
12652
- let nodeToDelete;
12653
- if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);
12654
- else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);
12655
- if (!nodeToDelete) {
12656
- return results;
12657
- }
12658
- let originalColor = nodeToDelete.color;
12659
- let replacementNode;
12660
- if (!this.isRealNode(nodeToDelete.left)) {
12661
- if (nodeToDelete.right !== null) replacementNode = nodeToDelete.right;
12662
- if (ignoreCount || nodeToDelete.count <= 1) {
12663
- if (nodeToDelete.right !== null) {
12664
- this._transplant(nodeToDelete, nodeToDelete.right);
12665
- this._count -= nodeToDelete.count;
12666
- }
12667
- } else {
12668
- nodeToDelete.count--;
12669
- this._count--;
12670
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12671
- return results;
12672
- }
12673
- } else if (!this.isRealNode(nodeToDelete.right)) {
12674
- replacementNode = nodeToDelete.left;
12675
- if (ignoreCount || nodeToDelete.count <= 1) {
12676
- this._transplant(nodeToDelete, nodeToDelete.left);
12677
- this._count -= nodeToDelete.count;
12678
- } else {
12679
- nodeToDelete.count--;
12680
- this._count--;
12681
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12682
- return results;
12683
- }
12684
- } else {
12685
- const successor = this.getLeftMost((node) => node, nodeToDelete.right);
12686
- if (successor) {
12687
- originalColor = successor.color;
12688
- if (successor.right !== null) replacementNode = successor.right;
12689
- if (successor.parent === nodeToDelete) {
12690
- if (this.isRealNode(replacementNode)) {
12691
- replacementNode.parent = successor;
12692
- }
12693
- } else {
12694
- if (ignoreCount || nodeToDelete.count <= 1) {
12695
- if (successor.right !== null) {
12696
- this._transplant(successor, successor.right);
12697
- }
12698
- } else {
12699
- nodeToDelete.count--;
12700
- this._count--;
12701
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12702
- return results;
12703
- }
12704
- successor.right = nodeToDelete.right;
12705
- if (this.isRealNode(successor.right)) {
12706
- successor.right.parent = successor;
12707
- }
12708
- }
12709
- if (ignoreCount || nodeToDelete.count <= 1) {
12710
- this._transplant(nodeToDelete, successor);
12711
- this._count -= nodeToDelete.count;
12712
- } else {
12713
- nodeToDelete.count--;
12714
- this._count--;
12715
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12716
- return results;
12717
- }
12718
- successor.left = nodeToDelete.left;
12719
- if (this.isRealNode(successor.left)) {
12720
- successor.left.parent = successor;
12721
- }
12722
- successor.color = nodeToDelete.color;
12723
- }
12646
+ static createDefaultComparator() {
12647
+ return (a, b) => {
12648
+ if (typeof a === "number" && typeof b === "number") {
12649
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeMap: NaN is not a valid key");
12650
+ const aa = Object.is(a, -0) ? 0 : a;
12651
+ const bb = Object.is(b, -0) ? 0 : b;
12652
+ return aa > bb ? 1 : aa < bb ? -1 : 0;
12653
+ }
12654
+ if (typeof a === "string" && typeof b === "string") {
12655
+ return a > b ? 1 : a < b ? -1 : 0;
12656
+ }
12657
+ if (a instanceof Date && b instanceof Date) {
12658
+ const ta = a.getTime();
12659
+ const tb = b.getTime();
12660
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeMap: invalid Date key");
12661
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
12662
+ }
12663
+ throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
12664
+ };
12665
+ }
12666
+ _validateKey(key) {
12667
+ if (!this.#isDefaultComparator) return;
12668
+ if (typeof key === "number") {
12669
+ if (Number.isNaN(key)) throw new TypeError("TreeMap: NaN is not a valid key");
12670
+ return;
12724
12671
  }
12725
- this._size--;
12726
- if (originalColor === "BLACK") {
12727
- this._deleteFixup(replacementNode);
12672
+ if (typeof key === "string") return;
12673
+ if (key instanceof Date) {
12674
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMap: invalid Date key");
12675
+ return;
12728
12676
  }
12729
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12730
- return results;
12677
+ throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
12731
12678
  }
12732
12679
  /**
12733
- * Remove all nodes and reset aggregate counters.
12734
- * @remarks Time O(N), Space O(1)
12735
- * @returns void
12680
+ * Number of entries in the map.
12681
+ */
12682
+ get size() {
12683
+ return this.#core.size;
12684
+ }
12685
+ /**
12686
+ * Whether the map is empty.
12687
+ */
12688
+ isEmpty() {
12689
+ return this.size === 0;
12690
+ }
12691
+ /**
12692
+ * Set or overwrite a value for a key.
12693
+ * @remarks Expected time O(log n)
12694
+ */
12695
+ set(key, value) {
12696
+ this._validateKey(key);
12697
+ this.#core.set(key, value);
12698
+ return this;
12699
+ }
12700
+ /**
12701
+ * Get the value under a key.
12702
+ * @remarks Expected time O(log n)
12703
+ */
12704
+ get(key) {
12705
+ this._validateKey(key);
12706
+ return this.#core.get(key);
12707
+ }
12708
+ /**
12709
+ * Test whether a key exists.
12710
+ * @remarks Expected time O(log n)
12711
+ */
12712
+ has(key) {
12713
+ this._validateKey(key);
12714
+ return this.#core.has(key);
12715
+ }
12716
+ /**
12717
+ * Delete a key.
12718
+ * @returns `true` if the key existed; otherwise `false`.
12719
+ * @remarks Expected time O(log n)
12720
+ */
12721
+ delete(key) {
12722
+ this._validateKey(key);
12723
+ const res = this.#core.delete(key);
12724
+ return Array.isArray(res) && res.length > 0 && !!res[0]?.deleted;
12725
+ }
12726
+ /**
12727
+ * Remove all entries.
12736
12728
  */
12737
12729
  clear() {
12738
- super.clear();
12739
- this._count = 0;
12730
+ this.#core.clear();
12740
12731
  }
12741
12732
  /**
12742
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12743
- * @remarks Time O(N), Space O(N)
12744
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12745
- * @returns True if rebalancing succeeded (tree not empty).
12733
+ * Iterate over keys in ascending order.
12746
12734
  */
12747
- perfectlyBalance(iterationType = this.iterationType) {
12748
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12749
- const n = nodes.length;
12750
- if (n < 1) return false;
12751
- let total = 0;
12752
- for (const nd of nodes) total += nd ? nd.count : 0;
12753
- this._clearNodes();
12754
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12755
- if (l > r) return void 0;
12756
- const m = l + (r - l >> 1);
12757
- const root = nodes[m];
12758
- const leftChild = build(l, m - 1, root);
12759
- const rightChild = build(m + 1, r, root);
12760
- root.left = leftChild;
12761
- root.right = rightChild;
12762
- root.parent = parent;
12763
- return root;
12764
- }, "build");
12765
- const newRoot = build(0, n - 1, void 0);
12766
- this._setRoot(newRoot);
12767
- this._size = n;
12768
- this._count = total;
12769
- return true;
12735
+ keys() {
12736
+ return this.#core.keys();
12737
+ }
12738
+ _entryFromKey(k) {
12739
+ return [k, this.#core.get(k)];
12770
12740
  }
12771
12741
  /**
12772
- * Create a new TreeCounter by mapping each [key, value] entry.
12773
- * @remarks Time O(N log N), Space O(N)
12774
- * @template MK
12775
- * @template MV
12776
- * @template MR
12777
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
12778
- * @param [options] - Options for the output tree.
12779
- * @param [thisArg] - Value for `this` inside the callback.
12780
- * @returns A new TreeCounter with mapped entries.
12742
+ * Iterate over values in ascending key order.
12743
+ *
12744
+ * Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
12781
12745
  */
12782
- map(callback, options, thisArg) {
12783
- const out = this._createLike([], options);
12746
+ *values() {
12747
+ for (const k of this.keys()) yield this._entryFromKey(k)[1];
12748
+ }
12749
+ /**
12750
+ * Iterate over `[key, value]` entries in ascending key order.
12751
+ *
12752
+ * Note: values may be `undefined`.
12753
+ */
12754
+ *entries() {
12755
+ for (const k of this.keys()) yield this._entryFromKey(k);
12756
+ }
12757
+ [Symbol.iterator]() {
12758
+ return this.entries();
12759
+ }
12760
+ /**
12761
+ * Visit each entry in ascending key order.
12762
+ *
12763
+ * Note: callback value may be `undefined`.
12764
+ */
12765
+ forEach(cb, thisArg) {
12766
+ for (const [k, v] of this) cb.call(thisArg, v, k, this);
12767
+ }
12768
+ /**
12769
+ * Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
12770
+ *
12771
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
12772
+ * @remarks Time O(n log n) expected, Space O(n)
12773
+ */
12774
+ map(callbackfn, options = {}, thisArg) {
12775
+ const out = new _TreeMap([], options);
12784
12776
  let index = 0;
12785
- for (const [key, value] of this) {
12786
- out.set(callback.call(thisArg, value, key, index++, this));
12777
+ for (const [k, v] of this) {
12778
+ const [mk, mv] = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12779
+ out.set(mk, mv);
12787
12780
  }
12788
12781
  return out;
12789
12782
  }
12790
12783
  /**
12791
- * Deep copy this tree, preserving map mode and aggregate counts.
12792
- * @remarks Time O(N), Space O(N)
12793
- * @returns A deep copy of this tree.
12784
+ * Create a new TreeMap containing only entries that satisfy the predicate.
12785
+ * @remarks Time O(n log n) expected, Space O(n)
12794
12786
  */
12795
- clone() {
12796
- const out = this._createInstance();
12797
- this._clone(out);
12798
- out._count = this._count;
12799
- for (const node of this.dfs((n) => n, "IN")) {
12800
- if (!node) continue;
12801
- const outNode = out.getNode(node.key);
12802
- if (outNode) outNode.count = node.count;
12787
+ filter(callbackfn, thisArg) {
12788
+ const out = new _TreeMap([], { comparator: this.#userComparator });
12789
+ let index = 0;
12790
+ for (const [k, v] of this) {
12791
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12792
+ if (ok) out.set(k, v);
12803
12793
  }
12804
12794
  return out;
12805
12795
  }
12806
12796
  /**
12807
- * (Protected) Create an empty instance of the same concrete class.
12808
- * @remarks Time O(1), Space O(1)
12809
- * @template TK
12810
- * @template TV
12811
- * @template TR
12812
- * @param [options] - Optional constructor options for the like-kind instance.
12813
- * @returns An empty like-kind instance.
12797
+ * Reduce entries into a single accumulator.
12798
+ * @remarks Time O(n), Space O(1)
12814
12799
  */
12815
- _createInstance(options) {
12816
- const Ctor = this.constructor;
12817
- return new Ctor([], { ...this._snapshotOptions(), ...options ?? {} });
12800
+ reduce(callbackfn, initialValue) {
12801
+ let acc = initialValue;
12802
+ let index = 0;
12803
+ for (const [k, v] of this) acc = callbackfn(acc, v, k, index++, this);
12804
+ return acc;
12818
12805
  }
12819
12806
  /**
12820
- * (Protected) Create a like-kind instance and seed it from an iterable.
12821
- * @remarks Time O(N log N), Space O(N)
12822
- * @template TK
12823
- * @template TV
12824
- * @template TR
12825
- * @param iter - Iterable used to seed the new tree.
12826
- * @param [options] - Options merged with the current snapshot.
12827
- * @returns A like-kind TreeCounter built from the iterable.
12807
+ * Test whether all entries satisfy a predicate.
12808
+ * @remarks Time O(n), Space O(1)
12828
12809
  */
12829
- _createLike(iter = [], options) {
12830
- const Ctor = this.constructor;
12831
- return new Ctor(iter, {
12832
- ...this._snapshotOptions(),
12833
- ...options ?? {}
12834
- });
12810
+ every(callbackfn, thisArg) {
12811
+ let index = 0;
12812
+ for (const [k, v] of this) {
12813
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12814
+ if (!ok) return false;
12815
+ }
12816
+ return true;
12835
12817
  }
12836
12818
  /**
12837
- * (Protected) Normalize input into a node plus its effective value and count.
12838
- * @remarks Time O(1), Space O(1)
12839
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
12840
- * @param [value] - Value used when a bare key is provided.
12841
- * @param [count] - Count increment to apply (default 1).
12842
- * @returns Tuple [node, value] where node may be undefined.
12819
+ * Test whether any entry satisfies a predicate.
12820
+ * @remarks Time O(n), Space O(1)
12843
12821
  */
12844
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
12845
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
12846
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
12847
- if (this.isEntry(keyNodeOrEntry)) {
12848
- const [key, entryValue] = keyNodeOrEntry;
12849
- if (key === void 0 || key === null) return [void 0, void 0];
12850
- const finalValue = value ?? entryValue;
12851
- return [this.createNode(key, finalValue, "BLACK", count), finalValue];
12822
+ some(callbackfn, thisArg) {
12823
+ let index = 0;
12824
+ for (const [k, v] of this) {
12825
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12826
+ if (ok) return true;
12852
12827
  }
12853
- return [this.createNode(keyNodeOrEntry, value, "BLACK", count), value];
12828
+ return false;
12854
12829
  }
12855
12830
  /**
12856
- * (Protected) Swap keys/values/counters between the source and destination nodes.
12857
- * @remarks Time O(1), Space O(1)
12858
- * @param srcNode - Source node (or key) whose properties will be moved.
12859
- * @param destNode - Destination node (or key) to receive properties.
12860
- * @returns Destination node after swap, or undefined.
12831
+ * Find the first entry that satisfies a predicate.
12832
+ * @returns The first matching `[key, value]` tuple, or `undefined`.
12833
+ * @remarks Time O(n), Space O(1)
12861
12834
  */
12862
- _swapProperties(srcNode, destNode) {
12863
- srcNode = this.ensureNode(srcNode);
12864
- destNode = this.ensureNode(destNode);
12865
- if (srcNode && destNode) {
12866
- const { key, value, count, color } = destNode;
12867
- const tempNode = this.createNode(key, value, color, count);
12868
- if (tempNode) {
12869
- tempNode.color = color;
12870
- destNode.key = srcNode.key;
12871
- if (!this._isMapMode) destNode.value = srcNode.value;
12872
- destNode.count = srcNode.count;
12873
- destNode.color = srcNode.color;
12874
- srcNode.key = tempNode.key;
12875
- if (!this._isMapMode) srcNode.value = tempNode.value;
12876
- srcNode.count = tempNode.count;
12877
- srcNode.color = tempNode.color;
12878
- }
12879
- return destNode;
12835
+ find(callbackfn, thisArg) {
12836
+ let index = 0;
12837
+ for (const [k, v] of this) {
12838
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12839
+ if (ok) return [k, v];
12880
12840
  }
12881
12841
  return void 0;
12882
12842
  }
12883
12843
  /**
12884
- * (Protected) Replace one node by another and adjust counters accordingly.
12885
- * @remarks Time O(1), Space O(1)
12886
- * @param oldNode - Node being replaced.
12887
- * @param newNode - Replacement node.
12888
- * @returns The new node after replacement.
12844
+ * Materialize the map into an array of `[key, value]` tuples.
12845
+ * @remarks Time O(n), Space O(n)
12889
12846
  */
12890
- _replaceNode(oldNode, newNode) {
12891
- newNode.count = oldNode.count + newNode.count;
12892
- return super._replaceNode(oldNode, newNode);
12847
+ toArray() {
12848
+ return [...this];
12849
+ }
12850
+ /**
12851
+ * Print a human-friendly representation.
12852
+ * @remarks Time O(n), Space O(n)
12853
+ */
12854
+ print() {
12855
+ this.#core.print();
12856
+ }
12857
+ // Navigable operations (return entry tuples)
12858
+ // Note: returned tuple values may be `undefined`.
12859
+ /**
12860
+ * Smallest entry by key.
12861
+ */
12862
+ first() {
12863
+ const k = this.#core.getLeftMost();
12864
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12865
+ }
12866
+ /**
12867
+ * Largest entry by key.
12868
+ */
12869
+ last() {
12870
+ const k = this.#core.getRightMost();
12871
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12872
+ }
12873
+ /**
12874
+ * Remove and return the smallest entry.
12875
+ */
12876
+ pollFirst() {
12877
+ const entry = this.first();
12878
+ if (!entry) return void 0;
12879
+ this.delete(entry[0]);
12880
+ return entry;
12881
+ }
12882
+ /**
12883
+ * Remove and return the largest entry.
12884
+ */
12885
+ pollLast() {
12886
+ const entry = this.last();
12887
+ if (!entry) return void 0;
12888
+ this.delete(entry[0]);
12889
+ return entry;
12890
+ }
12891
+ /**
12892
+ * Smallest entry whose key is >= the given key.
12893
+ */
12894
+ ceiling(key) {
12895
+ this._validateKey(key);
12896
+ const k = this.#core.ceiling(key);
12897
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12898
+ }
12899
+ /**
12900
+ * Largest entry whose key is <= the given key.
12901
+ */
12902
+ floor(key) {
12903
+ this._validateKey(key);
12904
+ const k = this.#core.floor(key);
12905
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12906
+ }
12907
+ /**
12908
+ * Smallest entry whose key is > the given key.
12909
+ */
12910
+ higher(key) {
12911
+ this._validateKey(key);
12912
+ const k = this.#core.higher(key);
12913
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12914
+ }
12915
+ /**
12916
+ * Largest entry whose key is < the given key.
12917
+ */
12918
+ lower(key) {
12919
+ this._validateKey(key);
12920
+ const k = this.#core.lower(key);
12921
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12922
+ }
12923
+ /**
12924
+ * Return all entries in a given key range.
12925
+ *
12926
+ * @param range `[low, high]`
12927
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12928
+ */
12929
+ rangeSearch(range, options = {}) {
12930
+ const { lowInclusive = true, highInclusive = true } = options;
12931
+ const [low, high] = range;
12932
+ this._validateKey(low);
12933
+ this._validateKey(high);
12934
+ const keys = this.#core.rangeSearch([low, high]);
12935
+ const out = [];
12936
+ const cmp = this.#core.comparator;
12937
+ for (const k of keys) {
12938
+ if (k === void 0) continue;
12939
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12940
+ if (!highInclusive && cmp(k, high) === 0) continue;
12941
+ out.push(this._entryFromKey(k));
12942
+ }
12943
+ return out;
12893
12944
  }
12894
12945
  };
12895
12946
 
12896
- // src/data-structures/binary-tree/avl-tree-counter.ts
12897
- var AVLTreeCounterNode = class {
12947
+ // src/data-structures/binary-tree/tree-multi-set.ts
12948
+ var TreeMultiSet = class _TreeMultiSet {
12898
12949
  static {
12899
- __name(this, "AVLTreeCounterNode");
12950
+ __name(this, "TreeMultiSet");
12900
12951
  }
12901
- key;
12902
- value;
12903
- parent = void 0;
12952
+ #core;
12953
+ #isDefaultComparator;
12954
+ _size = 0;
12955
+ // total occurrences (sumCounts)
12904
12956
  /**
12905
- * Create an AVL counter node.
12957
+ * Creates a new TreeMultiSet.
12958
+ * @param elements - Initial elements to add
12959
+ * @param options - Configuration options
12960
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial elements
12961
+ */
12962
+ constructor(elements = [], options = {}) {
12963
+ const comparator = options.comparator ?? TreeSet.createDefaultComparator();
12964
+ this.#isDefaultComparator = options.comparator === void 0;
12965
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
12966
+ for (const k of elements) this.add(k);
12967
+ }
12968
+ /**
12969
+ * Validates the key against the default comparator rules.
12906
12970
  * @remarks Time O(1), Space O(1)
12907
- * @param key - Key of the node.
12908
- * @param [value] - Associated value (ignored in map mode).
12909
- * @param [count] - Initial count for this node (default 1).
12910
- * @returns New AVLTreeCounterNode instance.
12911
12971
  */
12912
- constructor(key, value, count = 1) {
12913
- this.key = key;
12914
- this.value = value;
12915
- this.count = count;
12972
+ _validateKey(key) {
12973
+ if (!this.#isDefaultComparator) return;
12974
+ if (typeof key === "number") {
12975
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiSet: NaN is not a valid key");
12976
+ return;
12977
+ }
12978
+ if (typeof key === "string") return;
12979
+ if (key instanceof Date) {
12980
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiSet: invalid Date key");
12981
+ return;
12982
+ }
12983
+ throw new TypeError("TreeMultiSet: comparator is required for non-number/non-string/non-Date keys");
12916
12984
  }
12917
- _left = void 0;
12918
12985
  /**
12919
- * Get the left child pointer.
12986
+ * Validates that count is a non-negative safe integer.
12920
12987
  * @remarks Time O(1), Space O(1)
12921
- * @returns Left child node, or null/undefined.
12922
12988
  */
12923
- get left() {
12924
- return this._left;
12989
+ _validateCount(n) {
12990
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError("TreeMultiSet: count must be a safe integer >= 0");
12925
12991
  }
12926
12992
  /**
12927
- * Set the left child and update its parent pointer.
12993
+ * Total occurrences (sumCounts).
12928
12994
  * @remarks Time O(1), Space O(1)
12929
- * @param v - New left child node, or null/undefined.
12930
- * @returns void
12931
12995
  */
12932
- set left(v) {
12933
- if (v) {
12934
- v.parent = this;
12935
- }
12936
- this._left = v;
12996
+ get size() {
12997
+ return this._size;
12937
12998
  }
12938
- _right = void 0;
12939
12999
  /**
12940
- * Get the right child pointer.
13000
+ * Number of distinct keys.
12941
13001
  * @remarks Time O(1), Space O(1)
12942
- * @returns Right child node, or null/undefined.
12943
13002
  */
12944
- get right() {
12945
- return this._right;
13003
+ get distinctSize() {
13004
+ return this.#core.size;
12946
13005
  }
12947
13006
  /**
12948
- * Set the right child and update its parent pointer.
13007
+ * Whether the multiset is empty.
12949
13008
  * @remarks Time O(1), Space O(1)
12950
- * @param v - New right child node, or null/undefined.
12951
- * @returns void
12952
13009
  */
12953
- set right(v) {
12954
- if (v) {
12955
- v.parent = this;
12956
- }
12957
- this._right = v;
13010
+ isEmpty() {
13011
+ return this.size === 0;
12958
13012
  }
12959
- _height = 0;
12960
13013
  /**
12961
- * Gets the height of the node (used in self-balancing trees).
12962
- * @remarks Time O(1), Space O(1)
12963
- *
12964
- * @returns The height.
13014
+ * Whether the multiset contains the given key.
13015
+ * @remarks Time O(log n), Space O(1)
12965
13016
  */
12966
- get height() {
12967
- return this._height;
13017
+ has(key) {
13018
+ this._validateKey(key);
13019
+ return this.count(key) > 0;
12968
13020
  }
12969
13021
  /**
12970
- * Sets the height of the node.
12971
- * @remarks Time O(1), Space O(1)
12972
- *
12973
- * @param value - The new height.
13022
+ * Returns the count of occurrences for the given key.
13023
+ * @remarks Time O(log n), Space O(1)
12974
13024
  */
12975
- set height(value) {
12976
- this._height = value;
13025
+ count(key) {
13026
+ this._validateKey(key);
13027
+ return this.#core.get(key) ?? 0;
12977
13028
  }
12978
- _color = "BLACK";
12979
13029
  /**
12980
- * Gets the color of the node (used in Red-Black trees).
12981
- * @remarks Time O(1), Space O(1)
12982
- *
12983
- * @returns The node's color.
13030
+ * Add `n` occurrences of `key`.
13031
+ * @returns True if the multiset changed.
13032
+ * @remarks Time O(log n), Space O(1)
12984
13033
  */
12985
- get color() {
12986
- return this._color;
13034
+ add(key, n = 1) {
13035
+ this._validateKey(key);
13036
+ this._validateCount(n);
13037
+ if (n === 0) return false;
13038
+ const old = this.#core.get(key) ?? 0;
13039
+ const next = old + n;
13040
+ this.#core.set(key, next);
13041
+ this._size += n;
13042
+ return true;
12987
13043
  }
12988
13044
  /**
12989
- * Sets the color of the node.
12990
- * @remarks Time O(1), Space O(1)
12991
- *
12992
- * @param value - The new color.
13045
+ * Set count for `key` to exactly `n`.
13046
+ * @returns True if changed.
13047
+ * @remarks Time O(log n), Space O(1)
12993
13048
  */
12994
- set color(value) {
12995
- this._color = value;
13049
+ setCount(key, n) {
13050
+ this._validateKey(key);
13051
+ this._validateCount(n);
13052
+ const old = this.#core.get(key) ?? 0;
13053
+ if (old === n) return false;
13054
+ if (n === 0) {
13055
+ if (old !== 0) this.#core.delete(key);
13056
+ } else {
13057
+ this.#core.set(key, n);
13058
+ }
13059
+ this._size += n - old;
13060
+ return true;
12996
13061
  }
12997
- _count = 1;
12998
13062
  /**
12999
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
13000
- * @remarks Time O(1), Space O(1)
13001
- *
13002
- * @returns The subtree node count.
13063
+ * Delete `n` occurrences of `key` (default 1).
13064
+ * @returns True if any occurrence was removed.
13065
+ * @remarks Time O(log n), Space O(1)
13003
13066
  */
13004
- get count() {
13005
- return this._count;
13067
+ delete(key, n = 1) {
13068
+ this._validateKey(key);
13069
+ this._validateCount(n);
13070
+ if (n === 0) return false;
13071
+ const old = this.#core.get(key) ?? 0;
13072
+ if (old === 0) return false;
13073
+ const removed = Math.min(old, n);
13074
+ const next = old - removed;
13075
+ if (next === 0) this.#core.delete(key);
13076
+ else this.#core.set(key, next);
13077
+ this._size -= removed;
13078
+ return true;
13006
13079
  }
13007
13080
  /**
13008
- * Sets the count of nodes in the subtree.
13009
- * @remarks Time O(1), Space O(1)
13010
- *
13011
- * @param value - The new count.
13081
+ * Delete all occurrences of the given key.
13082
+ * @returns True if any occurrence was removed.
13083
+ * @remarks Time O(log n), Space O(1)
13012
13084
  */
13013
- set count(value) {
13014
- this._count = value;
13085
+ deleteAll(key) {
13086
+ this._validateKey(key);
13087
+ const old = this.#core.get(key) ?? 0;
13088
+ if (old === 0) return false;
13089
+ this.#core.delete(key);
13090
+ this._size -= old;
13091
+ return true;
13015
13092
  }
13016
13093
  /**
13017
- * Gets the position of the node relative to its parent.
13018
- * @remarks Time O(1), Space O(1)
13019
- *
13020
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
13094
+ * Iterates over distinct keys (each key yielded once).
13095
+ * @remarks Time O(n), Space O(1)
13021
13096
  */
13022
- get familyPosition() {
13023
- if (!this.parent) {
13024
- return this.left || this.right ? "ROOT" : "ISOLATED";
13097
+ *keysDistinct() {
13098
+ yield* this.#core.keys();
13099
+ }
13100
+ /**
13101
+ * Iterates over entries as [key, count] pairs.
13102
+ * @remarks Time O(n), Space O(1)
13103
+ */
13104
+ *entries() {
13105
+ for (const [k, v] of this.#core) {
13106
+ yield [k, v ?? 0];
13025
13107
  }
13026
- if (this.parent.left === this) {
13027
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
13028
- } else if (this.parent.right === this) {
13029
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
13108
+ }
13109
+ /**
13110
+ * Expanded iteration (default). Each key is yielded `count(key)` times.
13111
+ * @remarks Time O(size), Space O(1) where size is total occurrences
13112
+ */
13113
+ *[Symbol.iterator]() {
13114
+ for (const [k, c] of this.entries()) {
13115
+ for (let i = 0; i < c; i++) yield k;
13030
13116
  }
13031
- return "MAL_NODE";
13032
13117
  }
13033
- };
13034
- var AVLTreeCounter = class extends AVLTree {
13035
- static {
13036
- __name(this, "AVLTreeCounter");
13118
+ /**
13119
+ * Returns an array with all elements (expanded).
13120
+ * @remarks Time O(size), Space O(size)
13121
+ */
13122
+ toArray() {
13123
+ return [...this];
13037
13124
  }
13038
13125
  /**
13039
- * Create a AVLTreeCounter instance
13126
+ * Returns an array with distinct keys only.
13040
13127
  * @remarks Time O(n), Space O(n)
13041
- * @param keysNodesEntriesOrRaws
13042
- * @param options
13043
- * @returns New AVLTreeCounterNode instance.
13044
13128
  */
13045
- constructor(keysNodesEntriesOrRaws = [], options) {
13046
- super([], options);
13047
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
13048
- }
13049
- _count = 0;
13050
- get count() {
13051
- return this._count;
13129
+ toDistinctArray() {
13130
+ return [...this.keysDistinct()];
13052
13131
  }
13053
13132
  /**
13054
- * Compute the total count by traversing the tree (sums node.count).
13055
- * @remarks Time O(N), Space O(H)
13056
- * @returns Total count recomputed from nodes.
13133
+ * Returns an array of [key, count] entries.
13134
+ * @remarks Time O(n), Space O(n)
13057
13135
  */
13058
- getComputedCount() {
13059
- let sum = 0;
13060
- this.dfs((node) => sum += node.count);
13061
- return sum;
13136
+ toEntries() {
13137
+ return [...this.entries()];
13062
13138
  }
13063
- createNode(key, value, count) {
13064
- return new AVLTreeCounterNode(key, this._isMapMode ? void 0 : value, count);
13139
+ /**
13140
+ * Expose comparator for advanced usage/testing (read-only).
13141
+ * @remarks Time O(1), Space O(1)
13142
+ */
13143
+ get comparator() {
13144
+ return this.#core._comparator;
13065
13145
  }
13146
+ // ━━━ clear ━━━
13066
13147
  /**
13067
- * Type guard: check whether the input is an AVLTreeCounterNode.
13148
+ * Remove all elements from the multiset.
13068
13149
  * @remarks Time O(1), Space O(1)
13069
- * @returns True if the value is an AVLTreeCounterNode.
13150
+ * @example
13151
+ * const ms = new TreeMultiSet([1, 2, 2, 3]);
13152
+ * ms.clear();
13153
+ * ms.size; // 0
13070
13154
  */
13071
- isNode(keyNodeOrEntry) {
13072
- return keyNodeOrEntry instanceof AVLTreeCounterNode;
13155
+ clear() {
13156
+ this.#core.clear();
13157
+ this._size = 0;
13073
13158
  }
13159
+ // ━━━ Navigable methods ━━━
13074
13160
  /**
13075
- * Insert or increment a node and update aggregate count.
13076
- * @remarks Time O(log N), Space O(1)
13077
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
13078
- * @param [value] - Value when a bare key is provided (ignored in map mode).
13079
- * @param [count] - How much to increase the node's count (default 1).
13080
- * @returns True if inserted/updated; false if ignored.
13161
+ * Returns the smallest key, or undefined if empty.
13162
+ * @remarks Time O(log n), Space O(1)
13163
+ * @example
13164
+ * const ms = new TreeMultiSet([3, 1, 4]);
13165
+ * ms.first(); // 1
13081
13166
  */
13082
- set(keyNodeOrEntry, value, count = 1) {
13083
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
13084
- if (newNode === void 0) return false;
13085
- const orgNodeCount = newNode?.count || 0;
13086
- const inserted = super.set(newNode, newValue);
13087
- if (inserted) {
13088
- this._count += orgNodeCount;
13089
- }
13090
- return true;
13167
+ first() {
13168
+ return this.#core.getLeftMost();
13091
13169
  }
13092
13170
  /**
13093
- * Delete a node (or decrement its count) and rebalance if needed.
13094
- * @remarks Time O(log N), Space O(1)
13095
- * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
13096
- * @param [ignoreCount] - If true, remove the node regardless of its count.
13097
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
13171
+ * Returns the largest key, or undefined if empty.
13172
+ * @remarks Time O(log n), Space O(1)
13173
+ * @example
13174
+ * const ms = new TreeMultiSet([3, 1, 4]);
13175
+ * ms.last(); // 4
13098
13176
  */
13099
- delete(keyNodeOrEntry, ignoreCount = false) {
13100
- const deletedResult = [];
13101
- if (!this.root) return deletedResult;
13102
- const curr = this.getNode(keyNodeOrEntry) ?? void 0;
13103
- if (!curr) return deletedResult;
13104
- const parent = curr?.parent ? curr.parent : void 0;
13105
- let needBalanced = void 0, orgCurrent = curr;
13106
- if (curr.count > 1 && !ignoreCount) {
13107
- curr.count--;
13108
- this._count--;
13109
- } else {
13110
- if (!curr.left) {
13111
- if (!parent) {
13112
- if (curr.right !== void 0 && curr.right !== null) this._setRoot(curr.right);
13113
- } else {
13114
- const { familyPosition: fp } = curr;
13115
- if (fp === "LEFT" || fp === "ROOT_LEFT") {
13116
- parent.left = curr.right;
13117
- } else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
13118
- parent.right = curr.right;
13119
- }
13120
- needBalanced = parent;
13121
- }
13122
- } else {
13123
- const leftSubTreeRightMost = curr.left ? this.getRightMost((node) => node, curr.left) : void 0;
13124
- if (leftSubTreeRightMost) {
13125
- const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
13126
- orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
13127
- if (parentOfLeftSubTreeMax) {
13128
- if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
13129
- parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
13130
- } else {
13131
- parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
13132
- }
13133
- needBalanced = parentOfLeftSubTreeMax;
13134
- }
13135
- }
13136
- }
13137
- this._size = this._size - 1;
13138
- if (orgCurrent) this._count -= orgCurrent.count;
13139
- }
13140
- deletedResult.push({ deleted: orgCurrent, needBalanced });
13141
- if (needBalanced) {
13142
- this._balancePath(needBalanced);
13143
- }
13144
- return deletedResult;
13177
+ last() {
13178
+ return this.#core.getRightMost();
13145
13179
  }
13146
13180
  /**
13147
- * Remove all nodes and reset aggregate counters.
13148
- * @remarks Time O(N), Space O(1)
13149
- * @returns void
13181
+ * Removes all occurrences of the smallest key and returns it.
13182
+ * @remarks Time O(log n), Space O(1)
13183
+ * @example
13184
+ * const ms = new TreeMultiSet([1, 1, 2, 3]);
13185
+ * ms.pollFirst(); // 1
13186
+ * ms.has(1); // false
13150
13187
  */
13151
- clear() {
13152
- super.clear();
13153
- this._count = 0;
13188
+ pollFirst() {
13189
+ const key = this.first();
13190
+ if (key === void 0) return void 0;
13191
+ this.deleteAll(key);
13192
+ return key;
13154
13193
  }
13155
13194
  /**
13156
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
13157
- * @remarks Time O(N), Space O(N)
13158
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
13159
- * @returns True if rebalancing succeeded (tree not empty).
13195
+ * Removes all occurrences of the largest key and returns it.
13196
+ * @remarks Time O(log n), Space O(1)
13197
+ * @example
13198
+ * const ms = new TreeMultiSet([1, 2, 3, 3]);
13199
+ * ms.pollLast(); // 3
13200
+ * ms.has(3); // false
13160
13201
  */
13161
- perfectlyBalance(iterationType = this.iterationType) {
13162
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
13163
- const n = nodes.length;
13164
- if (n === 0) return false;
13165
- let total = 0;
13166
- for (const nd of nodes) total += nd ? nd.count : 0;
13167
- this._clearNodes();
13168
- const build = /* @__PURE__ */ __name((l, r, parent) => {
13169
- if (l > r) return void 0;
13170
- const m = l + (r - l >> 1);
13171
- const root = nodes[m];
13172
- root.left = build(l, m - 1, root);
13173
- root.right = build(m + 1, r, root);
13174
- root.parent = parent;
13175
- const lh = root.left ? root.left.height : -1;
13176
- const rh = root.right ? root.right.height : -1;
13177
- root.height = Math.max(lh, rh) + 1;
13178
- return root;
13179
- }, "build");
13180
- const newRoot = build(0, n - 1, void 0);
13181
- this._setRoot(newRoot);
13182
- this._size = n;
13183
- this._count = total;
13184
- return true;
13202
+ pollLast() {
13203
+ const key = this.last();
13204
+ if (key === void 0) return void 0;
13205
+ this.deleteAll(key);
13206
+ return key;
13185
13207
  }
13186
13208
  /**
13187
- * Deep copy this tree, preserving map mode and aggregate counts.
13188
- * @remarks Time O(N), Space O(N)
13189
- * @returns A deep copy of this tree.
13209
+ * Returns the smallest key >= given key, or undefined.
13210
+ * @remarks Time O(log n), Space O(1)
13211
+ * @example
13212
+ * const ms = new TreeMultiSet([10, 20, 30]);
13213
+ * ms.ceiling(15); // 20
13214
+ * ms.ceiling(20); // 20
13190
13215
  */
13191
- clone() {
13192
- const out = this._createInstance();
13193
- if (this._isMapMode) {
13194
- this.bfs((node) => out.set(node.key, void 0, node.count));
13195
- } else {
13196
- this.bfs((node) => out.set(node.key, node.value, node.count));
13197
- }
13198
- if (this._isMapMode) out._store = this._store;
13199
- return out;
13216
+ ceiling(key) {
13217
+ this._validateKey(key);
13218
+ return this.#core.ceiling(key);
13200
13219
  }
13201
13220
  /**
13202
- * Create a new AVLTreeCounter by mapping each [key, value] entry.
13203
- * @remarks Time O(N log N), Space O(N)
13204
- * @template MK
13205
- * @template MV
13206
- * @template MR
13207
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
13208
- * @param [options] - Options for the output tree.
13209
- * @param [thisArg] - Value for `this` inside the callback.
13210
- * @returns A new AVLTreeCounter with mapped entries.
13221
+ * Returns the largest key <= given key, or undefined.
13222
+ * @remarks Time O(log n), Space O(1)
13223
+ * @example
13224
+ * const ms = new TreeMultiSet([10, 20, 30]);
13225
+ * ms.floor(25); // 20
13226
+ * ms.floor(20); // 20
13211
13227
  */
13212
- map(callback, options, thisArg) {
13213
- const out = this._createLike([], options);
13214
- let index = 0;
13215
- for (const [key, value] of this) {
13216
- out.set(callback.call(thisArg, value, key, index++, this));
13217
- }
13218
- return out;
13228
+ floor(key) {
13229
+ this._validateKey(key);
13230
+ return this.#core.floor(key);
13219
13231
  }
13220
13232
  /**
13221
- * (Protected) Create an empty instance of the same concrete class.
13222
- * @remarks Time O(1), Space O(1)
13223
- * @template TK
13224
- * @template TV
13225
- * @template TR
13226
- * @param [options] - Optional constructor options for the like-kind instance.
13227
- * @returns An empty like-kind instance.
13233
+ * Returns the smallest key > given key, or undefined.
13234
+ * @remarks Time O(log n), Space O(1)
13235
+ * @example
13236
+ * const ms = new TreeMultiSet([10, 20, 30]);
13237
+ * ms.higher(10); // 20
13238
+ * ms.higher(15); // 20
13228
13239
  */
13229
- _createInstance(options) {
13230
- const Ctor = this.constructor;
13231
- return new Ctor([], { ...this._snapshotOptions(), ...options ?? {} });
13240
+ higher(key) {
13241
+ this._validateKey(key);
13242
+ return this.#core.higher(key);
13232
13243
  }
13233
13244
  /**
13234
- * (Protected) Create a like-kind instance and seed it from an iterable.
13235
- * @remarks Time O(N log N), Space O(N)
13236
- * @template TK
13237
- * @template TV
13238
- * @template TR
13239
- * @param iter - Iterable used to seed the new tree.
13240
- * @param [options] - Options merged with the current snapshot.
13241
- * @returns A like-kind AVLTreeCounter built from the iterable.
13245
+ * Returns the largest key < given key, or undefined.
13246
+ * @remarks Time O(log n), Space O(1)
13247
+ * @example
13248
+ * const ms = new TreeMultiSet([10, 20, 30]);
13249
+ * ms.lower(20); // 10
13250
+ * ms.lower(15); // 10
13242
13251
  */
13243
- _createLike(iter = [], options) {
13244
- const Ctor = this.constructor;
13245
- return new Ctor(iter, { ...this._snapshotOptions(), ...options ?? {} });
13252
+ lower(key) {
13253
+ this._validateKey(key);
13254
+ return this.#core.lower(key);
13246
13255
  }
13256
+ // ━━━ Functional methods ━━━
13247
13257
  /**
13248
- * (Protected) Normalize input into a node plus its effective value and count.
13249
- * @remarks Time O(1), Space O(1)
13250
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
13251
- * @param [value] - Value used when a bare key is provided.
13252
- * @param [count] - Count increment to apply (default 1).
13253
- * @returns Tuple [node, value] where node may be undefined.
13258
+ * Iterates over distinct keys with their counts.
13259
+ * @remarks Time O(n), Space O(1)
13260
+ * @example
13261
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13262
+ * ms.forEach((key, count) => console.log(`${key}: ${count}`));
13263
+ * // 1: 2, 2: 1, 3: 3
13254
13264
  */
13255
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
13256
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
13257
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
13258
- if (this.isEntry(keyNodeOrEntry)) {
13259
- const [key, entryValue] = keyNodeOrEntry;
13260
- if (key === void 0 || key === null) return [void 0, void 0];
13261
- const finalValue = value ?? entryValue;
13262
- return [this.createNode(key, finalValue, count), finalValue];
13265
+ forEach(callback) {
13266
+ for (const [k, c] of this.entries()) {
13267
+ callback(k, c);
13263
13268
  }
13264
- return [this.createNode(keyNodeOrEntry, value, count), value];
13265
13269
  }
13266
13270
  /**
13267
- * (Protected) Swap keys/values/counters between the source and destination nodes.
13268
- * @remarks Time O(1), Space O(1)
13269
- * @param srcNode - Source node (or key) whose properties will be moved.
13270
- * @param destNode - Destination node (or key) to receive properties.
13271
- * @returns Destination node after swap, or undefined.
13271
+ * Creates a new TreeMultiSet with entries that match the predicate.
13272
+ * @remarks Time O(n log n), Space O(n)
13273
+ * @example
13274
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13275
+ * const filtered = ms.filter((key, count) => count >= 2);
13276
+ * // TreeMultiSet { 1: 2, 3: 3 }
13272
13277
  */
13273
- _swapProperties(srcNode, destNode) {
13274
- srcNode = this.ensureNode(srcNode);
13275
- destNode = this.ensureNode(destNode);
13276
- if (srcNode && destNode) {
13277
- const { key, value, count, height } = destNode;
13278
- const tempNode = this.createNode(key, value, count);
13279
- if (tempNode) {
13280
- tempNode.height = height;
13281
- destNode.key = srcNode.key;
13282
- if (!this._isMapMode) destNode.value = srcNode.value;
13283
- destNode.count = srcNode.count;
13284
- destNode.height = srcNode.height;
13285
- srcNode.key = tempNode.key;
13286
- if (!this._isMapMode) srcNode.value = tempNode.value;
13287
- srcNode.count = tempNode.count;
13288
- srcNode.height = tempNode.height;
13278
+ filter(predicate) {
13279
+ const result = new _TreeMultiSet([], {
13280
+ comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13281
+ isMapMode: this.#core._isMapMode
13282
+ });
13283
+ for (const [k, c] of this.entries()) {
13284
+ if (predicate(k, c)) {
13285
+ result.add(k, c);
13289
13286
  }
13290
- return destNode;
13291
13287
  }
13292
- return void 0;
13288
+ return result;
13293
13289
  }
13294
13290
  /**
13295
- * (Protected) Replace one node by another and adjust counters accordingly.
13296
- * @remarks Time O(1), Space O(1)
13297
- * @param oldNode - Node being replaced.
13298
- * @param newNode - Replacement node.
13299
- * @returns The new node after replacement.
13291
+ * Reduces the multiset to a single value.
13292
+ * @remarks Time O(n), Space O(1)
13293
+ * @example
13294
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13295
+ * const total = ms.reduce((acc, key, count) => acc + count, 0); // 6
13300
13296
  */
13301
- _replaceNode(oldNode, newNode) {
13302
- newNode.count = oldNode.count + newNode.count;
13303
- return super._replaceNode(oldNode, newNode);
13297
+ reduce(callback, initialValue) {
13298
+ let acc = initialValue;
13299
+ for (const [k, c] of this.entries()) {
13300
+ acc = callback(acc, k, c);
13301
+ }
13302
+ return acc;
13303
+ }
13304
+ /**
13305
+ * Maps keys and counts to a new TreeMultiSet.
13306
+ * When multiple keys map to the same new key, counts are merged (added).
13307
+ * @remarks Time O(n log n), Space O(n)
13308
+ * @example
13309
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13310
+ * const mapped = ms.map((key, count) => [key * 10, count]);
13311
+ * // TreeMultiSet { 10: 2, 20: 1, 30: 3 }
13312
+ * @example
13313
+ * // Collision: counts merge
13314
+ * const ms = new TreeMultiSet([1, 2, 3]);
13315
+ * const merged = ms.map((key, count) => [key % 2, count]);
13316
+ * // { 0: 1, 1: 2 } (1 and 3 both map to 1, counts add)
13317
+ */
13318
+ map(mapper, options) {
13319
+ const result = new _TreeMultiSet([], {
13320
+ comparator: options?.comparator,
13321
+ isMapMode: this.#core._isMapMode
13322
+ });
13323
+ for (const [k, c] of this.entries()) {
13324
+ const [newKey, newCount] = mapper(k, c);
13325
+ result.add(newKey, newCount);
13326
+ }
13327
+ return result;
13328
+ }
13329
+ /**
13330
+ * Creates an independent copy of this multiset.
13331
+ * @remarks Time O(n log n), Space O(n)
13332
+ * @example
13333
+ * const ms = new TreeMultiSet([1, 1, 2]);
13334
+ * const copy = ms.clone();
13335
+ * copy.add(3);
13336
+ * ms.has(3); // false (original unchanged)
13337
+ */
13338
+ clone() {
13339
+ const result = new _TreeMultiSet([], {
13340
+ comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13341
+ isMapMode: this.#core._isMapMode
13342
+ });
13343
+ for (const [k, c] of this.entries()) {
13344
+ result.add(k, c);
13345
+ }
13346
+ return result;
13347
+ }
13348
+ // ━━━ Tree utilities ━━━
13349
+ /**
13350
+ * Returns keys within the given range.
13351
+ * @remarks Time O(log n + k), Space O(k) where k is result size
13352
+ * @example
13353
+ * const ms = new TreeMultiSet([10, 20, 30, 40, 50]);
13354
+ * ms.rangeSearch([15, 45]); // [20, 30, 40]
13355
+ */
13356
+ rangeSearch(range, callback) {
13357
+ const cb = callback ?? ((k) => k);
13358
+ return this.#core.rangeSearch(range, (node) => cb(node.key));
13359
+ }
13360
+ /**
13361
+ * Prints the internal tree structure (for debugging).
13362
+ * @remarks Time O(n), Space O(n)
13363
+ * @example
13364
+ * const ms = new TreeMultiSet([1, 2, 3]);
13365
+ * ms.print();
13366
+ */
13367
+ print() {
13368
+ this.#core.print();
13304
13369
  }
13305
13370
  };
13306
13371
 
@@ -14516,6 +14581,13 @@ var TreeNode = class _TreeNode {
14516
14581
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
14517
14582
  * @license MIT License
14518
14583
  */
14584
+ /**
14585
+ * data-structure-typed
14586
+ *
14587
+ * @author Pablo Zeng
14588
+ * @copyright Copyright (c) 2022 Pablo Zeng
14589
+ * @license MIT License
14590
+ */
14519
14591
  /**
14520
14592
  * data-structure-typed
14521
14593
  *
@@ -14525,10 +14597,6 @@ var TreeNode = class _TreeNode {
14525
14597
  */
14526
14598
 
14527
14599
  exports.AVLTree = AVLTree;
14528
- exports.AVLTreeCounter = AVLTreeCounter;
14529
- exports.AVLTreeCounterNode = AVLTreeCounterNode;
14530
- exports.AVLTreeMultiMap = AVLTreeMultiMap;
14531
- exports.AVLTreeMultiMapNode = AVLTreeMultiMapNode;
14532
14600
  exports.AVLTreeNode = AVLTreeNode;
14533
14601
  exports.AbstractEdge = AbstractEdge;
14534
14602
  exports.AbstractGraph = AbstractGraph;
@@ -14575,11 +14643,12 @@ exports.SinglyLinkedListNode = SinglyLinkedListNode;
14575
14643
  exports.SkipList = SkipList;
14576
14644
  exports.SkipListNode = SkipListNode;
14577
14645
  exports.Stack = Stack;
14578
- exports.TreeCounter = TreeCounter;
14579
- exports.TreeCounterNode = TreeCounterNode;
14646
+ exports.TreeMap = TreeMap;
14580
14647
  exports.TreeMultiMap = TreeMultiMap;
14581
14648
  exports.TreeMultiMapNode = TreeMultiMapNode;
14649
+ exports.TreeMultiSet = TreeMultiSet;
14582
14650
  exports.TreeNode = TreeNode;
14651
+ exports.TreeSet = TreeSet;
14583
14652
  exports.Trie = Trie;
14584
14653
  exports.TrieNode = TrieNode;
14585
14654
  exports.UndirectedEdge = UndirectedEdge;