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
@@ -7042,6 +7042,9 @@ var BinaryTree = class extends IterableEntryBase {
7042
7042
  get isDuplicate() {
7043
7043
  return this._isDuplicate;
7044
7044
  }
7045
+ // Map mode acceleration store:
7046
+ // - isMapMode=false: unused
7047
+ // - isMapMode=true: key -> node reference (O(1) has/getNode + fast get)
7045
7048
  _store = /* @__PURE__ */ new Map();
7046
7049
  /**
7047
7050
  * Gets the external value store (used in Map mode).
@@ -7101,7 +7104,7 @@ var BinaryTree = class extends IterableEntryBase {
7101
7104
  * @returns The newly created node.
7102
7105
  */
7103
7106
  createNode(key, value) {
7104
- return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
7107
+ return new BinaryTreeNode(key, value);
7105
7108
  }
7106
7109
  /**
7107
7110
  * Creates a new, empty tree of the same type and configuration.
@@ -7248,11 +7251,11 @@ var BinaryTree = class extends IterableEntryBase {
7248
7251
  * @returns True if the addition was successful, false otherwise.
7249
7252
  */
7250
7253
  set(keyNodeOrEntry, value) {
7251
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7254
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7252
7255
  if (newNode === void 0) return false;
7253
7256
  if (!this._root) {
7254
7257
  this._setRoot(newNode);
7255
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
7258
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7256
7259
  this._size = 1;
7257
7260
  return true;
7258
7261
  }
@@ -7264,7 +7267,7 @@ var BinaryTree = class extends IterableEntryBase {
7264
7267
  if (!this._isDuplicate) {
7265
7268
  if (newNode !== null && cur.key === newNode.key) {
7266
7269
  this._replaceNode(cur, newNode);
7267
- if (this._isMapMode) this._setValue(cur.key, newValue);
7270
+ if (this._isMapMode && newNode !== null) this._store.set(cur.key, newNode);
7268
7271
  return true;
7269
7272
  }
7270
7273
  }
@@ -7284,7 +7287,7 @@ var BinaryTree = class extends IterableEntryBase {
7284
7287
  } else if (potentialParent.right === void 0) {
7285
7288
  potentialParent.right = newNode;
7286
7289
  }
7287
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
7290
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7288
7291
  this._size++;
7289
7292
  return true;
7290
7293
  }
@@ -7369,6 +7372,10 @@ var BinaryTree = class extends IterableEntryBase {
7369
7372
  if (leftSubTreeRightMost) {
7370
7373
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
7371
7374
  orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
7375
+ if (this._isMapMode) {
7376
+ this._store.set(curr.key, curr);
7377
+ this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
7378
+ }
7372
7379
  if (parentOfLeftSubTreeMax) {
7373
7380
  if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
7374
7381
  parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
@@ -7452,6 +7459,13 @@ var BinaryTree = class extends IterableEntryBase {
7452
7459
  * @returns The first matching node, or undefined if not found.
7453
7460
  */
7454
7461
  getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7462
+ if (this._isMapMode && keyNodeEntryOrPredicate !== null && keyNodeEntryOrPredicate !== void 0) {
7463
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7464
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7465
+ if (key === null || key === void 0) return;
7466
+ return this._store.get(key);
7467
+ }
7468
+ }
7455
7469
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType)[0];
7456
7470
  }
7457
7471
  /**
@@ -7467,11 +7481,18 @@ var BinaryTree = class extends IterableEntryBase {
7467
7481
  if (this._isMapMode) {
7468
7482
  const key = this._extractKey(keyNodeEntryOrPredicate);
7469
7483
  if (key === null || key === void 0) return;
7470
- return this._store.get(key);
7484
+ return this._store.get(key)?.value;
7471
7485
  }
7472
7486
  return this.getNode(keyNodeEntryOrPredicate, startNode, iterationType)?.value;
7473
7487
  }
7474
7488
  has(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7489
+ if (this._isMapMode && keyNodeEntryOrPredicate !== void 0 && keyNodeEntryOrPredicate !== null) {
7490
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7491
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7492
+ if (key === null || key === void 0) return false;
7493
+ return this._store.has(key);
7494
+ }
7495
+ }
7475
7496
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType).length > 0;
7476
7497
  }
7477
7498
  /**
@@ -8214,8 +8235,7 @@ var BinaryTree = class extends IterableEntryBase {
8214
8235
  }
8215
8236
  current = stack.pop();
8216
8237
  if (this.isRealNode(current)) {
8217
- if (this._isMapMode) yield [current.key, this._store.get(current.key)];
8218
- else yield [current.key, current.value];
8238
+ yield [current.key, current.value];
8219
8239
  current = current.right;
8220
8240
  }
8221
8241
  }
@@ -8223,8 +8243,7 @@ var BinaryTree = class extends IterableEntryBase {
8223
8243
  if (node.left && this.isRealNode(node)) {
8224
8244
  yield* this[Symbol.iterator](node.left);
8225
8245
  }
8226
- if (this._isMapMode) yield [node.key, this._store.get(node.key)];
8227
- else yield [node.key, node.value];
8246
+ yield [node.key, node.value];
8228
8247
  if (node.right && this.isRealNode(node)) {
8229
8248
  yield* this[Symbol.iterator](node.right);
8230
8249
  }
@@ -8310,8 +8329,7 @@ var BinaryTree = class extends IterableEntryBase {
8310
8329
  (node) => {
8311
8330
  if (node === null) cloned.set(null);
8312
8331
  else {
8313
- if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
8314
- else cloned.set([node.key, node.value]);
8332
+ cloned.set([node.key, node.value]);
8315
8333
  }
8316
8334
  },
8317
8335
  this._root,
@@ -8319,7 +8337,6 @@ var BinaryTree = class extends IterableEntryBase {
8319
8337
  true
8320
8338
  // Include nulls
8321
8339
  );
8322
- if (this._isMapMode) cloned._store = this._store;
8323
8340
  }
8324
8341
  /**
8325
8342
  * (Protected) Recursive helper for `toVisual`.
@@ -8482,8 +8499,10 @@ var BinaryTree = class extends IterableEntryBase {
8482
8499
  */
8483
8500
  _setValue(key, value) {
8484
8501
  if (key === null || key === void 0) return false;
8485
- if (value === void 0) return false;
8486
- return this._store.set(key, value);
8502
+ const node = this._store.get(key);
8503
+ if (!node) return false;
8504
+ node.value = value;
8505
+ return true;
8487
8506
  }
8488
8507
  /**
8489
8508
  * (Protected) Clears all nodes from the tree.
@@ -8694,7 +8713,7 @@ var BST = class extends BinaryTree {
8694
8713
  * @returns The newly created BSTNode.
8695
8714
  */
8696
8715
  createNode(key, value) {
8697
- return new BSTNode(key, this._isMapMode ? void 0 : value);
8716
+ return new BSTNode(key, value);
8698
8717
  }
8699
8718
  /**
8700
8719
  * Ensures the input is a node. If it's a key or entry, it searches for the node.
@@ -8933,11 +8952,11 @@ var BST = class extends BinaryTree {
8933
8952
  * @returns True if the addition was successful, false otherwise.
8934
8953
  */
8935
8954
  set(keyNodeOrEntry, value) {
8936
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8955
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8937
8956
  if (newNode === void 0) return false;
8938
8957
  if (this._root === void 0) {
8939
8958
  this._setRoot(newNode);
8940
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8959
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8941
8960
  this._size++;
8942
8961
  return true;
8943
8962
  }
@@ -8945,12 +8964,12 @@ var BST = class extends BinaryTree {
8945
8964
  while (current !== void 0) {
8946
8965
  if (this._compare(current.key, newNode.key) === 0) {
8947
8966
  this._replaceNode(current, newNode);
8948
- if (this._isMapMode) this._setValue(current.key, newValue);
8967
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(current.key, newNode);
8949
8968
  return true;
8950
8969
  } else if (this._compare(current.key, newNode.key) > 0) {
8951
8970
  if (current.left === void 0) {
8952
8971
  current.left = newNode;
8953
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8972
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8954
8973
  this._size++;
8955
8974
  return true;
8956
8975
  }
@@ -8958,7 +8977,7 @@ var BST = class extends BinaryTree {
8958
8977
  } else {
8959
8978
  if (current.right === void 0) {
8960
8979
  current.right = newNode;
8961
- if (this._isMapMode) this._setValue(newNode?.key, newValue);
8980
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8962
8981
  this._size++;
8963
8982
  return true;
8964
8983
  }
@@ -10515,7 +10534,7 @@ var AVLTree = class extends BST {
10515
10534
  * @returns The newly created AVLTreeNode.
10516
10535
  */
10517
10536
  createNode(key, value) {
10518
- return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
10537
+ return new AVLTreeNode(key, value);
10519
10538
  }
10520
10539
  /**
10521
10540
  * Checks if the given item is an `AVLTreeNode` instance.
@@ -11071,7 +11090,7 @@ var RedBlackTree = class extends BST {
11071
11090
  * @returns A new RedBlackTreeNode instance.
11072
11091
  */
11073
11092
  createNode(key, value, color = "BLACK") {
11074
- return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
11093
+ return new RedBlackTreeNode(key, value, color);
11075
11094
  }
11076
11095
  /**
11077
11096
  * Type guard: check whether the input is a RedBlackTreeNode.
@@ -11220,20 +11239,15 @@ var RedBlackTree = class extends BST {
11220
11239
  if (minN !== NIL) {
11221
11240
  const cMin = comparator(key, minN.key);
11222
11241
  if (cMin === 0) {
11223
- if (this._isMapMode) {
11224
- if (nextValue !== void 0) this._store.set(key, nextValue);
11225
- else this._setValue(key, nextValue);
11226
- } else minN.value = nextValue;
11242
+ minN.value = nextValue;
11243
+ if (this._isMapMode) this._store.set(key, minN);
11227
11244
  return { node: minN, created: false };
11228
11245
  }
11229
11246
  const minL = minN.left;
11230
11247
  if (cMin < 0 && (minL === NIL || minL === null || minL === void 0)) {
11231
11248
  const newNode2 = this.createNode(key, nextValue);
11232
11249
  this._attachNewNode(minN, "left", newNode2);
11233
- if (this._isMapMode) {
11234
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11235
- else this._setValue(newNode2.key, nextValue);
11236
- }
11250
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11237
11251
  this._size++;
11238
11252
  this._setMinCache(newNode2);
11239
11253
  if (header._right === NIL) this._setMaxCache(newNode2);
@@ -11243,20 +11257,15 @@ var RedBlackTree = class extends BST {
11243
11257
  const maxN = header._right ?? NIL;
11244
11258
  const cMax = comparator(key, maxN.key);
11245
11259
  if (cMax === 0) {
11246
- if (this._isMapMode) {
11247
- if (nextValue !== void 0) this._store.set(key, nextValue);
11248
- else this._setValue(key, nextValue);
11249
- } else maxN.value = nextValue;
11260
+ maxN.value = nextValue;
11261
+ if (this._isMapMode) this._store.set(key, maxN);
11250
11262
  return { node: maxN, created: false };
11251
11263
  }
11252
11264
  const maxR = maxN.right;
11253
11265
  if (cMax > 0 && (maxR === NIL || maxR === null || maxR === void 0)) {
11254
11266
  const newNode2 = this.createNode(key, nextValue);
11255
11267
  this._attachNewNode(maxN, "right", newNode2);
11256
- if (this._isMapMode) {
11257
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11258
- else this._setValue(newNode2.key, nextValue);
11259
- }
11268
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11260
11269
  this._size++;
11261
11270
  this._setMaxCache(newNode2);
11262
11271
  if (header._left === NIL) this._setMinCache(newNode2);
@@ -11276,12 +11285,8 @@ var RedBlackTree = class extends BST {
11276
11285
  if (lastCompared < 0) current = current.left ?? NIL;
11277
11286
  else if (lastCompared > 0) current = current.right ?? NIL;
11278
11287
  else {
11279
- if (isMapMode) {
11280
- if (nextValue !== void 0) store.set(key, nextValue);
11281
- else this._setValue(key, nextValue);
11282
- } else {
11283
- current.value = nextValue;
11284
- }
11288
+ current.value = nextValue;
11289
+ if (isMapMode) store.set(key, current);
11285
11290
  return { node: current, created: false };
11286
11291
  }
11287
11292
  }
@@ -11300,10 +11305,7 @@ var RedBlackTree = class extends BST {
11300
11305
  this._insertFixup(newNode);
11301
11306
  if (this.isRealNode(this._root)) this._root.color = "BLACK";
11302
11307
  else return void 0;
11303
- if (isMapMode) {
11304
- if (nextValue !== void 0) store.set(newNode.key, nextValue);
11305
- else this._setValue(newNode.key, nextValue);
11306
- }
11308
+ if (isMapMode) store.set(newNode.key, newNode);
11307
11309
  this._size++;
11308
11310
  const hMin = this._header._left ?? NIL;
11309
11311
  const hMax = this._header._right ?? NIL;
@@ -11331,10 +11333,11 @@ var RedBlackTree = class extends BST {
11331
11333
  * @remarks Time O(log n) average, Space O(1)
11332
11334
  */
11333
11335
  _setKV(key, nextValue) {
11334
- if (this._isMapMode && nextValue !== void 0) {
11336
+ if (this._isMapMode) {
11335
11337
  const store = this._store;
11336
- if (store.has(key)) {
11337
- store.set(key, nextValue);
11338
+ const node = store.get(key);
11339
+ if (node) {
11340
+ node.value = nextValue;
11338
11341
  return true;
11339
11342
  }
11340
11343
  }
@@ -11358,10 +11361,8 @@ var RedBlackTree = class extends BST {
11358
11361
  const cmp = this._compare.bind(this);
11359
11362
  const c0 = cmp(key, hint.key);
11360
11363
  if (c0 === 0) {
11361
- if (this._isMapMode) {
11362
- if (value !== void 0) this._store.set(key, value);
11363
- else this._setValue(key, value);
11364
- } else hint.value = value;
11364
+ hint.value = value;
11365
+ if (this._isMapMode) this._store.set(key, hint);
11365
11366
  return hint;
11366
11367
  }
11367
11368
  if (c0 < 0) {
@@ -11369,10 +11370,7 @@ var RedBlackTree = class extends BST {
11369
11370
  const newNode = this.createNode(key, value);
11370
11371
  if (!this.isRealNode(newNode)) return void 0;
11371
11372
  this._attachNewNode(hint, "left", newNode);
11372
- if (this._isMapMode) {
11373
- if (value !== void 0) this._store.set(key, value);
11374
- else this._setValue(key, value);
11375
- }
11373
+ if (this._isMapMode) this._store.set(key, newNode);
11376
11374
  this._size++;
11377
11375
  const NIL = this.NIL;
11378
11376
  const hMin = this._header._left ?? NIL;
@@ -11389,10 +11387,7 @@ var RedBlackTree = class extends BST {
11389
11387
  const newNode = this.createNode(key, value);
11390
11388
  if (!this.isRealNode(newNode)) return void 0;
11391
11389
  this._attachNewNode(pred, "right", newNode);
11392
- if (this._isMapMode) {
11393
- if (value !== void 0) this._store.set(key, value);
11394
- else this._setValue(key, value);
11395
- }
11390
+ if (this._isMapMode) this._store.set(key, newNode);
11396
11391
  this._size++;
11397
11392
  const NIL = this.NIL;
11398
11393
  const hMin = this._header._left ?? NIL;
@@ -11407,10 +11402,7 @@ var RedBlackTree = class extends BST {
11407
11402
  const newNode = this.createNode(key, value);
11408
11403
  if (!this.isRealNode(newNode)) return void 0;
11409
11404
  this._attachNewNode(hint, "right", newNode);
11410
- if (this._isMapMode) {
11411
- if (value !== void 0) this._store.set(key, value);
11412
- else this._setValue(key, value);
11413
- }
11405
+ if (this._isMapMode) this._store.set(key, newNode);
11414
11406
  this._size++;
11415
11407
  const NIL = this.NIL;
11416
11408
  const hMin = this._header._left ?? NIL;
@@ -11427,10 +11419,7 @@ var RedBlackTree = class extends BST {
11427
11419
  const newNode = this.createNode(key, value);
11428
11420
  if (!this.isRealNode(newNode)) return void 0;
11429
11421
  this._attachNewNode(succ, "left", newNode);
11430
- if (this._isMapMode) {
11431
- if (value !== void 0) this._store.set(key, value);
11432
- else this._setValue(key, value);
11433
- }
11422
+ if (this._isMapMode) this._store.set(key, newNode);
11434
11423
  this._size++;
11435
11424
  const NIL = this.NIL;
11436
11425
  const hMin = this._header._left ?? NIL;
@@ -11477,12 +11466,24 @@ var RedBlackTree = class extends BST {
11477
11466
  } else {
11478
11467
  return false;
11479
11468
  }
11480
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11469
+ if (this._isMapMode) {
11470
+ const n = this.getNode(newNode.key);
11471
+ if (this.isRealNode(n)) {
11472
+ n.value = newValue;
11473
+ this._store.set(n.key, n);
11474
+ }
11475
+ }
11481
11476
  this._size++;
11482
11477
  return true;
11483
11478
  }
11484
11479
  if (insertStatus === "UPDATED") {
11485
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11480
+ if (this._isMapMode) {
11481
+ const n = this.getNode(newNode.key);
11482
+ if (this.isRealNode(n)) {
11483
+ n.value = newValue;
11484
+ this._store.set(n.key, n);
11485
+ }
11486
+ }
11486
11487
  return true;
11487
11488
  }
11488
11489
  return false;
@@ -11848,1457 +11849,1521 @@ var RedBlackTree = class extends BST {
11848
11849
  }
11849
11850
  };
11850
11851
 
11851
- // src/data-structures/binary-tree/avl-tree-multi-map.ts
11852
- var AVLTreeMultiMapNode = class {
11852
+ // src/data-structures/binary-tree/tree-set.ts
11853
+ var TreeSet = class _TreeSet {
11853
11854
  static {
11854
- __name(this, "AVLTreeMultiMapNode");
11855
+ __name(this, "TreeSet");
11855
11856
  }
11856
- key;
11857
- value;
11858
- parent = void 0;
11857
+ #core;
11858
+ #isDefaultComparator;
11859
+ #userComparator;
11859
11860
  /**
11860
- * Create an AVLTreeMultiMap node with a value bucket.
11861
- * @remarks Time O(1), Space O(1)
11862
- * @param key - Key of the node.
11863
- * @param value - Initial array of values.
11864
- * @returns New AVLTreeMultiMapNode instance.
11861
+ * Create a TreeSet from an iterable of keys.
11862
+ *
11863
+ * @throws {TypeError} When using the default comparator and encountering unsupported key types,
11864
+ * or invalid keys (e.g. `NaN`, invalid `Date`).
11865
11865
  */
11866
- constructor(key, value = []) {
11867
- this.key = key;
11868
- this.value = value;
11866
+ constructor(elements = [], options = {}) {
11867
+ this.#userComparator = options.comparator;
11868
+ const comparator = options.comparator ?? _TreeSet.createDefaultComparator();
11869
+ this.#isDefaultComparator = options.comparator === void 0;
11870
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
11871
+ for (const k of elements) this.add(k);
11869
11872
  }
11870
- _left = void 0;
11871
11873
  /**
11872
- * Get the left child pointer.
11873
- * @remarks Time O(1), Space O(1)
11874
- * @returns Left child node, or null/undefined.
11874
+ * Create the strict default comparator.
11875
+ *
11876
+ * Supports:
11877
+ * - `number` (rejects `NaN`; treats `-0` and `0` as equal)
11878
+ * - `string`
11879
+ * - `Date` (orders by `getTime()`, rejects invalid dates)
11880
+ *
11881
+ * For other key types, a custom comparator must be provided.
11875
11882
  */
11876
- get left() {
11877
- return this._left;
11883
+ static createDefaultComparator() {
11884
+ return (a, b) => {
11885
+ if (typeof a === "number" && typeof b === "number") {
11886
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeSet: NaN is not a valid key");
11887
+ const aa = Object.is(a, -0) ? 0 : a;
11888
+ const bb = Object.is(b, -0) ? 0 : b;
11889
+ return aa > bb ? 1 : aa < bb ? -1 : 0;
11890
+ }
11891
+ if (typeof a === "string" && typeof b === "string") {
11892
+ return a > b ? 1 : a < b ? -1 : 0;
11893
+ }
11894
+ if (a instanceof Date && b instanceof Date) {
11895
+ const ta = a.getTime();
11896
+ const tb = b.getTime();
11897
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeSet: invalid Date key");
11898
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
11899
+ }
11900
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11901
+ };
11878
11902
  }
11879
11903
  /**
11880
- * Set the left child and update its parent pointer.
11881
- * @remarks Time O(1), Space O(1)
11882
- * @param v - New left child node, or null/undefined.
11883
- * @returns void
11904
+ * Number of elements in the set.
11884
11905
  */
11885
- set left(v) {
11886
- if (v) {
11887
- v.parent = this;
11906
+ get size() {
11907
+ return this.#core.size;
11908
+ }
11909
+ /**
11910
+ * Whether the set is empty.
11911
+ */
11912
+ isEmpty() {
11913
+ return this.size === 0;
11914
+ }
11915
+ _validateKey(key) {
11916
+ if (!this.#isDefaultComparator) return;
11917
+ if (typeof key === "number") {
11918
+ if (Number.isNaN(key)) throw new TypeError("TreeSet: NaN is not a valid key");
11919
+ return;
11888
11920
  }
11889
- this._left = v;
11921
+ if (typeof key === "string") return;
11922
+ if (key instanceof Date) {
11923
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeSet: invalid Date key");
11924
+ return;
11925
+ }
11926
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11890
11927
  }
11891
- _right = void 0;
11892
11928
  /**
11893
- * Get the right child pointer.
11894
- * @remarks Time O(1), Space O(1)
11895
- * @returns Right child node, or null/undefined.
11929
+ * Add a key to the set (no-op if already present).
11930
+ * @remarks Expected time O(log n)
11896
11931
  */
11897
- get right() {
11898
- return this._right;
11932
+ add(key) {
11933
+ this._validateKey(key);
11934
+ this.#core.set(key, void 0);
11935
+ return this;
11899
11936
  }
11900
11937
  /**
11901
- * Set the right child and update its parent pointer.
11902
- * @remarks Time O(1), Space O(1)
11903
- * @param v - New right child node, or null/undefined.
11904
- * @returns void
11938
+ * Test whether a key exists.
11939
+ * @remarks Expected time O(log n)
11905
11940
  */
11906
- set right(v) {
11907
- if (v) {
11908
- v.parent = this;
11909
- }
11910
- this._right = v;
11941
+ has(key) {
11942
+ this._validateKey(key);
11943
+ return this.#core.has(key);
11911
11944
  }
11912
- _height = 0;
11913
11945
  /**
11914
- * Gets the height of the node (used in self-balancing trees).
11915
- * @remarks Time O(1), Space O(1)
11916
- *
11917
- * @returns The height.
11946
+ * Delete a key.
11947
+ * @returns `true` if the key existed; otherwise `false`.
11948
+ * @remarks Expected time O(log n)
11918
11949
  */
11919
- get height() {
11920
- return this._height;
11950
+ delete(key) {
11951
+ this._validateKey(key);
11952
+ const res = this.#core.delete(key);
11953
+ return Array.isArray(res) && res.length > 0 && !!res[0]?.deleted;
11921
11954
  }
11922
11955
  /**
11923
- * Sets the height of the node.
11924
- * @remarks Time O(1), Space O(1)
11925
- *
11926
- * @param value - The new height.
11956
+ * Remove all keys.
11927
11957
  */
11928
- set height(value) {
11929
- this._height = value;
11958
+ clear() {
11959
+ this.#core.clear();
11930
11960
  }
11931
- _color = "BLACK";
11932
11961
  /**
11933
- * Gets the color of the node (used in Red-Black trees).
11934
- * @remarks Time O(1), Space O(1)
11935
- *
11936
- * @returns The node's color.
11962
+ * Iterate over keys in ascending order.
11937
11963
  */
11938
- get color() {
11939
- return this._color;
11964
+ keys() {
11965
+ return this.#core.keys();
11940
11966
  }
11941
11967
  /**
11942
- * Sets the color of the node.
11943
- * @remarks Time O(1), Space O(1)
11968
+ * Iterate over values in ascending order.
11944
11969
  *
11945
- * @param value - The new color.
11970
+ * Note: for Set-like containers, `values()` is the same as `keys()`.
11946
11971
  */
11947
- set color(value) {
11948
- this._color = value;
11972
+ values() {
11973
+ return this.keys();
11949
11974
  }
11950
- _count = 1;
11951
11975
  /**
11952
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
11953
- * @remarks Time O(1), Space O(1)
11976
+ * Iterate over `[value, value]` pairs (native Set convention).
11954
11977
  *
11955
- * @returns The subtree node count.
11978
+ * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
11956
11979
  */
11957
- get count() {
11958
- return this._count;
11980
+ *entries() {
11981
+ for (const k of this.keys()) yield [k, k];
11982
+ }
11983
+ [Symbol.iterator]() {
11984
+ return this.keys();
11959
11985
  }
11960
11986
  /**
11961
- * Sets the count of nodes in the subtree.
11962
- * @remarks Time O(1), Space O(1)
11987
+ * Visit each value in ascending order.
11963
11988
  *
11964
- * @param value - The new count.
11989
+ * Callback follows native Set convention: `(value, value2, set)`.
11965
11990
  */
11966
- set count(value) {
11967
- this._count = value;
11991
+ forEach(cb, thisArg) {
11992
+ for (const k of this) cb.call(thisArg, k, k, this);
11968
11993
  }
11969
11994
  /**
11970
- * Gets the position of the node relative to its parent.
11971
- * @remarks Time O(1), Space O(1)
11995
+ * Create a new TreeSet by mapping each value to a new key.
11972
11996
  *
11973
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
11997
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
11998
+ * @remarks Time O(n log n) expected, Space O(n)
11974
11999
  */
11975
- get familyPosition() {
11976
- if (!this.parent) {
11977
- return this.left || this.right ? "ROOT" : "ISOLATED";
11978
- }
11979
- if (this.parent.left === this) {
11980
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
11981
- } else if (this.parent.right === this) {
11982
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12000
+ map(callbackfn, options = {}, thisArg) {
12001
+ const out = new _TreeSet([], options);
12002
+ let index = 0;
12003
+ for (const v of this) {
12004
+ const mk = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12005
+ out.add(mk);
11983
12006
  }
11984
- return "MAL_NODE";
11985
- }
11986
- };
11987
- var AVLTreeMultiMap = class extends AVLTree {
11988
- static {
11989
- __name(this, "AVLTreeMultiMap");
12007
+ return out;
11990
12008
  }
11991
12009
  /**
11992
- * Create an AVLTreeMultiMap and optionally bulk-insert items.
11993
- * @remarks Time O(N log N), Space O(N)
11994
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
11995
- * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
11996
- * @returns New AVLTreeMultiMap instance.
12010
+ * Create a new TreeSet containing only values that satisfy the predicate.
12011
+ * @remarks Time O(n log n) expected, Space O(n)
11997
12012
  */
11998
- constructor(keysNodesEntriesOrRaws = [], options) {
11999
- super([], { ...options, isMapMode: true });
12000
- if (keysNodesEntriesOrRaws) {
12001
- this.setMany(keysNodesEntriesOrRaws);
12013
+ filter(callbackfn, thisArg) {
12014
+ const out = new _TreeSet([], { comparator: this.#userComparator });
12015
+ let index = 0;
12016
+ for (const v of this) {
12017
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12018
+ if (ok) out.add(v);
12002
12019
  }
12003
- }
12004
- createNode(key, value = []) {
12005
- return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
12020
+ return out;
12006
12021
  }
12007
12022
  /**
12008
- * Checks if the given item is a `AVLTreeMultiMapNode` instance.
12009
- * @remarks Time O(1), Space O(1)
12010
- *
12011
- * @param keyNodeOrEntry - The item to check.
12012
- * @returns True if it's a AVLTreeMultiMapNode, false otherwise.
12023
+ * Reduce values into a single accumulator.
12024
+ * @remarks Time O(n), Space O(1)
12013
12025
  */
12014
- isNode(keyNodeOrEntry) {
12015
- return keyNodeOrEntry instanceof AVLTreeMultiMapNode;
12026
+ reduce(callbackfn, initialValue) {
12027
+ let acc = initialValue;
12028
+ let index = 0;
12029
+ for (const v of this) acc = callbackfn(acc, v, index++, this);
12030
+ return acc;
12016
12031
  }
12017
12032
  /**
12018
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12019
- * @remarks Time O(log N + M), Space O(1)
12020
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12021
- * @param [value] - Single value to set when a bare key is provided.
12022
- * @returns True if inserted or appended; false if ignored.
12033
+ * Test whether all values satisfy a predicate.
12034
+ * @remarks Time O(n), Space O(1)
12023
12035
  */
12024
- set(keyNodeOrEntry, value) {
12025
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12026
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12027
- if (key === void 0 || key === null) return false;
12028
- const _setToValues = /* @__PURE__ */ __name(() => {
12029
- const existingValues = this.get(key);
12030
- if (existingValues !== void 0 && values !== void 0) {
12031
- for (const value2 of values) existingValues.push(value2);
12032
- return true;
12033
- }
12034
- return false;
12035
- }, "_setToValues");
12036
- const _setByNode = /* @__PURE__ */ __name(() => {
12037
- const existingNode = this.getNode(key);
12038
- if (this.isRealNode(existingNode)) {
12039
- const existingValues = this.get(existingNode);
12040
- if (existingValues === void 0) {
12041
- super.set(key, values);
12042
- return true;
12043
- }
12044
- if (values !== void 0) {
12045
- for (const value2 of values) existingValues.push(value2);
12046
- return true;
12047
- } else {
12048
- return false;
12049
- }
12050
- } else {
12051
- return super.set(key, values);
12052
- }
12053
- }, "_setByNode");
12054
- if (this._isMapMode) {
12055
- return _setByNode() || _setToValues();
12056
- }
12057
- return _setToValues() || _setByNode();
12058
- }, "_commonAdd");
12059
- if (this.isEntry(keyNodeOrEntry)) {
12060
- const [key, values] = keyNodeOrEntry;
12061
- return _commonAdd(key, value !== void 0 ? [value] : values);
12036
+ every(callbackfn, thisArg) {
12037
+ let index = 0;
12038
+ for (const v of this) {
12039
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12040
+ if (!ok) return false;
12062
12041
  }
12063
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12042
+ return true;
12064
12043
  }
12065
12044
  /**
12066
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12067
- * @remarks Time O(log N), Space O(1)
12068
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12069
- * @param value - Value to remove from the bucket.
12070
- * @returns True if the value was removed; false if not found.
12071
- */
12072
- deleteValue(keyNodeOrEntry, value) {
12073
- const values = this.get(keyNodeOrEntry);
12074
- if (Array.isArray(values)) {
12075
- const index = values.indexOf(value);
12076
- if (index === -1) return false;
12077
- values.splice(index, 1);
12078
- if (values.length === 0) this.delete(keyNodeOrEntry);
12079
- return true;
12045
+ * Test whether any value satisfies a predicate.
12046
+ * @remarks Time O(n), Space O(1)
12047
+ */
12048
+ some(callbackfn, thisArg) {
12049
+ let index = 0;
12050
+ for (const v of this) {
12051
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12052
+ if (ok) return true;
12080
12053
  }
12081
12054
  return false;
12082
12055
  }
12083
12056
  /**
12084
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12085
- * @remarks Time O(N), Space O(N)
12086
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12087
- * @returns True if rebalancing succeeded (tree not empty).
12057
+ * Find the first value that satisfies a predicate.
12058
+ * @remarks Time O(n), Space O(1)
12088
12059
  */
12089
- perfectlyBalance(iterationType = this.iterationType) {
12090
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12091
- const n = nodes.length;
12092
- if (n === 0) return false;
12093
- this._clearNodes();
12094
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12095
- if (l > r) return void 0;
12096
- const m = l + (r - l >> 1);
12097
- const root = nodes[m];
12098
- root.left = build(l, m - 1, root);
12099
- root.right = build(m + 1, r, root);
12100
- root.parent = parent;
12101
- const lh = root.left ? root.left.height : -1;
12102
- const rh = root.right ? root.right.height : -1;
12103
- root.height = Math.max(lh, rh) + 1;
12104
- return root;
12105
- }, "build");
12106
- const newRoot = build(0, n - 1, void 0);
12107
- this._setRoot(newRoot);
12108
- this._size = n;
12109
- return true;
12060
+ find(callbackfn, thisArg) {
12061
+ let index = 0;
12062
+ for (const v of this) {
12063
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12064
+ if (ok) return v;
12065
+ }
12066
+ return void 0;
12110
12067
  }
12111
12068
  /**
12112
- * Create a new tree by mapping each [key, values] bucket.
12113
- * @remarks Time O(N log N), Space O(N)
12114
- * @template MK
12115
- * @template MV
12116
- * @template MR
12117
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12118
- * @param [options] - Options for the output tree.
12119
- * @param [thisArg] - Value for `this` inside the callback.
12120
- * @returns The mapped AVLTree or AVLTreeMultiMap depending on MV; see overloads.
12069
+ * Materialize the set into an array of keys.
12070
+ * @remarks Time O(n), Space O(n)
12121
12071
  */
12122
- map(callback, options, thisArg) {
12123
- const out = this._createLike([], options);
12124
- let i = 0;
12125
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12126
- return out;
12072
+ toArray() {
12073
+ return [...this];
12127
12074
  }
12128
12075
  /**
12129
- * (Protected) Create an empty instance of the same concrete class.
12130
- * @remarks Time O(1), Space O(1)
12131
- * @template TK
12132
- * @template TV
12133
- * @template TR
12134
- * @param [options] - Optional constructor options for the like-kind instance.
12135
- * @returns An empty like-kind instance.
12076
+ * Print a human-friendly representation.
12077
+ * @remarks Time O(n), Space O(n)
12136
12078
  */
12137
- _createInstance(options) {
12138
- const Ctor = this.constructor;
12139
- return new Ctor([], { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12079
+ print() {
12080
+ this.#core.print();
12140
12081
  }
12082
+ // Navigable operations
12141
12083
  /**
12142
- * (Protected) Create a like-kind instance and seed it from an iterable.
12143
- * @remarks Time O(N log N), Space O(N)
12144
- * @template TK
12145
- * @template TV
12146
- * @template TR
12147
- * @param iter - Iterable used to seed the new tree.
12148
- * @param [options] - Options merged with the current snapshot.
12149
- * @returns A like-kind AVLTree built from the iterable.
12084
+ * Smallest key in the set.
12150
12085
  */
12151
- _createLike(iter = [], options) {
12152
- const Ctor = this.constructor;
12153
- return new Ctor(iter, { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12154
- }
12155
- };
12156
-
12157
- // src/data-structures/binary-tree/tree-multi-map.ts
12158
- var TreeMultiMapNode = class {
12159
- static {
12160
- __name(this, "TreeMultiMapNode");
12086
+ first() {
12087
+ return this.#core.getLeftMost();
12161
12088
  }
12162
- key;
12163
- value;
12164
- parent = void 0;
12165
12089
  /**
12166
- * Create a TreeMultiMap node with an optional value bucket.
12167
- * @remarks Time O(1), Space O(1)
12168
- * @param key - Key of the node.
12169
- * @param [value] - Initial array of values.
12170
- * @returns New TreeMultiMapNode instance.
12090
+ * Largest key in the set.
12171
12091
  */
12172
- constructor(key, value = [], color = "BLACK") {
12173
- this.key = key;
12174
- this.value = value;
12175
- this.color = color;
12092
+ last() {
12093
+ return this.#core.getRightMost();
12176
12094
  }
12177
- _left = void 0;
12178
12095
  /**
12179
- * Get the left child pointer.
12180
- * @remarks Time O(1), Space O(1)
12181
- * @returns Left child node, or null/undefined.
12096
+ * Remove and return the smallest key.
12182
12097
  */
12183
- get left() {
12184
- return this._left;
12098
+ pollFirst() {
12099
+ const k = this.first();
12100
+ if (k === void 0) return void 0;
12101
+ this.delete(k);
12102
+ return k;
12185
12103
  }
12186
12104
  /**
12187
- * Set the left child and update its parent pointer.
12188
- * @remarks Time O(1), Space O(1)
12189
- * @param v - New left child node, or null/undefined.
12190
- * @returns void
12105
+ * Remove and return the largest key.
12191
12106
  */
12192
- set left(v) {
12193
- if (v) {
12194
- v.parent = this;
12195
- }
12196
- this._left = v;
12107
+ pollLast() {
12108
+ const k = this.last();
12109
+ if (k === void 0) return void 0;
12110
+ this.delete(k);
12111
+ return k;
12197
12112
  }
12198
- _right = void 0;
12199
12113
  /**
12200
- * Get the right child pointer.
12201
- * @remarks Time O(1), Space O(1)
12202
- * @returns Right child node, or null/undefined.
12114
+ * Smallest key that is >= the given key.
12203
12115
  */
12204
- get right() {
12205
- return this._right;
12116
+ ceiling(key) {
12117
+ this._validateKey(key);
12118
+ return this.#core.ceiling(key);
12206
12119
  }
12207
12120
  /**
12208
- * Set the right child and update its parent pointer.
12209
- * @remarks Time O(1), Space O(1)
12210
- * @param v - New right child node, or null/undefined.
12211
- * @returns void
12121
+ * Largest key that is <= the given key.
12212
12122
  */
12213
- set right(v) {
12214
- if (v) {
12215
- v.parent = this;
12216
- }
12217
- this._right = v;
12123
+ floor(key) {
12124
+ this._validateKey(key);
12125
+ return this.#core.floor(key);
12218
12126
  }
12219
- _height = 0;
12220
12127
  /**
12221
- * Gets the height of the node (used in self-balancing trees).
12222
- * @remarks Time O(1), Space O(1)
12223
- *
12224
- * @returns The height.
12128
+ * Smallest key that is > the given key.
12225
12129
  */
12226
- get height() {
12227
- return this._height;
12130
+ higher(key) {
12131
+ this._validateKey(key);
12132
+ return this.#core.higher(key);
12228
12133
  }
12229
12134
  /**
12230
- * Sets the height of the node.
12231
- * @remarks Time O(1), Space O(1)
12232
- *
12233
- * @param value - The new height.
12135
+ * Largest key that is < the given key.
12234
12136
  */
12235
- set height(value) {
12236
- this._height = value;
12137
+ lower(key) {
12138
+ this._validateKey(key);
12139
+ return this.#core.lower(key);
12237
12140
  }
12238
- _color = "BLACK";
12239
12141
  /**
12240
- * Gets the color of the node (used in Red-Black trees).
12241
- * @remarks Time O(1), Space O(1)
12142
+ * Return all keys in a given range.
12242
12143
  *
12243
- * @returns The node's color.
12144
+ * @param range `[low, high]`
12145
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12244
12146
  */
12245
- get color() {
12246
- return this._color;
12147
+ rangeSearch(range, options = {}) {
12148
+ const { lowInclusive = true, highInclusive = true } = options;
12149
+ const [low, high] = range;
12150
+ this._validateKey(low);
12151
+ this._validateKey(high);
12152
+ const keys = this.#core.rangeSearch([low, high]);
12153
+ const out = [];
12154
+ const cmp = this.#core.comparator;
12155
+ for (const k of keys) {
12156
+ if (k === void 0) continue;
12157
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12158
+ if (!highInclusive && cmp(k, high) === 0) continue;
12159
+ out.push(k);
12160
+ }
12161
+ return out;
12162
+ }
12163
+ };
12164
+
12165
+ // src/data-structures/binary-tree/tree-multi-map.ts
12166
+ var TreeMultiMapNode = class extends RedBlackTreeNode {
12167
+ static {
12168
+ __name(this, "TreeMultiMapNode");
12169
+ }
12170
+ constructor(key, value = []) {
12171
+ super(key, value);
12172
+ }
12173
+ };
12174
+ var TreeMultiMap = class _TreeMultiMap {
12175
+ static {
12176
+ __name(this, "TreeMultiMap");
12177
+ }
12178
+ #core;
12179
+ #isDefaultComparator;
12180
+ /**
12181
+ * Creates a new TreeMultiMap.
12182
+ * @param keysNodesEntriesOrRaws - Initial entries
12183
+ * @param options - Configuration options
12184
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial entries
12185
+ */
12186
+ constructor(keysNodesEntriesOrRaws = [], options = {}) {
12187
+ const comparator = options.comparator ?? TreeSet.createDefaultComparator();
12188
+ this.#isDefaultComparator = options.comparator === void 0;
12189
+ this.#core = new RedBlackTree([], { ...options, comparator, isMapMode: options.isMapMode });
12190
+ for (const x of keysNodesEntriesOrRaws) {
12191
+ if (x === null || x === void 0) continue;
12192
+ if (Array.isArray(x)) {
12193
+ const [k, bucket] = x;
12194
+ if (k === null || k === void 0) continue;
12195
+ if (bucket !== void 0) {
12196
+ this.#core.set(k, [...bucket]);
12197
+ } else {
12198
+ this.#core.set(k, []);
12199
+ }
12200
+ continue;
12201
+ }
12202
+ this.#core.set(x, []);
12203
+ }
12247
12204
  }
12248
12205
  /**
12249
- * Sets the color of the node.
12206
+ * Validates the key against the default comparator rules.
12250
12207
  * @remarks Time O(1), Space O(1)
12251
- *
12252
- * @param value - The new color.
12253
12208
  */
12254
- set color(value) {
12255
- this._color = value;
12209
+ _validateKey(key) {
12210
+ if (!this.#isDefaultComparator) return;
12211
+ if (typeof key === "number") {
12212
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiMap: NaN is not a valid key");
12213
+ return;
12214
+ }
12215
+ if (typeof key === "string") return;
12216
+ if (key instanceof Date) {
12217
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiMap: invalid Date key");
12218
+ return;
12219
+ }
12220
+ throw new TypeError("TreeMultiMap: comparator is required for non-number/non-string/non-Date keys");
12256
12221
  }
12257
- _count = 1;
12258
12222
  /**
12259
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12223
+ * Number of distinct keys.
12260
12224
  * @remarks Time O(1), Space O(1)
12261
- *
12262
- * @returns The subtree node count.
12263
12225
  */
12264
- get count() {
12265
- return this._count;
12226
+ get size() {
12227
+ return this.#core.size;
12266
12228
  }
12267
12229
  /**
12268
- * Sets the count of nodes in the subtree.
12230
+ * Whether the map is empty.
12269
12231
  * @remarks Time O(1), Space O(1)
12270
- *
12271
- * @param value - The new count.
12272
12232
  */
12273
- set count(value) {
12274
- this._count = value;
12233
+ isEmpty() {
12234
+ return this.size === 0;
12275
12235
  }
12276
12236
  /**
12277
- * Gets the position of the node relative to its parent.
12237
+ * Removes all entries from the map.
12278
12238
  * @remarks Time O(1), Space O(1)
12279
- *
12280
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12281
12239
  */
12282
- get familyPosition() {
12283
- if (!this.parent) {
12284
- return this.left || this.right ? "ROOT" : "ISOLATED";
12285
- }
12286
- if (this.parent.left === this) {
12287
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12288
- } else if (this.parent.right === this) {
12289
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12290
- }
12291
- return "MAL_NODE";
12240
+ clear() {
12241
+ this.#core.clear();
12292
12242
  }
12293
- };
12294
- var TreeMultiMap = class extends RedBlackTree {
12295
- static {
12296
- __name(this, "TreeMultiMap");
12243
+ /**
12244
+ * Bucket length for a key (missing => 0).
12245
+ * @remarks Time O(log n), Space O(1)
12246
+ */
12247
+ count(key) {
12248
+ const b = this.get(key);
12249
+ return Array.isArray(b) ? b.length : 0;
12297
12250
  }
12298
12251
  /**
12299
- * Create a TreeMultiMap and optionally bulk-insert items.
12300
- * @remarks Time O(N log N), Space O(N)
12301
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12302
- * @param [options] - Options for TreeMultiMap (comparator, reverse, map mode).
12303
- * @returns New TreeMultiMap instance.
12252
+ * Total number of values across all buckets (Σ bucket.length).
12253
+ * @remarks Time O(n), Space O(1)
12304
12254
  */
12305
- constructor(keysNodesEntriesOrRaws = [], options) {
12306
- super([], { ...options });
12307
- if (keysNodesEntriesOrRaws) {
12308
- this.setMany(keysNodesEntriesOrRaws);
12309
- }
12255
+ get totalSize() {
12256
+ let sum = 0;
12257
+ for (const [, bucket] of this) sum += bucket.length;
12258
+ return sum;
12310
12259
  }
12311
- createNode(key, value = []) {
12312
- return new TreeMultiMapNode(key, this._isMapMode ? [] : value);
12260
+ /**
12261
+ * Whether the map contains the given key.
12262
+ * @remarks Time O(log n), Space O(1)
12263
+ */
12264
+ has(key) {
12265
+ this._validateKey(key);
12266
+ return this.#core.has(key);
12313
12267
  }
12314
12268
  /**
12315
- * Checks if the given item is a `TreeMultiMapNode` instance.
12316
- * @remarks Time O(1), Space O(1)
12317
- *
12318
- * @param keyNodeOrEntry - The item to check.
12319
- * @returns True if it's a TreeMultiMapNode, false otherwise.
12269
+ * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
12270
+ * @remarks Time O(log n), Space O(1)
12320
12271
  */
12321
- isNode(keyNodeOrEntry) {
12322
- return keyNodeOrEntry instanceof TreeMultiMapNode;
12272
+ get(key) {
12273
+ this._validateKey(key);
12274
+ return this.#core.get(key);
12323
12275
  }
12324
12276
  /**
12325
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12326
- * @remarks Time O(log N + M), Space O(1)
12327
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12328
- * @param [value] - Single value to set when a bare key is provided.
12329
- * @returns True if inserted or appended; false if ignored.
12277
+ * Append a single value.
12278
+ * @remarks Time O(log n), Space O(1)
12330
12279
  */
12331
- set(keyNodeOrEntry, value) {
12332
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12333
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12334
- if (key === void 0 || key === null) return false;
12335
- const _setToValues = /* @__PURE__ */ __name(() => {
12336
- const existingValues = this.get(key);
12337
- if (existingValues !== void 0 && values !== void 0) {
12338
- for (const value2 of values) existingValues.push(value2);
12339
- return true;
12340
- }
12341
- return false;
12342
- }, "_setToValues");
12343
- const _setByNode = /* @__PURE__ */ __name(() => {
12344
- const existingNode = this.getNode(key);
12345
- if (this.isRealNode(existingNode)) {
12346
- const existingValues = this.get(existingNode);
12347
- if (existingValues === void 0) {
12348
- super.set(key, values);
12349
- return true;
12350
- }
12351
- if (values !== void 0) {
12352
- for (const value2 of values) existingValues.push(value2);
12353
- return true;
12354
- } else {
12355
- return false;
12356
- }
12357
- } else {
12358
- return super.set(key, values);
12359
- }
12360
- }, "_setByNode");
12361
- if (this._isMapMode) {
12362
- return _setByNode() || _setToValues();
12280
+ add(key, value) {
12281
+ this._validateKey(key);
12282
+ const bucket = this.#core.get(key);
12283
+ if (bucket) {
12284
+ bucket.push(value);
12285
+ return true;
12286
+ }
12287
+ return this.#core.set(key, [value]);
12288
+ }
12289
+ set(entry, value) {
12290
+ if (entry === null || entry === void 0) return false;
12291
+ if (Array.isArray(entry)) {
12292
+ const [k, bucket] = entry;
12293
+ if (k === null || k === void 0) return false;
12294
+ if (value !== void 0) return this.add(k, value);
12295
+ if (bucket === void 0) {
12296
+ return this.#core.set(k, []);
12363
12297
  }
12364
- return _setToValues() || _setByNode();
12365
- }, "_commonAdd");
12366
- if (this.isEntry(keyNodeOrEntry)) {
12367
- const [key, values] = keyNodeOrEntry;
12368
- return _commonAdd(key, value !== void 0 ? [value] : values);
12298
+ const existing = this.#core.get(k);
12299
+ if (existing) {
12300
+ existing.push(...bucket);
12301
+ return true;
12302
+ }
12303
+ return this.#core.set(k, [...bucket]);
12369
12304
  }
12370
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12305
+ if (value !== void 0) return this.add(entry, value);
12306
+ return this.#core.set(entry, []);
12371
12307
  }
12372
12308
  /**
12373
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12374
- * @remarks Time O(log N), Space O(1)
12375
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12376
- * @param value - Value to remove from the bucket.
12377
- * @returns True if the value was removed; false if not found.
12378
- */
12379
- deleteValue(keyNodeOrEntry, value) {
12380
- const values = this.get(keyNodeOrEntry);
12381
- if (Array.isArray(values)) {
12382
- const index = values.indexOf(value);
12383
- if (index === -1) return false;
12384
- values.splice(index, 1);
12385
- if (values.length === 0) this.delete(keyNodeOrEntry);
12386
- return true;
12387
- }
12388
- return false;
12309
+ * Deletes a key and its entire bucket.
12310
+ * @remarks Time O(log n), Space O(1)
12311
+ */
12312
+ delete(key) {
12313
+ this._validateKey(key);
12314
+ return this.#core.delete(key).length > 0;
12389
12315
  }
12390
12316
  /**
12391
- * Create a new tree by mapping each [key, values] bucket.
12392
- * @remarks Time O(N log N), Space O(N)
12393
- * @template MK
12394
- * @template MV
12395
- * @template MR
12396
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12397
- * @param [options] - Options for the output tree.
12398
- * @param [thisArg] - Value for `this` inside the callback.
12399
- * @returns A new RedBlackTree (or TreeMultiMap when mapping to array values; see overloads).
12317
+ * Check if a specific value exists in a key's bucket.
12318
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12400
12319
  */
12401
- map(callback, options, thisArg) {
12402
- const out = this._createLike([], options);
12403
- let i = 0;
12404
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12405
- return out;
12320
+ hasEntry(key, value, eq = Object.is) {
12321
+ const bucket = this.get(key);
12322
+ if (!Array.isArray(bucket)) return false;
12323
+ return bucket.some((v) => eq(v, value));
12406
12324
  }
12407
12325
  /**
12408
- * (Protected) Create an empty instance of the same concrete class.
12409
- * @remarks Time O(1), Space O(1)
12410
- * @template TK
12411
- * @template TV
12412
- * @template TR
12413
- * @param [options] - Optional constructor options for the like-kind instance.
12414
- * @returns An empty like-kind instance.
12326
+ * Delete a single occurrence of a value from a key's bucket.
12327
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12415
12328
  */
12416
- _createInstance(options) {
12417
- const Ctor = this.constructor;
12418
- return new Ctor([], { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12329
+ deleteValue(key, value, eq = Object.is) {
12330
+ const bucket = this.get(key);
12331
+ if (!Array.isArray(bucket)) return false;
12332
+ const idx = bucket.findIndex((v) => eq(v, value));
12333
+ if (idx === -1) return false;
12334
+ bucket.splice(idx, 1);
12335
+ if (bucket.length === 0) this.delete(key);
12336
+ return true;
12419
12337
  }
12420
12338
  /**
12421
- * (Protected) Create a like-kind instance and seed it from an iterable.
12422
- * @remarks Time O(N log N), Space O(N)
12423
- * @template TK
12424
- * @template TV
12425
- * @template TR
12426
- * @param iter - Iterable used to seed the new tree.
12427
- * @param [options] - Options merged with the current snapshot.
12428
- * @returns A like-kind RedBlackTree built from the iterable.
12339
+ * Delete all occurrences of a value from a key's bucket.
12340
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12429
12341
  */
12430
- _createLike(iter = [], options) {
12431
- const Ctor = this.constructor;
12432
- return new Ctor(iter, { ...this._snapshotOptions?.() ?? {}, ...options ?? {} });
12342
+ deleteValues(key, value, eq = Object.is) {
12343
+ const bucket = this.get(key);
12344
+ if (!Array.isArray(bucket) || bucket.length === 0) return 0;
12345
+ let removed = 0;
12346
+ for (let i = bucket.length - 1; i >= 0; i--) {
12347
+ if (eq(bucket[i], value)) {
12348
+ bucket.splice(i, 1);
12349
+ removed++;
12350
+ }
12351
+ }
12352
+ if (bucket.length === 0 && removed > 0) this.delete(key);
12353
+ return removed;
12433
12354
  }
12434
- };
12435
-
12436
- // src/data-structures/binary-tree/tree-counter.ts
12437
- var TreeCounterNode = class {
12438
- static {
12439
- __name(this, "TreeCounterNode");
12355
+ // ---- iteration (bucket view) ----
12356
+ /**
12357
+ * Iterates over all entries as [key, bucket] pairs.
12358
+ * @remarks Time O(n), Space O(1)
12359
+ */
12360
+ *[Symbol.iterator]() {
12361
+ for (const [k, v] of this.#core) {
12362
+ yield [k, v ?? []];
12363
+ }
12440
12364
  }
12441
- key;
12442
- value;
12443
- parent = void 0;
12444
12365
  /**
12445
- * Create a tree counter node.
12446
- * @remarks Time O(1), Space O(1)
12447
- * @param key - Key of the node.
12448
- * @param [value] - Value associated with the key (ignored in map mode).
12449
- * @param [count] - Initial count for this node (default 1).
12450
- * @param color - Initial color ('RED' or 'BLACK').
12451
- * @returns New TreeCounterNode instance.
12366
+ * Iterates over all keys.
12367
+ * @remarks Time O(n), Space O(1)
12452
12368
  */
12453
- constructor(key, value, count = 1, color = "BLACK") {
12454
- this.key = key;
12455
- this.value = value;
12456
- this.color = color;
12457
- this.count = count;
12369
+ *keys() {
12370
+ yield* this.#core.keys();
12458
12371
  }
12459
- _left = void 0;
12460
12372
  /**
12461
- * Get the left child pointer.
12462
- * @remarks Time O(1), Space O(1)
12463
- * @returns Left child node, or null/undefined.
12373
+ * Iterates over all buckets.
12374
+ * @remarks Time O(n), Space O(1)
12464
12375
  */
12465
- get left() {
12466
- return this._left;
12376
+ *values() {
12377
+ for (const [, bucket] of this) yield bucket;
12467
12378
  }
12379
+ // ---- entry-flat views ----
12468
12380
  /**
12469
- * Set the left child and update its parent pointer.
12470
- * @remarks Time O(1), Space O(1)
12471
- * @param v - New left child node, or null/undefined.
12472
- * @returns void
12381
+ * Iterates over all entries for a specific key.
12382
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12473
12383
  */
12474
- set left(v) {
12475
- if (v) {
12476
- v.parent = this;
12477
- }
12478
- this._left = v;
12384
+ *entriesOf(key) {
12385
+ const bucket = this.get(key);
12386
+ if (!Array.isArray(bucket)) return;
12387
+ for (const v of bucket) yield [key, v];
12479
12388
  }
12480
- _right = void 0;
12481
12389
  /**
12482
- * Get the right child pointer.
12483
- * @remarks Time O(1), Space O(1)
12484
- * @returns Right child node, or null/undefined.
12390
+ * Iterates over all values for a specific key.
12391
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12485
12392
  */
12486
- get right() {
12487
- return this._right;
12393
+ *valuesOf(key) {
12394
+ const bucket = this.get(key);
12395
+ if (!Array.isArray(bucket)) return;
12396
+ yield* bucket;
12488
12397
  }
12489
12398
  /**
12490
- * Set the right child and update its parent pointer.
12491
- * @remarks Time O(1), Space O(1)
12492
- * @param v - New right child node, or null/undefined.
12493
- * @returns void
12399
+ * Iterates over all [key, value] pairs (flattened from buckets).
12400
+ * @remarks Time O(T), Space O(1) where T is totalSize
12494
12401
  */
12495
- set right(v) {
12496
- if (v) {
12497
- v.parent = this;
12402
+ *flatEntries() {
12403
+ for (const [k, bucket] of this) {
12404
+ for (const v of bucket) yield [k, v];
12498
12405
  }
12499
- this._right = v;
12500
12406
  }
12501
- _height = 0;
12407
+ // ━━━ Navigable methods (return [K, V[]] | undefined) ━━━
12502
12408
  /**
12503
- * Gets the height of the node (used in self-balancing trees).
12504
- * @remarks Time O(1), Space O(1)
12505
- *
12506
- * @returns The height.
12409
+ * Returns the entry with the smallest key.
12410
+ * @remarks Time O(log n), Space O(1)
12411
+ * @example
12412
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12413
+ * map.first(); // [1, ['a']]
12507
12414
  */
12508
- get height() {
12509
- return this._height;
12415
+ first() {
12416
+ const k = this.#core.getLeftMost();
12417
+ if (k === void 0) return void 0;
12418
+ const b = this.get(k);
12419
+ return b === void 0 ? void 0 : [k, b];
12510
12420
  }
12511
12421
  /**
12512
- * Sets the height of the node.
12513
- * @remarks Time O(1), Space O(1)
12514
- *
12515
- * @param value - The new height.
12422
+ * Returns the entry with the largest key.
12423
+ * @remarks Time O(log n), Space O(1)
12424
+ * @example
12425
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12426
+ * map.last(); // [2, ['b']]
12516
12427
  */
12517
- set height(value) {
12518
- this._height = value;
12428
+ last() {
12429
+ const k = this.#core.getRightMost();
12430
+ if (k === void 0) return void 0;
12431
+ const b = this.get(k);
12432
+ return b === void 0 ? void 0 : [k, b];
12519
12433
  }
12520
- _color = "BLACK";
12521
12434
  /**
12522
- * Gets the color of the node (used in Red-Black trees).
12523
- * @remarks Time O(1), Space O(1)
12524
- *
12525
- * @returns The node's color.
12435
+ * Removes and returns the entry with the smallest key.
12436
+ * @remarks Time O(log n), Space O(1)
12437
+ * @example
12438
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12439
+ * map.pollFirst(); // [1, ['a']]
12440
+ * map.has(1); // false
12526
12441
  */
12527
- get color() {
12528
- return this._color;
12442
+ pollFirst() {
12443
+ const e = this.first();
12444
+ if (!e) return void 0;
12445
+ this.delete(e[0]);
12446
+ return e;
12529
12447
  }
12530
12448
  /**
12531
- * Sets the color of the node.
12532
- * @remarks Time O(1), Space O(1)
12533
- *
12534
- * @param value - The new color.
12449
+ * Removes and returns the entry with the largest key.
12450
+ * @remarks Time O(log n), Space O(1)
12451
+ * @example
12452
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12453
+ * map.pollLast(); // [2, ['b']]
12454
+ * map.has(2); // false
12535
12455
  */
12536
- set color(value) {
12537
- this._color = value;
12456
+ pollLast() {
12457
+ const e = this.last();
12458
+ if (!e) return void 0;
12459
+ this.delete(e[0]);
12460
+ return e;
12538
12461
  }
12539
- _count = 1;
12540
12462
  /**
12541
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12542
- * @remarks Time O(1), Space O(1)
12543
- *
12544
- * @returns The subtree node count.
12463
+ * Returns the entry with the smallest key >= given key.
12464
+ * @remarks Time O(log n), Space O(1)
12465
+ * @example
12466
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12467
+ * map.ceiling(15); // [20, ['b']]
12468
+ * map.ceiling(20); // [20, ['b']]
12545
12469
  */
12546
- get count() {
12547
- return this._count;
12470
+ ceiling(key) {
12471
+ this._validateKey(key);
12472
+ const k = this.#core.ceiling(key);
12473
+ if (k === void 0) return void 0;
12474
+ const b = this.get(k);
12475
+ return b === void 0 ? void 0 : [k, b];
12548
12476
  }
12549
12477
  /**
12550
- * Sets the count of nodes in the subtree.
12551
- * @remarks Time O(1), Space O(1)
12552
- *
12553
- * @param value - The new count.
12478
+ * Returns the entry with the largest key <= given key.
12479
+ * @remarks Time O(log n), Space O(1)
12480
+ * @example
12481
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12482
+ * map.floor(25); // [20, ['b']]
12483
+ * map.floor(20); // [20, ['b']]
12484
+ */
12485
+ floor(key) {
12486
+ this._validateKey(key);
12487
+ const k = this.#core.floor(key);
12488
+ if (k === void 0) return void 0;
12489
+ const b = this.get(k);
12490
+ return b === void 0 ? void 0 : [k, b];
12491
+ }
12492
+ /**
12493
+ * Returns the entry with the smallest key > given key.
12494
+ * @remarks Time O(log n), Space O(1)
12495
+ * @example
12496
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12497
+ * map.higher(10); // [20, ['b']]
12498
+ * map.higher(15); // [20, ['b']]
12554
12499
  */
12555
- set count(value) {
12556
- this._count = value;
12500
+ higher(key) {
12501
+ this._validateKey(key);
12502
+ const k = this.#core.higher(key);
12503
+ if (k === void 0) return void 0;
12504
+ const b = this.get(k);
12505
+ return b === void 0 ? void 0 : [k, b];
12557
12506
  }
12558
12507
  /**
12559
- * Gets the position of the node relative to its parent.
12560
- * @remarks Time O(1), Space O(1)
12561
- *
12562
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12508
+ * Returns the entry with the largest key < given key.
12509
+ * @remarks Time O(log n), Space O(1)
12510
+ * @example
12511
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12512
+ * map.lower(20); // [10, ['a']]
12513
+ * map.lower(15); // [10, ['a']]
12563
12514
  */
12564
- get familyPosition() {
12565
- if (!this.parent) {
12566
- return this.left || this.right ? "ROOT" : "ISOLATED";
12515
+ lower(key) {
12516
+ this._validateKey(key);
12517
+ const k = this.#core.lower(key);
12518
+ if (k === void 0) return void 0;
12519
+ const b = this.get(k);
12520
+ return b === void 0 ? void 0 : [k, b];
12521
+ }
12522
+ // ━━━ Tree utilities ━━━
12523
+ /**
12524
+ * Prints the internal tree structure (for debugging).
12525
+ * @remarks Time O(n), Space O(n)
12526
+ */
12527
+ print(...args) {
12528
+ return this.#core.print(...args);
12529
+ }
12530
+ /**
12531
+ * Executes a callback for each entry.
12532
+ * @remarks Time O(n), Space O(1)
12533
+ */
12534
+ forEach(callback) {
12535
+ for (const [k, v] of this) {
12536
+ callback(v, k, this);
12567
12537
  }
12568
- if (this.parent.left === this) {
12569
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12570
- } else if (this.parent.right === this) {
12571
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12538
+ }
12539
+ /**
12540
+ * Creates a new map with entries that pass the predicate.
12541
+ * @remarks Time O(n), Space O(n)
12542
+ */
12543
+ filter(predicate) {
12544
+ const filtered = [];
12545
+ for (const [k, v] of this) {
12546
+ if (predicate(v, k, this)) filtered.push([k, v]);
12572
12547
  }
12573
- return "MAL_NODE";
12548
+ return new _TreeMultiMap(filtered, { comparator: this.comparator });
12574
12549
  }
12575
- };
12576
- var TreeCounter = class extends RedBlackTree {
12577
- static {
12578
- __name(this, "TreeCounter");
12550
+ /**
12551
+ * Creates a new map by transforming each entry.
12552
+ * @remarks Time O(n log n), Space O(n)
12553
+ */
12554
+ map(mapper) {
12555
+ const mapped = [];
12556
+ for (const [k, v] of this) {
12557
+ mapped.push(mapper(v, k, this));
12558
+ }
12559
+ return new _TreeMultiMap(mapped, { comparator: this.comparator });
12579
12560
  }
12580
12561
  /**
12581
- * Create a TreeCounter and optionally bulk-insert items.
12582
- * @remarks Time O(N log N), Space O(N)
12583
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12584
- * @param [options] - Options for TreeCounter (comparator, reverse, map mode).
12585
- * @returns New TreeCounter instance.
12562
+ * Reduces all entries to a single value.
12563
+ * @remarks Time O(n), Space O(1)
12586
12564
  */
12587
- constructor(keysNodesEntriesOrRaws = [], options) {
12588
- super([], options);
12589
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
12565
+ reduce(callback, initialValue) {
12566
+ let acc = initialValue;
12567
+ for (const [k, v] of this) {
12568
+ acc = callback(acc, v, k, this);
12569
+ }
12570
+ return acc;
12590
12571
  }
12591
- _count = 0;
12592
12572
  /**
12593
- * Get the total aggregate count across all nodes.
12594
- * @remarks Time O(1), Space O(1)
12595
- * @returns Total count.
12573
+ * Sets multiple entries at once.
12574
+ * @remarks Time O(m log n), Space O(m) where m is input size
12596
12575
  */
12597
- get count() {
12598
- return this._count;
12576
+ setMany(keysNodesEntriesOrRaws) {
12577
+ const results = [];
12578
+ for (const x of keysNodesEntriesOrRaws) {
12579
+ results.push(this.set(x, void 0));
12580
+ }
12581
+ return results;
12599
12582
  }
12600
12583
  /**
12601
- * Compute the total count by traversing the tree (sums node.count).
12602
- * @remarks Time O(N), Space O(H)
12603
- * @returns Total count recomputed from nodes.
12584
+ * Searches for entries within a key range.
12585
+ * @remarks Time O(log n + k), Space O(k) where k is result size
12604
12586
  */
12605
- getComputedCount() {
12606
- let sum = 0;
12607
- this.dfs((node) => sum += node ? node.count : 0);
12608
- return sum;
12587
+ rangeSearch(range, callback, isBalanced) {
12588
+ return this.#core.rangeSearch(range, callback, isBalanced);
12609
12589
  }
12610
- createNode(key, value, color = "BLACK", count) {
12611
- return new TreeCounterNode(key, this._isMapMode ? void 0 : value, count, color);
12590
+ /**
12591
+ * Creates a shallow clone of this map.
12592
+ * @remarks Time O(n log n), Space O(n)
12593
+ */
12594
+ clone() {
12595
+ return new _TreeMultiMap(this, { comparator: this.comparator, isMapMode: this.#core._isMapMode });
12612
12596
  }
12613
12597
  /**
12614
- * Type guard: check whether the input is a TreeCounterNode.
12598
+ * Expose comparator for advanced usage/testing (read-only).
12615
12599
  * @remarks Time O(1), Space O(1)
12616
- * @returns True if the value is a TreeCounterNode.
12617
12600
  */
12618
- isNode(keyNodeOrEntry) {
12619
- return keyNodeOrEntry instanceof TreeCounterNode;
12601
+ get comparator() {
12602
+ return this.#core._comparator;
12603
+ }
12604
+ };
12605
+
12606
+ // src/data-structures/binary-tree/tree-map.ts
12607
+ var TreeMap = class _TreeMap {
12608
+ static {
12609
+ __name(this, "TreeMap");
12620
12610
  }
12611
+ #core;
12612
+ #isDefaultComparator;
12613
+ #userComparator;
12621
12614
  /**
12622
- * Insert or increment a node and update aggregate count.
12623
- * @remarks Time O(log N), Space O(1)
12624
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
12625
- * @param [value] - Value when a bare key is provided (ignored in map mode).
12626
- * @param [count] - How much to increase the node's count (default 1).
12627
- * @returns True if inserted/updated; false if ignored.
12628
- */
12629
- set(keyNodeOrEntry, value, count = 1) {
12630
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
12631
- const orgCount = newNode?.count || 0;
12632
- const isSuccessAdded = super.set(newNode, newValue);
12633
- if (isSuccessAdded) {
12634
- this._count += orgCount;
12635
- return true;
12636
- } else {
12637
- return false;
12615
+ * Create a TreeMap from an iterable of `[key, value]` entries.
12616
+ *
12617
+ * @throws {TypeError} If any entry is not a 2-tuple-like value, or when using the default comparator
12618
+ * and encountering unsupported/invalid keys (e.g. `NaN`, invalid `Date`).
12619
+ */
12620
+ constructor(entries = [], options = {}) {
12621
+ this.#userComparator = options.comparator;
12622
+ const comparator = options.comparator ?? _TreeMap.createDefaultComparator();
12623
+ this.#isDefaultComparator = options.comparator === void 0;
12624
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
12625
+ for (const item of entries) {
12626
+ if (!Array.isArray(item) || item.length < 2) {
12627
+ throw new TypeError("TreeMap: each entry must be a [key, value] tuple");
12628
+ }
12629
+ const k = item[0];
12630
+ const v = item[1];
12631
+ this.set(k, v);
12638
12632
  }
12639
12633
  }
12640
12634
  /**
12641
- * Delete a node (or decrement its count) and rebalance if needed.
12642
- * @remarks Time O(log N), Space O(1)
12643
- * @param keyNodeEntryRawOrPredicate - Key, node, or [key, value] entry identifying the node.
12644
- * @param [ignoreCount] - If true, remove the node regardless of its count.
12645
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
12635
+ * Create the strict default comparator.
12636
+ *
12637
+ * Supports:
12638
+ * - `number` (rejects `NaN`; treats `-0` and `0` as equal)
12639
+ * - `string`
12640
+ * - `Date` (orders by `getTime()`, rejects invalid dates)
12641
+ *
12642
+ * For other key types, a custom comparator must be provided.
12646
12643
  */
12647
- delete(keyNodeEntryRawOrPredicate, ignoreCount = false) {
12648
- if (keyNodeEntryRawOrPredicate === null) return [];
12649
- const results = [];
12650
- let nodeToDelete;
12651
- if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);
12652
- else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);
12653
- if (!nodeToDelete) {
12654
- return results;
12655
- }
12656
- let originalColor = nodeToDelete.color;
12657
- let replacementNode;
12658
- if (!this.isRealNode(nodeToDelete.left)) {
12659
- if (nodeToDelete.right !== null) replacementNode = nodeToDelete.right;
12660
- if (ignoreCount || nodeToDelete.count <= 1) {
12661
- if (nodeToDelete.right !== null) {
12662
- this._transplant(nodeToDelete, nodeToDelete.right);
12663
- this._count -= nodeToDelete.count;
12664
- }
12665
- } else {
12666
- nodeToDelete.count--;
12667
- this._count--;
12668
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12669
- return results;
12670
- }
12671
- } else if (!this.isRealNode(nodeToDelete.right)) {
12672
- replacementNode = nodeToDelete.left;
12673
- if (ignoreCount || nodeToDelete.count <= 1) {
12674
- this._transplant(nodeToDelete, nodeToDelete.left);
12675
- this._count -= nodeToDelete.count;
12676
- } else {
12677
- nodeToDelete.count--;
12678
- this._count--;
12679
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12680
- return results;
12681
- }
12682
- } else {
12683
- const successor = this.getLeftMost((node) => node, nodeToDelete.right);
12684
- if (successor) {
12685
- originalColor = successor.color;
12686
- if (successor.right !== null) replacementNode = successor.right;
12687
- if (successor.parent === nodeToDelete) {
12688
- if (this.isRealNode(replacementNode)) {
12689
- replacementNode.parent = successor;
12690
- }
12691
- } else {
12692
- if (ignoreCount || nodeToDelete.count <= 1) {
12693
- if (successor.right !== null) {
12694
- this._transplant(successor, successor.right);
12695
- }
12696
- } else {
12697
- nodeToDelete.count--;
12698
- this._count--;
12699
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12700
- return results;
12701
- }
12702
- successor.right = nodeToDelete.right;
12703
- if (this.isRealNode(successor.right)) {
12704
- successor.right.parent = successor;
12705
- }
12706
- }
12707
- if (ignoreCount || nodeToDelete.count <= 1) {
12708
- this._transplant(nodeToDelete, successor);
12709
- this._count -= nodeToDelete.count;
12710
- } else {
12711
- nodeToDelete.count--;
12712
- this._count--;
12713
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12714
- return results;
12715
- }
12716
- successor.left = nodeToDelete.left;
12717
- if (this.isRealNode(successor.left)) {
12718
- successor.left.parent = successor;
12719
- }
12720
- successor.color = nodeToDelete.color;
12721
- }
12644
+ static createDefaultComparator() {
12645
+ return (a, b) => {
12646
+ if (typeof a === "number" && typeof b === "number") {
12647
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeMap: NaN is not a valid key");
12648
+ const aa = Object.is(a, -0) ? 0 : a;
12649
+ const bb = Object.is(b, -0) ? 0 : b;
12650
+ return aa > bb ? 1 : aa < bb ? -1 : 0;
12651
+ }
12652
+ if (typeof a === "string" && typeof b === "string") {
12653
+ return a > b ? 1 : a < b ? -1 : 0;
12654
+ }
12655
+ if (a instanceof Date && b instanceof Date) {
12656
+ const ta = a.getTime();
12657
+ const tb = b.getTime();
12658
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeMap: invalid Date key");
12659
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
12660
+ }
12661
+ throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
12662
+ };
12663
+ }
12664
+ _validateKey(key) {
12665
+ if (!this.#isDefaultComparator) return;
12666
+ if (typeof key === "number") {
12667
+ if (Number.isNaN(key)) throw new TypeError("TreeMap: NaN is not a valid key");
12668
+ return;
12722
12669
  }
12723
- this._size--;
12724
- if (originalColor === "BLACK") {
12725
- this._deleteFixup(replacementNode);
12670
+ if (typeof key === "string") return;
12671
+ if (key instanceof Date) {
12672
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMap: invalid Date key");
12673
+ return;
12726
12674
  }
12727
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12728
- return results;
12675
+ throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
12729
12676
  }
12730
12677
  /**
12731
- * Remove all nodes and reset aggregate counters.
12732
- * @remarks Time O(N), Space O(1)
12733
- * @returns void
12678
+ * Number of entries in the map.
12679
+ */
12680
+ get size() {
12681
+ return this.#core.size;
12682
+ }
12683
+ /**
12684
+ * Whether the map is empty.
12685
+ */
12686
+ isEmpty() {
12687
+ return this.size === 0;
12688
+ }
12689
+ /**
12690
+ * Set or overwrite a value for a key.
12691
+ * @remarks Expected time O(log n)
12692
+ */
12693
+ set(key, value) {
12694
+ this._validateKey(key);
12695
+ this.#core.set(key, value);
12696
+ return this;
12697
+ }
12698
+ /**
12699
+ * Get the value under a key.
12700
+ * @remarks Expected time O(log n)
12701
+ */
12702
+ get(key) {
12703
+ this._validateKey(key);
12704
+ return this.#core.get(key);
12705
+ }
12706
+ /**
12707
+ * Test whether a key exists.
12708
+ * @remarks Expected time O(log n)
12709
+ */
12710
+ has(key) {
12711
+ this._validateKey(key);
12712
+ return this.#core.has(key);
12713
+ }
12714
+ /**
12715
+ * Delete a key.
12716
+ * @returns `true` if the key existed; otherwise `false`.
12717
+ * @remarks Expected time O(log n)
12718
+ */
12719
+ delete(key) {
12720
+ this._validateKey(key);
12721
+ const res = this.#core.delete(key);
12722
+ return Array.isArray(res) && res.length > 0 && !!res[0]?.deleted;
12723
+ }
12724
+ /**
12725
+ * Remove all entries.
12734
12726
  */
12735
12727
  clear() {
12736
- super.clear();
12737
- this._count = 0;
12728
+ this.#core.clear();
12738
12729
  }
12739
12730
  /**
12740
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12741
- * @remarks Time O(N), Space O(N)
12742
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12743
- * @returns True if rebalancing succeeded (tree not empty).
12731
+ * Iterate over keys in ascending order.
12744
12732
  */
12745
- perfectlyBalance(iterationType = this.iterationType) {
12746
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12747
- const n = nodes.length;
12748
- if (n < 1) return false;
12749
- let total = 0;
12750
- for (const nd of nodes) total += nd ? nd.count : 0;
12751
- this._clearNodes();
12752
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12753
- if (l > r) return void 0;
12754
- const m = l + (r - l >> 1);
12755
- const root = nodes[m];
12756
- const leftChild = build(l, m - 1, root);
12757
- const rightChild = build(m + 1, r, root);
12758
- root.left = leftChild;
12759
- root.right = rightChild;
12760
- root.parent = parent;
12761
- return root;
12762
- }, "build");
12763
- const newRoot = build(0, n - 1, void 0);
12764
- this._setRoot(newRoot);
12765
- this._size = n;
12766
- this._count = total;
12767
- return true;
12733
+ keys() {
12734
+ return this.#core.keys();
12735
+ }
12736
+ _entryFromKey(k) {
12737
+ return [k, this.#core.get(k)];
12768
12738
  }
12769
12739
  /**
12770
- * Create a new TreeCounter by mapping each [key, value] entry.
12771
- * @remarks Time O(N log N), Space O(N)
12772
- * @template MK
12773
- * @template MV
12774
- * @template MR
12775
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
12776
- * @param [options] - Options for the output tree.
12777
- * @param [thisArg] - Value for `this` inside the callback.
12778
- * @returns A new TreeCounter with mapped entries.
12740
+ * Iterate over values in ascending key order.
12741
+ *
12742
+ * Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
12779
12743
  */
12780
- map(callback, options, thisArg) {
12781
- const out = this._createLike([], options);
12744
+ *values() {
12745
+ for (const k of this.keys()) yield this._entryFromKey(k)[1];
12746
+ }
12747
+ /**
12748
+ * Iterate over `[key, value]` entries in ascending key order.
12749
+ *
12750
+ * Note: values may be `undefined`.
12751
+ */
12752
+ *entries() {
12753
+ for (const k of this.keys()) yield this._entryFromKey(k);
12754
+ }
12755
+ [Symbol.iterator]() {
12756
+ return this.entries();
12757
+ }
12758
+ /**
12759
+ * Visit each entry in ascending key order.
12760
+ *
12761
+ * Note: callback value may be `undefined`.
12762
+ */
12763
+ forEach(cb, thisArg) {
12764
+ for (const [k, v] of this) cb.call(thisArg, v, k, this);
12765
+ }
12766
+ /**
12767
+ * Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
12768
+ *
12769
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
12770
+ * @remarks Time O(n log n) expected, Space O(n)
12771
+ */
12772
+ map(callbackfn, options = {}, thisArg) {
12773
+ const out = new _TreeMap([], options);
12782
12774
  let index = 0;
12783
- for (const [key, value] of this) {
12784
- out.set(callback.call(thisArg, value, key, index++, this));
12775
+ for (const [k, v] of this) {
12776
+ const [mk, mv] = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12777
+ out.set(mk, mv);
12785
12778
  }
12786
12779
  return out;
12787
12780
  }
12788
12781
  /**
12789
- * Deep copy this tree, preserving map mode and aggregate counts.
12790
- * @remarks Time O(N), Space O(N)
12791
- * @returns A deep copy of this tree.
12782
+ * Create a new TreeMap containing only entries that satisfy the predicate.
12783
+ * @remarks Time O(n log n) expected, Space O(n)
12792
12784
  */
12793
- clone() {
12794
- const out = this._createInstance();
12795
- this._clone(out);
12796
- out._count = this._count;
12797
- for (const node of this.dfs((n) => n, "IN")) {
12798
- if (!node) continue;
12799
- const outNode = out.getNode(node.key);
12800
- if (outNode) outNode.count = node.count;
12785
+ filter(callbackfn, thisArg) {
12786
+ const out = new _TreeMap([], { comparator: this.#userComparator });
12787
+ let index = 0;
12788
+ for (const [k, v] of this) {
12789
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12790
+ if (ok) out.set(k, v);
12801
12791
  }
12802
12792
  return out;
12803
12793
  }
12804
12794
  /**
12805
- * (Protected) Create an empty instance of the same concrete class.
12806
- * @remarks Time O(1), Space O(1)
12807
- * @template TK
12808
- * @template TV
12809
- * @template TR
12810
- * @param [options] - Optional constructor options for the like-kind instance.
12811
- * @returns An empty like-kind instance.
12795
+ * Reduce entries into a single accumulator.
12796
+ * @remarks Time O(n), Space O(1)
12812
12797
  */
12813
- _createInstance(options) {
12814
- const Ctor = this.constructor;
12815
- return new Ctor([], { ...this._snapshotOptions(), ...options ?? {} });
12798
+ reduce(callbackfn, initialValue) {
12799
+ let acc = initialValue;
12800
+ let index = 0;
12801
+ for (const [k, v] of this) acc = callbackfn(acc, v, k, index++, this);
12802
+ return acc;
12816
12803
  }
12817
12804
  /**
12818
- * (Protected) Create a like-kind instance and seed it from an iterable.
12819
- * @remarks Time O(N log N), Space O(N)
12820
- * @template TK
12821
- * @template TV
12822
- * @template TR
12823
- * @param iter - Iterable used to seed the new tree.
12824
- * @param [options] - Options merged with the current snapshot.
12825
- * @returns A like-kind TreeCounter built from the iterable.
12805
+ * Test whether all entries satisfy a predicate.
12806
+ * @remarks Time O(n), Space O(1)
12826
12807
  */
12827
- _createLike(iter = [], options) {
12828
- const Ctor = this.constructor;
12829
- return new Ctor(iter, {
12830
- ...this._snapshotOptions(),
12831
- ...options ?? {}
12832
- });
12808
+ every(callbackfn, thisArg) {
12809
+ let index = 0;
12810
+ for (const [k, v] of this) {
12811
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12812
+ if (!ok) return false;
12813
+ }
12814
+ return true;
12833
12815
  }
12834
12816
  /**
12835
- * (Protected) Normalize input into a node plus its effective value and count.
12836
- * @remarks Time O(1), Space O(1)
12837
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
12838
- * @param [value] - Value used when a bare key is provided.
12839
- * @param [count] - Count increment to apply (default 1).
12840
- * @returns Tuple [node, value] where node may be undefined.
12817
+ * Test whether any entry satisfies a predicate.
12818
+ * @remarks Time O(n), Space O(1)
12841
12819
  */
12842
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
12843
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
12844
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
12845
- if (this.isEntry(keyNodeOrEntry)) {
12846
- const [key, entryValue] = keyNodeOrEntry;
12847
- if (key === void 0 || key === null) return [void 0, void 0];
12848
- const finalValue = value ?? entryValue;
12849
- return [this.createNode(key, finalValue, "BLACK", count), finalValue];
12820
+ some(callbackfn, thisArg) {
12821
+ let index = 0;
12822
+ for (const [k, v] of this) {
12823
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12824
+ if (ok) return true;
12850
12825
  }
12851
- return [this.createNode(keyNodeOrEntry, value, "BLACK", count), value];
12826
+ return false;
12852
12827
  }
12853
12828
  /**
12854
- * (Protected) Swap keys/values/counters between the source and destination nodes.
12855
- * @remarks Time O(1), Space O(1)
12856
- * @param srcNode - Source node (or key) whose properties will be moved.
12857
- * @param destNode - Destination node (or key) to receive properties.
12858
- * @returns Destination node after swap, or undefined.
12829
+ * Find the first entry that satisfies a predicate.
12830
+ * @returns The first matching `[key, value]` tuple, or `undefined`.
12831
+ * @remarks Time O(n), Space O(1)
12859
12832
  */
12860
- _swapProperties(srcNode, destNode) {
12861
- srcNode = this.ensureNode(srcNode);
12862
- destNode = this.ensureNode(destNode);
12863
- if (srcNode && destNode) {
12864
- const { key, value, count, color } = destNode;
12865
- const tempNode = this.createNode(key, value, color, count);
12866
- if (tempNode) {
12867
- tempNode.color = color;
12868
- destNode.key = srcNode.key;
12869
- if (!this._isMapMode) destNode.value = srcNode.value;
12870
- destNode.count = srcNode.count;
12871
- destNode.color = srcNode.color;
12872
- srcNode.key = tempNode.key;
12873
- if (!this._isMapMode) srcNode.value = tempNode.value;
12874
- srcNode.count = tempNode.count;
12875
- srcNode.color = tempNode.color;
12876
- }
12877
- return destNode;
12833
+ find(callbackfn, thisArg) {
12834
+ let index = 0;
12835
+ for (const [k, v] of this) {
12836
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12837
+ if (ok) return [k, v];
12878
12838
  }
12879
12839
  return void 0;
12880
12840
  }
12881
12841
  /**
12882
- * (Protected) Replace one node by another and adjust counters accordingly.
12883
- * @remarks Time O(1), Space O(1)
12884
- * @param oldNode - Node being replaced.
12885
- * @param newNode - Replacement node.
12886
- * @returns The new node after replacement.
12842
+ * Materialize the map into an array of `[key, value]` tuples.
12843
+ * @remarks Time O(n), Space O(n)
12887
12844
  */
12888
- _replaceNode(oldNode, newNode) {
12889
- newNode.count = oldNode.count + newNode.count;
12890
- return super._replaceNode(oldNode, newNode);
12845
+ toArray() {
12846
+ return [...this];
12847
+ }
12848
+ /**
12849
+ * Print a human-friendly representation.
12850
+ * @remarks Time O(n), Space O(n)
12851
+ */
12852
+ print() {
12853
+ this.#core.print();
12854
+ }
12855
+ // Navigable operations (return entry tuples)
12856
+ // Note: returned tuple values may be `undefined`.
12857
+ /**
12858
+ * Smallest entry by key.
12859
+ */
12860
+ first() {
12861
+ const k = this.#core.getLeftMost();
12862
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12863
+ }
12864
+ /**
12865
+ * Largest entry by key.
12866
+ */
12867
+ last() {
12868
+ const k = this.#core.getRightMost();
12869
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12870
+ }
12871
+ /**
12872
+ * Remove and return the smallest entry.
12873
+ */
12874
+ pollFirst() {
12875
+ const entry = this.first();
12876
+ if (!entry) return void 0;
12877
+ this.delete(entry[0]);
12878
+ return entry;
12879
+ }
12880
+ /**
12881
+ * Remove and return the largest entry.
12882
+ */
12883
+ pollLast() {
12884
+ const entry = this.last();
12885
+ if (!entry) return void 0;
12886
+ this.delete(entry[0]);
12887
+ return entry;
12888
+ }
12889
+ /**
12890
+ * Smallest entry whose key is >= the given key.
12891
+ */
12892
+ ceiling(key) {
12893
+ this._validateKey(key);
12894
+ const k = this.#core.ceiling(key);
12895
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12896
+ }
12897
+ /**
12898
+ * Largest entry whose key is <= the given key.
12899
+ */
12900
+ floor(key) {
12901
+ this._validateKey(key);
12902
+ const k = this.#core.floor(key);
12903
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12904
+ }
12905
+ /**
12906
+ * Smallest entry whose key is > the given key.
12907
+ */
12908
+ higher(key) {
12909
+ this._validateKey(key);
12910
+ const k = this.#core.higher(key);
12911
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12912
+ }
12913
+ /**
12914
+ * Largest entry whose key is < the given key.
12915
+ */
12916
+ lower(key) {
12917
+ this._validateKey(key);
12918
+ const k = this.#core.lower(key);
12919
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12920
+ }
12921
+ /**
12922
+ * Return all entries in a given key range.
12923
+ *
12924
+ * @param range `[low, high]`
12925
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12926
+ */
12927
+ rangeSearch(range, options = {}) {
12928
+ const { lowInclusive = true, highInclusive = true } = options;
12929
+ const [low, high] = range;
12930
+ this._validateKey(low);
12931
+ this._validateKey(high);
12932
+ const keys = this.#core.rangeSearch([low, high]);
12933
+ const out = [];
12934
+ const cmp = this.#core.comparator;
12935
+ for (const k of keys) {
12936
+ if (k === void 0) continue;
12937
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12938
+ if (!highInclusive && cmp(k, high) === 0) continue;
12939
+ out.push(this._entryFromKey(k));
12940
+ }
12941
+ return out;
12891
12942
  }
12892
12943
  };
12893
12944
 
12894
- // src/data-structures/binary-tree/avl-tree-counter.ts
12895
- var AVLTreeCounterNode = class {
12945
+ // src/data-structures/binary-tree/tree-multi-set.ts
12946
+ var TreeMultiSet = class _TreeMultiSet {
12896
12947
  static {
12897
- __name(this, "AVLTreeCounterNode");
12948
+ __name(this, "TreeMultiSet");
12898
12949
  }
12899
- key;
12900
- value;
12901
- parent = void 0;
12950
+ #core;
12951
+ #isDefaultComparator;
12952
+ _size = 0;
12953
+ // total occurrences (sumCounts)
12902
12954
  /**
12903
- * Create an AVL counter node.
12955
+ * Creates a new TreeMultiSet.
12956
+ * @param elements - Initial elements to add
12957
+ * @param options - Configuration options
12958
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial elements
12959
+ */
12960
+ constructor(elements = [], options = {}) {
12961
+ const comparator = options.comparator ?? TreeSet.createDefaultComparator();
12962
+ this.#isDefaultComparator = options.comparator === void 0;
12963
+ this.#core = new RedBlackTree([], { comparator, isMapMode: options.isMapMode });
12964
+ for (const k of elements) this.add(k);
12965
+ }
12966
+ /**
12967
+ * Validates the key against the default comparator rules.
12904
12968
  * @remarks Time O(1), Space O(1)
12905
- * @param key - Key of the node.
12906
- * @param [value] - Associated value (ignored in map mode).
12907
- * @param [count] - Initial count for this node (default 1).
12908
- * @returns New AVLTreeCounterNode instance.
12909
12969
  */
12910
- constructor(key, value, count = 1) {
12911
- this.key = key;
12912
- this.value = value;
12913
- this.count = count;
12970
+ _validateKey(key) {
12971
+ if (!this.#isDefaultComparator) return;
12972
+ if (typeof key === "number") {
12973
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiSet: NaN is not a valid key");
12974
+ return;
12975
+ }
12976
+ if (typeof key === "string") return;
12977
+ if (key instanceof Date) {
12978
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiSet: invalid Date key");
12979
+ return;
12980
+ }
12981
+ throw new TypeError("TreeMultiSet: comparator is required for non-number/non-string/non-Date keys");
12914
12982
  }
12915
- _left = void 0;
12916
12983
  /**
12917
- * Get the left child pointer.
12984
+ * Validates that count is a non-negative safe integer.
12918
12985
  * @remarks Time O(1), Space O(1)
12919
- * @returns Left child node, or null/undefined.
12920
12986
  */
12921
- get left() {
12922
- return this._left;
12987
+ _validateCount(n) {
12988
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError("TreeMultiSet: count must be a safe integer >= 0");
12923
12989
  }
12924
12990
  /**
12925
- * Set the left child and update its parent pointer.
12991
+ * Total occurrences (sumCounts).
12926
12992
  * @remarks Time O(1), Space O(1)
12927
- * @param v - New left child node, or null/undefined.
12928
- * @returns void
12929
12993
  */
12930
- set left(v) {
12931
- if (v) {
12932
- v.parent = this;
12933
- }
12934
- this._left = v;
12994
+ get size() {
12995
+ return this._size;
12935
12996
  }
12936
- _right = void 0;
12937
12997
  /**
12938
- * Get the right child pointer.
12998
+ * Number of distinct keys.
12939
12999
  * @remarks Time O(1), Space O(1)
12940
- * @returns Right child node, or null/undefined.
12941
13000
  */
12942
- get right() {
12943
- return this._right;
13001
+ get distinctSize() {
13002
+ return this.#core.size;
12944
13003
  }
12945
13004
  /**
12946
- * Set the right child and update its parent pointer.
13005
+ * Whether the multiset is empty.
12947
13006
  * @remarks Time O(1), Space O(1)
12948
- * @param v - New right child node, or null/undefined.
12949
- * @returns void
12950
13007
  */
12951
- set right(v) {
12952
- if (v) {
12953
- v.parent = this;
12954
- }
12955
- this._right = v;
13008
+ isEmpty() {
13009
+ return this.size === 0;
12956
13010
  }
12957
- _height = 0;
12958
13011
  /**
12959
- * Gets the height of the node (used in self-balancing trees).
12960
- * @remarks Time O(1), Space O(1)
12961
- *
12962
- * @returns The height.
13012
+ * Whether the multiset contains the given key.
13013
+ * @remarks Time O(log n), Space O(1)
12963
13014
  */
12964
- get height() {
12965
- return this._height;
13015
+ has(key) {
13016
+ this._validateKey(key);
13017
+ return this.count(key) > 0;
12966
13018
  }
12967
13019
  /**
12968
- * Sets the height of the node.
12969
- * @remarks Time O(1), Space O(1)
12970
- *
12971
- * @param value - The new height.
13020
+ * Returns the count of occurrences for the given key.
13021
+ * @remarks Time O(log n), Space O(1)
12972
13022
  */
12973
- set height(value) {
12974
- this._height = value;
13023
+ count(key) {
13024
+ this._validateKey(key);
13025
+ return this.#core.get(key) ?? 0;
12975
13026
  }
12976
- _color = "BLACK";
12977
13027
  /**
12978
- * Gets the color of the node (used in Red-Black trees).
12979
- * @remarks Time O(1), Space O(1)
12980
- *
12981
- * @returns The node's color.
13028
+ * Add `n` occurrences of `key`.
13029
+ * @returns True if the multiset changed.
13030
+ * @remarks Time O(log n), Space O(1)
12982
13031
  */
12983
- get color() {
12984
- return this._color;
13032
+ add(key, n = 1) {
13033
+ this._validateKey(key);
13034
+ this._validateCount(n);
13035
+ if (n === 0) return false;
13036
+ const old = this.#core.get(key) ?? 0;
13037
+ const next = old + n;
13038
+ this.#core.set(key, next);
13039
+ this._size += n;
13040
+ return true;
12985
13041
  }
12986
13042
  /**
12987
- * Sets the color of the node.
12988
- * @remarks Time O(1), Space O(1)
12989
- *
12990
- * @param value - The new color.
13043
+ * Set count for `key` to exactly `n`.
13044
+ * @returns True if changed.
13045
+ * @remarks Time O(log n), Space O(1)
12991
13046
  */
12992
- set color(value) {
12993
- this._color = value;
13047
+ setCount(key, n) {
13048
+ this._validateKey(key);
13049
+ this._validateCount(n);
13050
+ const old = this.#core.get(key) ?? 0;
13051
+ if (old === n) return false;
13052
+ if (n === 0) {
13053
+ if (old !== 0) this.#core.delete(key);
13054
+ } else {
13055
+ this.#core.set(key, n);
13056
+ }
13057
+ this._size += n - old;
13058
+ return true;
12994
13059
  }
12995
- _count = 1;
12996
13060
  /**
12997
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12998
- * @remarks Time O(1), Space O(1)
12999
- *
13000
- * @returns The subtree node count.
13061
+ * Delete `n` occurrences of `key` (default 1).
13062
+ * @returns True if any occurrence was removed.
13063
+ * @remarks Time O(log n), Space O(1)
13001
13064
  */
13002
- get count() {
13003
- return this._count;
13065
+ delete(key, n = 1) {
13066
+ this._validateKey(key);
13067
+ this._validateCount(n);
13068
+ if (n === 0) return false;
13069
+ const old = this.#core.get(key) ?? 0;
13070
+ if (old === 0) return false;
13071
+ const removed = Math.min(old, n);
13072
+ const next = old - removed;
13073
+ if (next === 0) this.#core.delete(key);
13074
+ else this.#core.set(key, next);
13075
+ this._size -= removed;
13076
+ return true;
13004
13077
  }
13005
13078
  /**
13006
- * Sets the count of nodes in the subtree.
13007
- * @remarks Time O(1), Space O(1)
13008
- *
13009
- * @param value - The new count.
13079
+ * Delete all occurrences of the given key.
13080
+ * @returns True if any occurrence was removed.
13081
+ * @remarks Time O(log n), Space O(1)
13010
13082
  */
13011
- set count(value) {
13012
- this._count = value;
13083
+ deleteAll(key) {
13084
+ this._validateKey(key);
13085
+ const old = this.#core.get(key) ?? 0;
13086
+ if (old === 0) return false;
13087
+ this.#core.delete(key);
13088
+ this._size -= old;
13089
+ return true;
13013
13090
  }
13014
13091
  /**
13015
- * Gets the position of the node relative to its parent.
13016
- * @remarks Time O(1), Space O(1)
13017
- *
13018
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
13092
+ * Iterates over distinct keys (each key yielded once).
13093
+ * @remarks Time O(n), Space O(1)
13019
13094
  */
13020
- get familyPosition() {
13021
- if (!this.parent) {
13022
- return this.left || this.right ? "ROOT" : "ISOLATED";
13095
+ *keysDistinct() {
13096
+ yield* this.#core.keys();
13097
+ }
13098
+ /**
13099
+ * Iterates over entries as [key, count] pairs.
13100
+ * @remarks Time O(n), Space O(1)
13101
+ */
13102
+ *entries() {
13103
+ for (const [k, v] of this.#core) {
13104
+ yield [k, v ?? 0];
13023
13105
  }
13024
- if (this.parent.left === this) {
13025
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
13026
- } else if (this.parent.right === this) {
13027
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
13106
+ }
13107
+ /**
13108
+ * Expanded iteration (default). Each key is yielded `count(key)` times.
13109
+ * @remarks Time O(size), Space O(1) where size is total occurrences
13110
+ */
13111
+ *[Symbol.iterator]() {
13112
+ for (const [k, c] of this.entries()) {
13113
+ for (let i = 0; i < c; i++) yield k;
13028
13114
  }
13029
- return "MAL_NODE";
13030
13115
  }
13031
- };
13032
- var AVLTreeCounter = class extends AVLTree {
13033
- static {
13034
- __name(this, "AVLTreeCounter");
13116
+ /**
13117
+ * Returns an array with all elements (expanded).
13118
+ * @remarks Time O(size), Space O(size)
13119
+ */
13120
+ toArray() {
13121
+ return [...this];
13035
13122
  }
13036
13123
  /**
13037
- * Create a AVLTreeCounter instance
13124
+ * Returns an array with distinct keys only.
13038
13125
  * @remarks Time O(n), Space O(n)
13039
- * @param keysNodesEntriesOrRaws
13040
- * @param options
13041
- * @returns New AVLTreeCounterNode instance.
13042
13126
  */
13043
- constructor(keysNodesEntriesOrRaws = [], options) {
13044
- super([], options);
13045
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
13046
- }
13047
- _count = 0;
13048
- get count() {
13049
- return this._count;
13127
+ toDistinctArray() {
13128
+ return [...this.keysDistinct()];
13050
13129
  }
13051
13130
  /**
13052
- * Compute the total count by traversing the tree (sums node.count).
13053
- * @remarks Time O(N), Space O(H)
13054
- * @returns Total count recomputed from nodes.
13131
+ * Returns an array of [key, count] entries.
13132
+ * @remarks Time O(n), Space O(n)
13055
13133
  */
13056
- getComputedCount() {
13057
- let sum = 0;
13058
- this.dfs((node) => sum += node.count);
13059
- return sum;
13134
+ toEntries() {
13135
+ return [...this.entries()];
13060
13136
  }
13061
- createNode(key, value, count) {
13062
- return new AVLTreeCounterNode(key, this._isMapMode ? void 0 : value, count);
13137
+ /**
13138
+ * Expose comparator for advanced usage/testing (read-only).
13139
+ * @remarks Time O(1), Space O(1)
13140
+ */
13141
+ get comparator() {
13142
+ return this.#core._comparator;
13063
13143
  }
13144
+ // ━━━ clear ━━━
13064
13145
  /**
13065
- * Type guard: check whether the input is an AVLTreeCounterNode.
13146
+ * Remove all elements from the multiset.
13066
13147
  * @remarks Time O(1), Space O(1)
13067
- * @returns True if the value is an AVLTreeCounterNode.
13148
+ * @example
13149
+ * const ms = new TreeMultiSet([1, 2, 2, 3]);
13150
+ * ms.clear();
13151
+ * ms.size; // 0
13068
13152
  */
13069
- isNode(keyNodeOrEntry) {
13070
- return keyNodeOrEntry instanceof AVLTreeCounterNode;
13153
+ clear() {
13154
+ this.#core.clear();
13155
+ this._size = 0;
13071
13156
  }
13157
+ // ━━━ Navigable methods ━━━
13072
13158
  /**
13073
- * Insert or increment a node and update aggregate count.
13074
- * @remarks Time O(log N), Space O(1)
13075
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
13076
- * @param [value] - Value when a bare key is provided (ignored in map mode).
13077
- * @param [count] - How much to increase the node's count (default 1).
13078
- * @returns True if inserted/updated; false if ignored.
13159
+ * Returns the smallest key, or undefined if empty.
13160
+ * @remarks Time O(log n), Space O(1)
13161
+ * @example
13162
+ * const ms = new TreeMultiSet([3, 1, 4]);
13163
+ * ms.first(); // 1
13079
13164
  */
13080
- set(keyNodeOrEntry, value, count = 1) {
13081
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
13082
- if (newNode === void 0) return false;
13083
- const orgNodeCount = newNode?.count || 0;
13084
- const inserted = super.set(newNode, newValue);
13085
- if (inserted) {
13086
- this._count += orgNodeCount;
13087
- }
13088
- return true;
13165
+ first() {
13166
+ return this.#core.getLeftMost();
13089
13167
  }
13090
13168
  /**
13091
- * Delete a node (or decrement its count) and rebalance if needed.
13092
- * @remarks Time O(log N), Space O(1)
13093
- * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
13094
- * @param [ignoreCount] - If true, remove the node regardless of its count.
13095
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
13169
+ * Returns the largest key, or undefined if empty.
13170
+ * @remarks Time O(log n), Space O(1)
13171
+ * @example
13172
+ * const ms = new TreeMultiSet([3, 1, 4]);
13173
+ * ms.last(); // 4
13096
13174
  */
13097
- delete(keyNodeOrEntry, ignoreCount = false) {
13098
- const deletedResult = [];
13099
- if (!this.root) return deletedResult;
13100
- const curr = this.getNode(keyNodeOrEntry) ?? void 0;
13101
- if (!curr) return deletedResult;
13102
- const parent = curr?.parent ? curr.parent : void 0;
13103
- let needBalanced = void 0, orgCurrent = curr;
13104
- if (curr.count > 1 && !ignoreCount) {
13105
- curr.count--;
13106
- this._count--;
13107
- } else {
13108
- if (!curr.left) {
13109
- if (!parent) {
13110
- if (curr.right !== void 0 && curr.right !== null) this._setRoot(curr.right);
13111
- } else {
13112
- const { familyPosition: fp } = curr;
13113
- if (fp === "LEFT" || fp === "ROOT_LEFT") {
13114
- parent.left = curr.right;
13115
- } else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
13116
- parent.right = curr.right;
13117
- }
13118
- needBalanced = parent;
13119
- }
13120
- } else {
13121
- const leftSubTreeRightMost = curr.left ? this.getRightMost((node) => node, curr.left) : void 0;
13122
- if (leftSubTreeRightMost) {
13123
- const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
13124
- orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
13125
- if (parentOfLeftSubTreeMax) {
13126
- if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
13127
- parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
13128
- } else {
13129
- parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
13130
- }
13131
- needBalanced = parentOfLeftSubTreeMax;
13132
- }
13133
- }
13134
- }
13135
- this._size = this._size - 1;
13136
- if (orgCurrent) this._count -= orgCurrent.count;
13137
- }
13138
- deletedResult.push({ deleted: orgCurrent, needBalanced });
13139
- if (needBalanced) {
13140
- this._balancePath(needBalanced);
13141
- }
13142
- return deletedResult;
13175
+ last() {
13176
+ return this.#core.getRightMost();
13143
13177
  }
13144
13178
  /**
13145
- * Remove all nodes and reset aggregate counters.
13146
- * @remarks Time O(N), Space O(1)
13147
- * @returns void
13179
+ * Removes all occurrences of the smallest key and returns it.
13180
+ * @remarks Time O(log n), Space O(1)
13181
+ * @example
13182
+ * const ms = new TreeMultiSet([1, 1, 2, 3]);
13183
+ * ms.pollFirst(); // 1
13184
+ * ms.has(1); // false
13148
13185
  */
13149
- clear() {
13150
- super.clear();
13151
- this._count = 0;
13186
+ pollFirst() {
13187
+ const key = this.first();
13188
+ if (key === void 0) return void 0;
13189
+ this.deleteAll(key);
13190
+ return key;
13152
13191
  }
13153
13192
  /**
13154
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
13155
- * @remarks Time O(N), Space O(N)
13156
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
13157
- * @returns True if rebalancing succeeded (tree not empty).
13193
+ * Removes all occurrences of the largest key and returns it.
13194
+ * @remarks Time O(log n), Space O(1)
13195
+ * @example
13196
+ * const ms = new TreeMultiSet([1, 2, 3, 3]);
13197
+ * ms.pollLast(); // 3
13198
+ * ms.has(3); // false
13158
13199
  */
13159
- perfectlyBalance(iterationType = this.iterationType) {
13160
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
13161
- const n = nodes.length;
13162
- if (n === 0) return false;
13163
- let total = 0;
13164
- for (const nd of nodes) total += nd ? nd.count : 0;
13165
- this._clearNodes();
13166
- const build = /* @__PURE__ */ __name((l, r, parent) => {
13167
- if (l > r) return void 0;
13168
- const m = l + (r - l >> 1);
13169
- const root = nodes[m];
13170
- root.left = build(l, m - 1, root);
13171
- root.right = build(m + 1, r, root);
13172
- root.parent = parent;
13173
- const lh = root.left ? root.left.height : -1;
13174
- const rh = root.right ? root.right.height : -1;
13175
- root.height = Math.max(lh, rh) + 1;
13176
- return root;
13177
- }, "build");
13178
- const newRoot = build(0, n - 1, void 0);
13179
- this._setRoot(newRoot);
13180
- this._size = n;
13181
- this._count = total;
13182
- return true;
13200
+ pollLast() {
13201
+ const key = this.last();
13202
+ if (key === void 0) return void 0;
13203
+ this.deleteAll(key);
13204
+ return key;
13183
13205
  }
13184
13206
  /**
13185
- * Deep copy this tree, preserving map mode and aggregate counts.
13186
- * @remarks Time O(N), Space O(N)
13187
- * @returns A deep copy of this tree.
13207
+ * Returns the smallest key >= given key, or undefined.
13208
+ * @remarks Time O(log n), Space O(1)
13209
+ * @example
13210
+ * const ms = new TreeMultiSet([10, 20, 30]);
13211
+ * ms.ceiling(15); // 20
13212
+ * ms.ceiling(20); // 20
13188
13213
  */
13189
- clone() {
13190
- const out = this._createInstance();
13191
- if (this._isMapMode) {
13192
- this.bfs((node) => out.set(node.key, void 0, node.count));
13193
- } else {
13194
- this.bfs((node) => out.set(node.key, node.value, node.count));
13195
- }
13196
- if (this._isMapMode) out._store = this._store;
13197
- return out;
13214
+ ceiling(key) {
13215
+ this._validateKey(key);
13216
+ return this.#core.ceiling(key);
13198
13217
  }
13199
13218
  /**
13200
- * Create a new AVLTreeCounter by mapping each [key, value] entry.
13201
- * @remarks Time O(N log N), Space O(N)
13202
- * @template MK
13203
- * @template MV
13204
- * @template MR
13205
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
13206
- * @param [options] - Options for the output tree.
13207
- * @param [thisArg] - Value for `this` inside the callback.
13208
- * @returns A new AVLTreeCounter with mapped entries.
13219
+ * Returns the largest key <= given key, or undefined.
13220
+ * @remarks Time O(log n), Space O(1)
13221
+ * @example
13222
+ * const ms = new TreeMultiSet([10, 20, 30]);
13223
+ * ms.floor(25); // 20
13224
+ * ms.floor(20); // 20
13209
13225
  */
13210
- map(callback, options, thisArg) {
13211
- const out = this._createLike([], options);
13212
- let index = 0;
13213
- for (const [key, value] of this) {
13214
- out.set(callback.call(thisArg, value, key, index++, this));
13215
- }
13216
- return out;
13226
+ floor(key) {
13227
+ this._validateKey(key);
13228
+ return this.#core.floor(key);
13217
13229
  }
13218
13230
  /**
13219
- * (Protected) Create an empty instance of the same concrete class.
13220
- * @remarks Time O(1), Space O(1)
13221
- * @template TK
13222
- * @template TV
13223
- * @template TR
13224
- * @param [options] - Optional constructor options for the like-kind instance.
13225
- * @returns An empty like-kind instance.
13231
+ * Returns the smallest key > given key, or undefined.
13232
+ * @remarks Time O(log n), Space O(1)
13233
+ * @example
13234
+ * const ms = new TreeMultiSet([10, 20, 30]);
13235
+ * ms.higher(10); // 20
13236
+ * ms.higher(15); // 20
13226
13237
  */
13227
- _createInstance(options) {
13228
- const Ctor = this.constructor;
13229
- return new Ctor([], { ...this._snapshotOptions(), ...options ?? {} });
13238
+ higher(key) {
13239
+ this._validateKey(key);
13240
+ return this.#core.higher(key);
13230
13241
  }
13231
13242
  /**
13232
- * (Protected) Create a like-kind instance and seed it from an iterable.
13233
- * @remarks Time O(N log N), Space O(N)
13234
- * @template TK
13235
- * @template TV
13236
- * @template TR
13237
- * @param iter - Iterable used to seed the new tree.
13238
- * @param [options] - Options merged with the current snapshot.
13239
- * @returns A like-kind AVLTreeCounter built from the iterable.
13243
+ * Returns the largest key < given key, or undefined.
13244
+ * @remarks Time O(log n), Space O(1)
13245
+ * @example
13246
+ * const ms = new TreeMultiSet([10, 20, 30]);
13247
+ * ms.lower(20); // 10
13248
+ * ms.lower(15); // 10
13240
13249
  */
13241
- _createLike(iter = [], options) {
13242
- const Ctor = this.constructor;
13243
- return new Ctor(iter, { ...this._snapshotOptions(), ...options ?? {} });
13250
+ lower(key) {
13251
+ this._validateKey(key);
13252
+ return this.#core.lower(key);
13244
13253
  }
13254
+ // ━━━ Functional methods ━━━
13245
13255
  /**
13246
- * (Protected) Normalize input into a node plus its effective value and count.
13247
- * @remarks Time O(1), Space O(1)
13248
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
13249
- * @param [value] - Value used when a bare key is provided.
13250
- * @param [count] - Count increment to apply (default 1).
13251
- * @returns Tuple [node, value] where node may be undefined.
13256
+ * Iterates over distinct keys with their counts.
13257
+ * @remarks Time O(n), Space O(1)
13258
+ * @example
13259
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13260
+ * ms.forEach((key, count) => console.log(`${key}: ${count}`));
13261
+ * // 1: 2, 2: 1, 3: 3
13252
13262
  */
13253
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
13254
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
13255
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
13256
- if (this.isEntry(keyNodeOrEntry)) {
13257
- const [key, entryValue] = keyNodeOrEntry;
13258
- if (key === void 0 || key === null) return [void 0, void 0];
13259
- const finalValue = value ?? entryValue;
13260
- return [this.createNode(key, finalValue, count), finalValue];
13263
+ forEach(callback) {
13264
+ for (const [k, c] of this.entries()) {
13265
+ callback(k, c);
13261
13266
  }
13262
- return [this.createNode(keyNodeOrEntry, value, count), value];
13263
13267
  }
13264
13268
  /**
13265
- * (Protected) Swap keys/values/counters between the source and destination nodes.
13266
- * @remarks Time O(1), Space O(1)
13267
- * @param srcNode - Source node (or key) whose properties will be moved.
13268
- * @param destNode - Destination node (or key) to receive properties.
13269
- * @returns Destination node after swap, or undefined.
13269
+ * Creates a new TreeMultiSet with entries that match the predicate.
13270
+ * @remarks Time O(n log n), Space O(n)
13271
+ * @example
13272
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13273
+ * const filtered = ms.filter((key, count) => count >= 2);
13274
+ * // TreeMultiSet { 1: 2, 3: 3 }
13270
13275
  */
13271
- _swapProperties(srcNode, destNode) {
13272
- srcNode = this.ensureNode(srcNode);
13273
- destNode = this.ensureNode(destNode);
13274
- if (srcNode && destNode) {
13275
- const { key, value, count, height } = destNode;
13276
- const tempNode = this.createNode(key, value, count);
13277
- if (tempNode) {
13278
- tempNode.height = height;
13279
- destNode.key = srcNode.key;
13280
- if (!this._isMapMode) destNode.value = srcNode.value;
13281
- destNode.count = srcNode.count;
13282
- destNode.height = srcNode.height;
13283
- srcNode.key = tempNode.key;
13284
- if (!this._isMapMode) srcNode.value = tempNode.value;
13285
- srcNode.count = tempNode.count;
13286
- srcNode.height = tempNode.height;
13276
+ filter(predicate) {
13277
+ const result = new _TreeMultiSet([], {
13278
+ comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13279
+ isMapMode: this.#core._isMapMode
13280
+ });
13281
+ for (const [k, c] of this.entries()) {
13282
+ if (predicate(k, c)) {
13283
+ result.add(k, c);
13287
13284
  }
13288
- return destNode;
13289
13285
  }
13290
- return void 0;
13286
+ return result;
13291
13287
  }
13292
13288
  /**
13293
- * (Protected) Replace one node by another and adjust counters accordingly.
13294
- * @remarks Time O(1), Space O(1)
13295
- * @param oldNode - Node being replaced.
13296
- * @param newNode - Replacement node.
13297
- * @returns The new node after replacement.
13289
+ * Reduces the multiset to a single value.
13290
+ * @remarks Time O(n), Space O(1)
13291
+ * @example
13292
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13293
+ * const total = ms.reduce((acc, key, count) => acc + count, 0); // 6
13298
13294
  */
13299
- _replaceNode(oldNode, newNode) {
13300
- newNode.count = oldNode.count + newNode.count;
13301
- return super._replaceNode(oldNode, newNode);
13295
+ reduce(callback, initialValue) {
13296
+ let acc = initialValue;
13297
+ for (const [k, c] of this.entries()) {
13298
+ acc = callback(acc, k, c);
13299
+ }
13300
+ return acc;
13301
+ }
13302
+ /**
13303
+ * Maps keys and counts to a new TreeMultiSet.
13304
+ * When multiple keys map to the same new key, counts are merged (added).
13305
+ * @remarks Time O(n log n), Space O(n)
13306
+ * @example
13307
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13308
+ * const mapped = ms.map((key, count) => [key * 10, count]);
13309
+ * // TreeMultiSet { 10: 2, 20: 1, 30: 3 }
13310
+ * @example
13311
+ * // Collision: counts merge
13312
+ * const ms = new TreeMultiSet([1, 2, 3]);
13313
+ * const merged = ms.map((key, count) => [key % 2, count]);
13314
+ * // { 0: 1, 1: 2 } (1 and 3 both map to 1, counts add)
13315
+ */
13316
+ map(mapper, options) {
13317
+ const result = new _TreeMultiSet([], {
13318
+ comparator: options?.comparator,
13319
+ isMapMode: this.#core._isMapMode
13320
+ });
13321
+ for (const [k, c] of this.entries()) {
13322
+ const [newKey, newCount] = mapper(k, c);
13323
+ result.add(newKey, newCount);
13324
+ }
13325
+ return result;
13326
+ }
13327
+ /**
13328
+ * Creates an independent copy of this multiset.
13329
+ * @remarks Time O(n log n), Space O(n)
13330
+ * @example
13331
+ * const ms = new TreeMultiSet([1, 1, 2]);
13332
+ * const copy = ms.clone();
13333
+ * copy.add(3);
13334
+ * ms.has(3); // false (original unchanged)
13335
+ */
13336
+ clone() {
13337
+ const result = new _TreeMultiSet([], {
13338
+ comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13339
+ isMapMode: this.#core._isMapMode
13340
+ });
13341
+ for (const [k, c] of this.entries()) {
13342
+ result.add(k, c);
13343
+ }
13344
+ return result;
13345
+ }
13346
+ // ━━━ Tree utilities ━━━
13347
+ /**
13348
+ * Returns keys within the given range.
13349
+ * @remarks Time O(log n + k), Space O(k) where k is result size
13350
+ * @example
13351
+ * const ms = new TreeMultiSet([10, 20, 30, 40, 50]);
13352
+ * ms.rangeSearch([15, 45]); // [20, 30, 40]
13353
+ */
13354
+ rangeSearch(range, callback) {
13355
+ const cb = callback ?? ((k) => k);
13356
+ return this.#core.rangeSearch(range, (node) => cb(node.key));
13357
+ }
13358
+ /**
13359
+ * Prints the internal tree structure (for debugging).
13360
+ * @remarks Time O(n), Space O(n)
13361
+ * @example
13362
+ * const ms = new TreeMultiSet([1, 2, 3]);
13363
+ * ms.print();
13364
+ */
13365
+ print() {
13366
+ this.#core.print();
13302
13367
  }
13303
13368
  };
13304
13369
 
@@ -14514,6 +14579,13 @@ var TreeNode = class _TreeNode {
14514
14579
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
14515
14580
  * @license MIT License
14516
14581
  */
14582
+ /**
14583
+ * data-structure-typed
14584
+ *
14585
+ * @author Pablo Zeng
14586
+ * @copyright Copyright (c) 2022 Pablo Zeng
14587
+ * @license MIT License
14588
+ */
14517
14589
  /**
14518
14590
  * data-structure-typed
14519
14591
  *
@@ -14522,6 +14594,6 @@ var TreeNode = class _TreeNode {
14522
14594
  * @license MIT License
14523
14595
  */
14524
14596
 
14525
- export { AVLTree, AVLTreeCounter, AVLTreeCounterNode, AVLTreeMultiMap, AVLTreeMultiMapNode, AVLTreeNode, AbstractEdge, AbstractGraph, AbstractVertex, BST, BSTNode, BinaryIndexedTree, BinaryTree, BinaryTreeNode, Character, DFSOperation, Deque, DirectedEdge, DirectedGraph, DirectedVertex, DoublyLinkedList, DoublyLinkedListNode, FibonacciHeap, FibonacciHeapNode, HashMap, Heap, IterableElementBase, IterableEntryBase, LinkedHashMap, LinkedListQueue, MapEdge, MapGraph, MapVertex, Matrix, MaxHeap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Navigator, PriorityQueue, Queue, Range, RedBlackTree, RedBlackTreeNode, SegmentTree, SegmentTreeNode, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, Stack, TreeCounter, TreeCounterNode, TreeMultiMap, TreeMultiMapNode, TreeNode, Trie, TrieNode, UndirectedEdge, UndirectedGraph, UndirectedVertex, arrayRemove, asyncTrampoline, calcMinUnitsRequired, getMSB, isComparable, isTrampolineThunk, isWeakKey, makeAsyncTrampoline, makeTrampoline, makeTrampolineThunk, rangeCheck, roundFixed, throwRangeError, toBinaryString, trampoline, uuidV4 };
14597
+ export { AVLTree, AVLTreeNode, AbstractEdge, AbstractGraph, AbstractVertex, BST, BSTNode, BinaryIndexedTree, BinaryTree, BinaryTreeNode, Character, DFSOperation, Deque, DirectedEdge, DirectedGraph, DirectedVertex, DoublyLinkedList, DoublyLinkedListNode, FibonacciHeap, FibonacciHeapNode, HashMap, Heap, IterableElementBase, IterableEntryBase, LinkedHashMap, LinkedListQueue, MapEdge, MapGraph, MapVertex, Matrix, MaxHeap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Navigator, PriorityQueue, Queue, Range, RedBlackTree, RedBlackTreeNode, SegmentTree, SegmentTreeNode, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, Stack, TreeMap, TreeMultiMap, TreeMultiMapNode, TreeMultiSet, TreeNode, TreeSet, Trie, TrieNode, UndirectedEdge, UndirectedGraph, UndirectedVertex, arrayRemove, asyncTrampoline, calcMinUnitsRequired, getMSB, isComparable, isTrampolineThunk, isWeakKey, makeAsyncTrampoline, makeTrampoline, makeTrampolineThunk, rangeCheck, roundFixed, throwRangeError, toBinaryString, trampoline, uuidV4 };
14526
14598
  //# sourceMappingURL=index.mjs.map
14527
14599
  //# sourceMappingURL=index.mjs.map