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
@@ -1,9 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
+ var __typeError = (msg) => {
5
+ throw TypeError(msg);
6
+ };
4
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
9
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
11
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
12
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
7
14
 
8
15
  // src/data-structures/base/iterable-entry-base.ts
9
16
  var _IterableEntryBase = class _IterableEntryBase {
@@ -6995,6 +7002,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
6995
7002
  __publicField(this, "iterationType", "ITERATIVE");
6996
7003
  __publicField(this, "_isMapMode", true);
6997
7004
  __publicField(this, "_isDuplicate", false);
7005
+ // Map mode acceleration store:
7006
+ // - isMapMode=false: unused
7007
+ // - isMapMode=true: key -> node reference (O(1) has/getNode + fast get)
6998
7008
  __publicField(this, "_store", /* @__PURE__ */ new Map());
6999
7009
  __publicField(this, "_root");
7000
7010
  __publicField(this, "_size", 0);
@@ -7090,7 +7100,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7090
7100
  * @returns The newly created node.
7091
7101
  */
7092
7102
  createNode(key, value) {
7093
- return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
7103
+ return new BinaryTreeNode(key, value);
7094
7104
  }
7095
7105
  /**
7096
7106
  * Creates a new, empty tree of the same type and configuration.
@@ -7237,11 +7247,11 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7237
7247
  * @returns True if the addition was successful, false otherwise.
7238
7248
  */
7239
7249
  set(keyNodeOrEntry, value) {
7240
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7250
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7241
7251
  if (newNode === void 0) return false;
7242
7252
  if (!this._root) {
7243
7253
  this._setRoot(newNode);
7244
- if (this._isMapMode) this._setValue(newNode == null ? void 0 : newNode.key, newValue);
7254
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7245
7255
  this._size = 1;
7246
7256
  return true;
7247
7257
  }
@@ -7253,7 +7263,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7253
7263
  if (!this._isDuplicate) {
7254
7264
  if (newNode !== null && cur.key === newNode.key) {
7255
7265
  this._replaceNode(cur, newNode);
7256
- if (this._isMapMode) this._setValue(cur.key, newValue);
7266
+ if (this._isMapMode && newNode !== null) this._store.set(cur.key, newNode);
7257
7267
  return true;
7258
7268
  }
7259
7269
  }
@@ -7273,7 +7283,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7273
7283
  } else if (potentialParent.right === void 0) {
7274
7284
  potentialParent.right = newNode;
7275
7285
  }
7276
- if (this._isMapMode) this._setValue(newNode == null ? void 0 : newNode.key, newValue);
7286
+ if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7277
7287
  this._size++;
7278
7288
  return true;
7279
7289
  }
@@ -7358,6 +7368,10 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7358
7368
  if (leftSubTreeRightMost) {
7359
7369
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
7360
7370
  orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
7371
+ if (this._isMapMode) {
7372
+ this._store.set(curr.key, curr);
7373
+ this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
7374
+ }
7361
7375
  if (parentOfLeftSubTreeMax) {
7362
7376
  if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
7363
7377
  parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
@@ -7441,6 +7455,13 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7441
7455
  * @returns The first matching node, or undefined if not found.
7442
7456
  */
7443
7457
  getNode(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7458
+ if (this._isMapMode && keyNodeEntryOrPredicate !== null && keyNodeEntryOrPredicate !== void 0) {
7459
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7460
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7461
+ if (key === null || key === void 0) return;
7462
+ return this._store.get(key);
7463
+ }
7464
+ }
7444
7465
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType)[0];
7445
7466
  }
7446
7467
  /**
@@ -7453,15 +7474,22 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7453
7474
  * @returns The associated value, or undefined.
7454
7475
  */
7455
7476
  get(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7456
- var _a;
7477
+ var _a, _b;
7457
7478
  if (this._isMapMode) {
7458
7479
  const key = this._extractKey(keyNodeEntryOrPredicate);
7459
7480
  if (key === null || key === void 0) return;
7460
- return this._store.get(key);
7481
+ return (_a = this._store.get(key)) == null ? void 0 : _a.value;
7461
7482
  }
7462
- return (_a = this.getNode(keyNodeEntryOrPredicate, startNode, iterationType)) == null ? void 0 : _a.value;
7483
+ return (_b = this.getNode(keyNodeEntryOrPredicate, startNode, iterationType)) == null ? void 0 : _b.value;
7463
7484
  }
7464
7485
  has(keyNodeEntryOrPredicate, startNode = this._root, iterationType = this.iterationType) {
7486
+ if (this._isMapMode && keyNodeEntryOrPredicate !== void 0 && keyNodeEntryOrPredicate !== null) {
7487
+ if (!this._isPredicate(keyNodeEntryOrPredicate)) {
7488
+ const key = this._extractKey(keyNodeEntryOrPredicate);
7489
+ if (key === null || key === void 0) return false;
7490
+ return this._store.has(key);
7491
+ }
7492
+ }
7465
7493
  return this.search(keyNodeEntryOrPredicate, true, (node) => node, startNode, iterationType).length > 0;
7466
7494
  }
7467
7495
  /**
@@ -8206,8 +8234,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8206
8234
  }
8207
8235
  current = stack.pop();
8208
8236
  if (this.isRealNode(current)) {
8209
- if (this._isMapMode) yield [current.key, this._store.get(current.key)];
8210
- else yield [current.key, current.value];
8237
+ yield [current.key, current.value];
8211
8238
  current = current.right;
8212
8239
  }
8213
8240
  }
@@ -8215,8 +8242,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8215
8242
  if (node.left && this.isRealNode(node)) {
8216
8243
  yield* this[Symbol.iterator](node.left);
8217
8244
  }
8218
- if (this._isMapMode) yield [node.key, this._store.get(node.key)];
8219
- else yield [node.key, node.value];
8245
+ yield [node.key, node.value];
8220
8246
  if (node.right && this.isRealNode(node)) {
8221
8247
  yield* this[Symbol.iterator](node.right);
8222
8248
  }
@@ -8294,8 +8320,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8294
8320
  (node) => {
8295
8321
  if (node === null) cloned.set(null);
8296
8322
  else {
8297
- if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
8298
- else cloned.set([node.key, node.value]);
8323
+ cloned.set([node.key, node.value]);
8299
8324
  }
8300
8325
  },
8301
8326
  this._root,
@@ -8303,7 +8328,6 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8303
8328
  true
8304
8329
  // Include nulls
8305
8330
  );
8306
- if (this._isMapMode) cloned._store = this._store;
8307
8331
  }
8308
8332
  /**
8309
8333
  * (Protected) Recursive helper for `toVisual`.
@@ -8466,8 +8490,10 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8466
8490
  */
8467
8491
  _setValue(key, value) {
8468
8492
  if (key === null || key === void 0) return false;
8469
- if (value === void 0) return false;
8470
- return this._store.set(key, value);
8493
+ const node = this._store.get(key);
8494
+ if (!node) return false;
8495
+ node.value = value;
8496
+ return true;
8471
8497
  }
8472
8498
  /**
8473
8499
  * (Protected) Clears all nodes from the tree.
@@ -8676,7 +8702,7 @@ var _BST = class _BST extends BinaryTree {
8676
8702
  * @returns The newly created BSTNode.
8677
8703
  */
8678
8704
  createNode(key, value) {
8679
- return new BSTNode(key, this._isMapMode ? void 0 : value);
8705
+ return new BSTNode(key, value);
8680
8706
  }
8681
8707
  /**
8682
8708
  * Ensures the input is a node. If it's a key or entry, it searches for the node.
@@ -8917,11 +8943,11 @@ var _BST = class _BST extends BinaryTree {
8917
8943
  * @returns True if the addition was successful, false otherwise.
8918
8944
  */
8919
8945
  set(keyNodeOrEntry, value) {
8920
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8946
+ const [newNode] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8921
8947
  if (newNode === void 0) return false;
8922
8948
  if (this._root === void 0) {
8923
8949
  this._setRoot(newNode);
8924
- if (this._isMapMode) this._setValue(newNode == null ? void 0 : newNode.key, newValue);
8950
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8925
8951
  this._size++;
8926
8952
  return true;
8927
8953
  }
@@ -8929,12 +8955,12 @@ var _BST = class _BST extends BinaryTree {
8929
8955
  while (current !== void 0) {
8930
8956
  if (this._compare(current.key, newNode.key) === 0) {
8931
8957
  this._replaceNode(current, newNode);
8932
- if (this._isMapMode) this._setValue(current.key, newValue);
8958
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(current.key, newNode);
8933
8959
  return true;
8934
8960
  } else if (this._compare(current.key, newNode.key) > 0) {
8935
8961
  if (current.left === void 0) {
8936
8962
  current.left = newNode;
8937
- if (this._isMapMode) this._setValue(newNode == null ? void 0 : newNode.key, newValue);
8963
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8938
8964
  this._size++;
8939
8965
  return true;
8940
8966
  }
@@ -8942,7 +8968,7 @@ var _BST = class _BST extends BinaryTree {
8942
8968
  } else {
8943
8969
  if (current.right === void 0) {
8944
8970
  current.right = newNode;
8945
- if (this._isMapMode) this._setValue(newNode == null ? void 0 : newNode.key, newValue);
8971
+ if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
8946
8972
  this._size++;
8947
8973
  return true;
8948
8974
  }
@@ -10497,7 +10523,7 @@ var _AVLTree = class _AVLTree extends BST {
10497
10523
  * @returns The newly created AVLTreeNode.
10498
10524
  */
10499
10525
  createNode(key, value) {
10500
- return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
10526
+ return new AVLTreeNode(key, value);
10501
10527
  }
10502
10528
  /**
10503
10529
  * Checks if the given item is an `AVLTreeNode` instance.
@@ -11051,7 +11077,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11051
11077
  * @returns A new RedBlackTreeNode instance.
11052
11078
  */
11053
11079
  createNode(key, value, color = "BLACK") {
11054
- return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
11080
+ return new RedBlackTreeNode(key, value, color);
11055
11081
  }
11056
11082
  /**
11057
11083
  * Type guard: check whether the input is a RedBlackTreeNode.
@@ -11202,20 +11228,15 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11202
11228
  if (minN !== NIL) {
11203
11229
  const cMin = comparator(key, minN.key);
11204
11230
  if (cMin === 0) {
11205
- if (this._isMapMode) {
11206
- if (nextValue !== void 0) this._store.set(key, nextValue);
11207
- else this._setValue(key, nextValue);
11208
- } else minN.value = nextValue;
11231
+ minN.value = nextValue;
11232
+ if (this._isMapMode) this._store.set(key, minN);
11209
11233
  return { node: minN, created: false };
11210
11234
  }
11211
11235
  const minL = minN.left;
11212
11236
  if (cMin < 0 && (minL === NIL || minL === null || minL === void 0)) {
11213
11237
  const newNode2 = this.createNode(key, nextValue);
11214
11238
  this._attachNewNode(minN, "left", newNode2);
11215
- if (this._isMapMode) {
11216
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11217
- else this._setValue(newNode2.key, nextValue);
11218
- }
11239
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11219
11240
  this._size++;
11220
11241
  this._setMinCache(newNode2);
11221
11242
  if (header._right === NIL) this._setMaxCache(newNode2);
@@ -11225,20 +11246,15 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11225
11246
  const maxN = (_b = header._right) != null ? _b : NIL;
11226
11247
  const cMax = comparator(key, maxN.key);
11227
11248
  if (cMax === 0) {
11228
- if (this._isMapMode) {
11229
- if (nextValue !== void 0) this._store.set(key, nextValue);
11230
- else this._setValue(key, nextValue);
11231
- } else maxN.value = nextValue;
11249
+ maxN.value = nextValue;
11250
+ if (this._isMapMode) this._store.set(key, maxN);
11232
11251
  return { node: maxN, created: false };
11233
11252
  }
11234
11253
  const maxR = maxN.right;
11235
11254
  if (cMax > 0 && (maxR === NIL || maxR === null || maxR === void 0)) {
11236
11255
  const newNode2 = this.createNode(key, nextValue);
11237
11256
  this._attachNewNode(maxN, "right", newNode2);
11238
- if (this._isMapMode) {
11239
- if (nextValue !== void 0) this._store.set(newNode2.key, nextValue);
11240
- else this._setValue(newNode2.key, nextValue);
11241
- }
11257
+ if (this._isMapMode) this._store.set(newNode2.key, newNode2);
11242
11258
  this._size++;
11243
11259
  this._setMaxCache(newNode2);
11244
11260
  if (header._left === NIL) this._setMinCache(newNode2);
@@ -11258,12 +11274,8 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11258
11274
  if (lastCompared < 0) current = (_d = current.left) != null ? _d : NIL;
11259
11275
  else if (lastCompared > 0) current = (_e = current.right) != null ? _e : NIL;
11260
11276
  else {
11261
- if (isMapMode) {
11262
- if (nextValue !== void 0) store.set(key, nextValue);
11263
- else this._setValue(key, nextValue);
11264
- } else {
11265
- current.value = nextValue;
11266
- }
11277
+ current.value = nextValue;
11278
+ if (isMapMode) store.set(key, current);
11267
11279
  return { node: current, created: false };
11268
11280
  }
11269
11281
  }
@@ -11282,10 +11294,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11282
11294
  this._insertFixup(newNode);
11283
11295
  if (this.isRealNode(this._root)) this._root.color = "BLACK";
11284
11296
  else return void 0;
11285
- if (isMapMode) {
11286
- if (nextValue !== void 0) store.set(newNode.key, nextValue);
11287
- else this._setValue(newNode.key, nextValue);
11288
- }
11297
+ if (isMapMode) store.set(newNode.key, newNode);
11289
11298
  this._size++;
11290
11299
  const hMin = (_f = this._header._left) != null ? _f : NIL;
11291
11300
  const hMax = (_g = this._header._right) != null ? _g : NIL;
@@ -11313,10 +11322,11 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11313
11322
  * @remarks Time O(log n) average, Space O(1)
11314
11323
  */
11315
11324
  _setKV(key, nextValue) {
11316
- if (this._isMapMode && nextValue !== void 0) {
11325
+ if (this._isMapMode) {
11317
11326
  const store = this._store;
11318
- if (store.has(key)) {
11319
- store.set(key, nextValue);
11327
+ const node = store.get(key);
11328
+ if (node) {
11329
+ node.value = nextValue;
11320
11330
  return true;
11321
11331
  }
11322
11332
  }
@@ -11341,10 +11351,8 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11341
11351
  const cmp = this._compare.bind(this);
11342
11352
  const c0 = cmp(key, hint.key);
11343
11353
  if (c0 === 0) {
11344
- if (this._isMapMode) {
11345
- if (value !== void 0) this._store.set(key, value);
11346
- else this._setValue(key, value);
11347
- } else hint.value = value;
11354
+ hint.value = value;
11355
+ if (this._isMapMode) this._store.set(key, hint);
11348
11356
  return hint;
11349
11357
  }
11350
11358
  if (c0 < 0) {
@@ -11352,10 +11360,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11352
11360
  const newNode = this.createNode(key, value);
11353
11361
  if (!this.isRealNode(newNode)) return void 0;
11354
11362
  this._attachNewNode(hint, "left", newNode);
11355
- if (this._isMapMode) {
11356
- if (value !== void 0) this._store.set(key, value);
11357
- else this._setValue(key, value);
11358
- }
11363
+ if (this._isMapMode) this._store.set(key, newNode);
11359
11364
  this._size++;
11360
11365
  const NIL = this.NIL;
11361
11366
  const hMin = (_b = this._header._left) != null ? _b : NIL;
@@ -11372,10 +11377,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11372
11377
  const newNode = this.createNode(key, value);
11373
11378
  if (!this.isRealNode(newNode)) return void 0;
11374
11379
  this._attachNewNode(pred, "right", newNode);
11375
- if (this._isMapMode) {
11376
- if (value !== void 0) this._store.set(key, value);
11377
- else this._setValue(key, value);
11378
- }
11380
+ if (this._isMapMode) this._store.set(key, newNode);
11379
11381
  this._size++;
11380
11382
  const NIL = this.NIL;
11381
11383
  const hMin = (_e = this._header._left) != null ? _e : NIL;
@@ -11390,10 +11392,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11390
11392
  const newNode = this.createNode(key, value);
11391
11393
  if (!this.isRealNode(newNode)) return void 0;
11392
11394
  this._attachNewNode(hint, "right", newNode);
11393
- if (this._isMapMode) {
11394
- if (value !== void 0) this._store.set(key, value);
11395
- else this._setValue(key, value);
11396
- }
11395
+ if (this._isMapMode) this._store.set(key, newNode);
11397
11396
  this._size++;
11398
11397
  const NIL = this.NIL;
11399
11398
  const hMin = (_h = this._header._left) != null ? _h : NIL;
@@ -11410,10 +11409,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11410
11409
  const newNode = this.createNode(key, value);
11411
11410
  if (!this.isRealNode(newNode)) return void 0;
11412
11411
  this._attachNewNode(succ, "left", newNode);
11413
- if (this._isMapMode) {
11414
- if (value !== void 0) this._store.set(key, value);
11415
- else this._setValue(key, value);
11416
- }
11412
+ if (this._isMapMode) this._store.set(key, newNode);
11417
11413
  this._size++;
11418
11414
  const NIL = this.NIL;
11419
11415
  const hMin = (_k = this._header._left) != null ? _k : NIL;
@@ -11460,12 +11456,24 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11460
11456
  } else {
11461
11457
  return false;
11462
11458
  }
11463
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11459
+ if (this._isMapMode) {
11460
+ const n = this.getNode(newNode.key);
11461
+ if (this.isRealNode(n)) {
11462
+ n.value = newValue;
11463
+ this._store.set(n.key, n);
11464
+ }
11465
+ }
11464
11466
  this._size++;
11465
11467
  return true;
11466
11468
  }
11467
11469
  if (insertStatus === "UPDATED") {
11468
- if (this._isMapMode) this._setValue(newNode.key, newValue);
11470
+ if (this._isMapMode) {
11471
+ const n = this.getNode(newNode.key);
11472
+ if (this.isRealNode(n)) {
11473
+ n.value = newValue;
11474
+ this._store.set(n.key, n);
11475
+ }
11476
+ }
11469
11477
  return true;
11470
11478
  }
11471
11479
  return false;
@@ -11835,1456 +11843,1543 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11835
11843
  __name(_RedBlackTree, "RedBlackTree");
11836
11844
  var RedBlackTree = _RedBlackTree;
11837
11845
 
11838
- // src/data-structures/binary-tree/avl-tree-multi-map.ts
11839
- var _AVLTreeMultiMapNode = class _AVLTreeMultiMapNode {
11846
+ // src/data-structures/binary-tree/tree-set.ts
11847
+ var _core, _isDefaultComparator, _userComparator;
11848
+ var _TreeSet = class _TreeSet {
11840
11849
  /**
11841
- * Create an AVLTreeMultiMap node with a value bucket.
11842
- * @remarks Time O(1), Space O(1)
11843
- * @param key - Key of the node.
11844
- * @param value - Initial array of values.
11845
- * @returns New AVLTreeMultiMapNode instance.
11850
+ * Create a TreeSet from an iterable of keys.
11851
+ *
11852
+ * @throws {TypeError} When using the default comparator and encountering unsupported key types,
11853
+ * or invalid keys (e.g. `NaN`, invalid `Date`).
11846
11854
  */
11847
- constructor(key, value = []) {
11848
- __publicField(this, "key");
11849
- __publicField(this, "value");
11850
- __publicField(this, "parent");
11851
- __publicField(this, "_left");
11852
- __publicField(this, "_right");
11853
- __publicField(this, "_height", 0);
11854
- __publicField(this, "_color", "BLACK");
11855
- __publicField(this, "_count", 1);
11856
- this.key = key;
11857
- this.value = value;
11855
+ constructor(elements = [], options = {}) {
11856
+ __privateAdd(this, _core);
11857
+ __privateAdd(this, _isDefaultComparator);
11858
+ __privateAdd(this, _userComparator);
11859
+ var _a;
11860
+ __privateSet(this, _userComparator, options.comparator);
11861
+ const comparator = (_a = options.comparator) != null ? _a : _TreeSet.createDefaultComparator();
11862
+ __privateSet(this, _isDefaultComparator, options.comparator === void 0);
11863
+ __privateSet(this, _core, new RedBlackTree([], { comparator, isMapMode: options.isMapMode }));
11864
+ for (const k of elements) this.add(k);
11858
11865
  }
11859
11866
  /**
11860
- * Get the left child pointer.
11861
- * @remarks Time O(1), Space O(1)
11862
- * @returns Left child node, or null/undefined.
11867
+ * Create the strict default comparator.
11868
+ *
11869
+ * Supports:
11870
+ * - `number` (rejects `NaN`; treats `-0` and `0` as equal)
11871
+ * - `string`
11872
+ * - `Date` (orders by `getTime()`, rejects invalid dates)
11873
+ *
11874
+ * For other key types, a custom comparator must be provided.
11863
11875
  */
11864
- get left() {
11865
- return this._left;
11876
+ static createDefaultComparator() {
11877
+ return (a, b) => {
11878
+ if (typeof a === "number" && typeof b === "number") {
11879
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeSet: NaN is not a valid key");
11880
+ const aa = Object.is(a, -0) ? 0 : a;
11881
+ const bb = Object.is(b, -0) ? 0 : b;
11882
+ return aa > bb ? 1 : aa < bb ? -1 : 0;
11883
+ }
11884
+ if (typeof a === "string" && typeof b === "string") {
11885
+ return a > b ? 1 : a < b ? -1 : 0;
11886
+ }
11887
+ if (a instanceof Date && b instanceof Date) {
11888
+ const ta = a.getTime();
11889
+ const tb = b.getTime();
11890
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeSet: invalid Date key");
11891
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
11892
+ }
11893
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11894
+ };
11866
11895
  }
11867
11896
  /**
11868
- * Set the left child and update its parent pointer.
11869
- * @remarks Time O(1), Space O(1)
11870
- * @param v - New left child node, or null/undefined.
11871
- * @returns void
11897
+ * Number of elements in the set.
11872
11898
  */
11873
- set left(v) {
11874
- if (v) {
11875
- v.parent = this;
11899
+ get size() {
11900
+ return __privateGet(this, _core).size;
11901
+ }
11902
+ /**
11903
+ * Whether the set is empty.
11904
+ */
11905
+ isEmpty() {
11906
+ return this.size === 0;
11907
+ }
11908
+ _validateKey(key) {
11909
+ if (!__privateGet(this, _isDefaultComparator)) return;
11910
+ if (typeof key === "number") {
11911
+ if (Number.isNaN(key)) throw new TypeError("TreeSet: NaN is not a valid key");
11912
+ return;
11876
11913
  }
11877
- this._left = v;
11914
+ if (typeof key === "string") return;
11915
+ if (key instanceof Date) {
11916
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeSet: invalid Date key");
11917
+ return;
11918
+ }
11919
+ throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
11878
11920
  }
11879
11921
  /**
11880
- * Get the right child pointer.
11881
- * @remarks Time O(1), Space O(1)
11882
- * @returns Right child node, or null/undefined.
11922
+ * Add a key to the set (no-op if already present).
11923
+ * @remarks Expected time O(log n)
11883
11924
  */
11884
- get right() {
11885
- return this._right;
11925
+ add(key) {
11926
+ this._validateKey(key);
11927
+ __privateGet(this, _core).set(key, void 0);
11928
+ return this;
11886
11929
  }
11887
11930
  /**
11888
- * Set the right child and update its parent pointer.
11889
- * @remarks Time O(1), Space O(1)
11890
- * @param v - New right child node, or null/undefined.
11891
- * @returns void
11931
+ * Test whether a key exists.
11932
+ * @remarks Expected time O(log n)
11892
11933
  */
11893
- set right(v) {
11894
- if (v) {
11895
- v.parent = this;
11896
- }
11897
- this._right = v;
11934
+ has(key) {
11935
+ this._validateKey(key);
11936
+ return __privateGet(this, _core).has(key);
11898
11937
  }
11899
11938
  /**
11900
- * Gets the height of the node (used in self-balancing trees).
11901
- * @remarks Time O(1), Space O(1)
11902
- *
11903
- * @returns The height.
11939
+ * Delete a key.
11940
+ * @returns `true` if the key existed; otherwise `false`.
11941
+ * @remarks Expected time O(log n)
11904
11942
  */
11905
- get height() {
11906
- return this._height;
11943
+ delete(key) {
11944
+ var _a;
11945
+ this._validateKey(key);
11946
+ const res = __privateGet(this, _core).delete(key);
11947
+ return Array.isArray(res) && res.length > 0 && !!((_a = res[0]) == null ? void 0 : _a.deleted);
11907
11948
  }
11908
11949
  /**
11909
- * Sets the height of the node.
11910
- * @remarks Time O(1), Space O(1)
11911
- *
11912
- * @param value - The new height.
11950
+ * Remove all keys.
11913
11951
  */
11914
- set height(value) {
11915
- this._height = value;
11952
+ clear() {
11953
+ __privateGet(this, _core).clear();
11916
11954
  }
11917
11955
  /**
11918
- * Gets the color of the node (used in Red-Black trees).
11919
- * @remarks Time O(1), Space O(1)
11920
- *
11921
- * @returns The node's color.
11956
+ * Iterate over keys in ascending order.
11922
11957
  */
11923
- get color() {
11924
- return this._color;
11958
+ keys() {
11959
+ return __privateGet(this, _core).keys();
11925
11960
  }
11926
11961
  /**
11927
- * Sets the color of the node.
11928
- * @remarks Time O(1), Space O(1)
11962
+ * Iterate over values in ascending order.
11929
11963
  *
11930
- * @param value - The new color.
11964
+ * Note: for Set-like containers, `values()` is the same as `keys()`.
11931
11965
  */
11932
- set color(value) {
11933
- this._color = value;
11966
+ values() {
11967
+ return this.keys();
11934
11968
  }
11935
11969
  /**
11936
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
11937
- * @remarks Time O(1), Space O(1)
11970
+ * Iterate over `[value, value]` pairs (native Set convention).
11938
11971
  *
11939
- * @returns The subtree node count.
11972
+ * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
11940
11973
  */
11941
- get count() {
11942
- return this._count;
11974
+ *entries() {
11975
+ for (const k of this.keys()) yield [k, k];
11976
+ }
11977
+ [Symbol.iterator]() {
11978
+ return this.keys();
11943
11979
  }
11944
11980
  /**
11945
- * Sets the count of nodes in the subtree.
11946
- * @remarks Time O(1), Space O(1)
11981
+ * Visit each value in ascending order.
11947
11982
  *
11948
- * @param value - The new count.
11983
+ * Callback follows native Set convention: `(value, value2, set)`.
11949
11984
  */
11950
- set count(value) {
11951
- this._count = value;
11985
+ forEach(cb, thisArg) {
11986
+ for (const k of this) cb.call(thisArg, k, k, this);
11952
11987
  }
11953
11988
  /**
11954
- * Gets the position of the node relative to its parent.
11955
- * @remarks Time O(1), Space O(1)
11989
+ * Create a new TreeSet by mapping each value to a new key.
11956
11990
  *
11957
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
11991
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
11992
+ * @remarks Time O(n log n) expected, Space O(n)
11958
11993
  */
11959
- get familyPosition() {
11960
- if (!this.parent) {
11961
- return this.left || this.right ? "ROOT" : "ISOLATED";
11962
- }
11963
- if (this.parent.left === this) {
11964
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
11965
- } else if (this.parent.right === this) {
11966
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
11994
+ map(callbackfn, options = {}, thisArg) {
11995
+ const out = new _TreeSet([], options);
11996
+ let index = 0;
11997
+ for (const v of this) {
11998
+ const mk = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
11999
+ out.add(mk);
11967
12000
  }
11968
- return "MAL_NODE";
12001
+ return out;
11969
12002
  }
11970
- };
11971
- __name(_AVLTreeMultiMapNode, "AVLTreeMultiMapNode");
11972
- var AVLTreeMultiMapNode = _AVLTreeMultiMapNode;
11973
- var _AVLTreeMultiMap = class _AVLTreeMultiMap extends AVLTree {
11974
12003
  /**
11975
- * Create an AVLTreeMultiMap and optionally bulk-insert items.
11976
- * @remarks Time O(N log N), Space O(N)
11977
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
11978
- * @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
11979
- * @returns New AVLTreeMultiMap instance.
12004
+ * Create a new TreeSet containing only values that satisfy the predicate.
12005
+ * @remarks Time O(n log n) expected, Space O(n)
11980
12006
  */
11981
- constructor(keysNodesEntriesOrRaws = [], options) {
11982
- super([], { ...options, isMapMode: true });
11983
- if (keysNodesEntriesOrRaws) {
11984
- this.setMany(keysNodesEntriesOrRaws);
12007
+ filter(callbackfn, thisArg) {
12008
+ const out = new _TreeSet([], { comparator: __privateGet(this, _userComparator) });
12009
+ let index = 0;
12010
+ for (const v of this) {
12011
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12012
+ if (ok) out.add(v);
11985
12013
  }
11986
- }
11987
- createNode(key, value = []) {
11988
- return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
12014
+ return out;
11989
12015
  }
11990
12016
  /**
11991
- * Checks if the given item is a `AVLTreeMultiMapNode` instance.
11992
- * @remarks Time O(1), Space O(1)
11993
- *
11994
- * @param keyNodeOrEntry - The item to check.
11995
- * @returns True if it's a AVLTreeMultiMapNode, false otherwise.
12017
+ * Reduce values into a single accumulator.
12018
+ * @remarks Time O(n), Space O(1)
11996
12019
  */
11997
- isNode(keyNodeOrEntry) {
11998
- return keyNodeOrEntry instanceof AVLTreeMultiMapNode;
12020
+ reduce(callbackfn, initialValue) {
12021
+ let acc = initialValue;
12022
+ let index = 0;
12023
+ for (const v of this) acc = callbackfn(acc, v, index++, this);
12024
+ return acc;
11999
12025
  }
12000
12026
  /**
12001
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12002
- * @remarks Time O(log N + M), Space O(1)
12003
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12004
- * @param [value] - Single value to set when a bare key is provided.
12005
- * @returns True if inserted or appended; false if ignored.
12027
+ * Test whether all values satisfy a predicate.
12028
+ * @remarks Time O(n), Space O(1)
12006
12029
  */
12007
- set(keyNodeOrEntry, value) {
12008
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12009
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12010
- if (key === void 0 || key === null) return false;
12011
- const _setToValues = /* @__PURE__ */ __name(() => {
12012
- const existingValues = this.get(key);
12013
- if (existingValues !== void 0 && values !== void 0) {
12014
- for (const value2 of values) existingValues.push(value2);
12015
- return true;
12016
- }
12017
- return false;
12018
- }, "_setToValues");
12019
- const _setByNode = /* @__PURE__ */ __name(() => {
12020
- const existingNode = this.getNode(key);
12021
- if (this.isRealNode(existingNode)) {
12022
- const existingValues = this.get(existingNode);
12023
- if (existingValues === void 0) {
12024
- super.set(key, values);
12025
- return true;
12026
- }
12027
- if (values !== void 0) {
12028
- for (const value2 of values) existingValues.push(value2);
12029
- return true;
12030
- } else {
12031
- return false;
12032
- }
12033
- } else {
12034
- return super.set(key, values);
12035
- }
12036
- }, "_setByNode");
12037
- if (this._isMapMode) {
12038
- return _setByNode() || _setToValues();
12039
- }
12040
- return _setToValues() || _setByNode();
12041
- }, "_commonAdd");
12042
- if (this.isEntry(keyNodeOrEntry)) {
12043
- const [key, values] = keyNodeOrEntry;
12044
- return _commonAdd(key, value !== void 0 ? [value] : values);
12030
+ every(callbackfn, thisArg) {
12031
+ let index = 0;
12032
+ for (const v of this) {
12033
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12034
+ if (!ok) return false;
12045
12035
  }
12046
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12036
+ return true;
12047
12037
  }
12048
12038
  /**
12049
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12050
- * @remarks Time O(log N), Space O(1)
12051
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12052
- * @param value - Value to remove from the bucket.
12053
- * @returns True if the value was removed; false if not found.
12054
- */
12055
- deleteValue(keyNodeOrEntry, value) {
12056
- const values = this.get(keyNodeOrEntry);
12057
- if (Array.isArray(values)) {
12058
- const index = values.indexOf(value);
12059
- if (index === -1) return false;
12060
- values.splice(index, 1);
12061
- if (values.length === 0) this.delete(keyNodeOrEntry);
12062
- return true;
12039
+ * Test whether any value satisfies a predicate.
12040
+ * @remarks Time O(n), Space O(1)
12041
+ */
12042
+ some(callbackfn, thisArg) {
12043
+ let index = 0;
12044
+ for (const v of this) {
12045
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12046
+ if (ok) return true;
12063
12047
  }
12064
12048
  return false;
12065
12049
  }
12066
12050
  /**
12067
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12068
- * @remarks Time O(N), Space O(N)
12069
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12070
- * @returns True if rebalancing succeeded (tree not empty).
12051
+ * Find the first value that satisfies a predicate.
12052
+ * @remarks Time O(n), Space O(1)
12071
12053
  */
12072
- perfectlyBalance(iterationType = this.iterationType) {
12073
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12074
- const n = nodes.length;
12075
- if (n === 0) return false;
12076
- this._clearNodes();
12077
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12078
- if (l > r) return void 0;
12079
- const m = l + (r - l >> 1);
12080
- const root = nodes[m];
12081
- root.left = build(l, m - 1, root);
12082
- root.right = build(m + 1, r, root);
12083
- root.parent = parent;
12084
- const lh = root.left ? root.left.height : -1;
12085
- const rh = root.right ? root.right.height : -1;
12086
- root.height = Math.max(lh, rh) + 1;
12087
- return root;
12088
- }, "build");
12089
- const newRoot = build(0, n - 1, void 0);
12090
- this._setRoot(newRoot);
12091
- this._size = n;
12092
- return true;
12054
+ find(callbackfn, thisArg) {
12055
+ let index = 0;
12056
+ for (const v of this) {
12057
+ const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
12058
+ if (ok) return v;
12059
+ }
12060
+ return void 0;
12093
12061
  }
12094
12062
  /**
12095
- * Create a new tree by mapping each [key, values] bucket.
12096
- * @remarks Time O(N log N), Space O(N)
12097
- * @template MK
12098
- * @template MV
12099
- * @template MR
12100
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12101
- * @param [options] - Options for the output tree.
12102
- * @param [thisArg] - Value for `this` inside the callback.
12103
- * @returns The mapped AVLTree or AVLTreeMultiMap depending on MV; see overloads.
12063
+ * Materialize the set into an array of keys.
12064
+ * @remarks Time O(n), Space O(n)
12104
12065
  */
12105
- map(callback, options, thisArg) {
12106
- const out = this._createLike([], options);
12107
- let i = 0;
12108
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12109
- return out;
12066
+ toArray() {
12067
+ return [...this];
12110
12068
  }
12111
12069
  /**
12112
- * (Protected) Create an empty instance of the same concrete class.
12113
- * @remarks Time O(1), Space O(1)
12114
- * @template TK
12115
- * @template TV
12116
- * @template TR
12117
- * @param [options] - Optional constructor options for the like-kind instance.
12118
- * @returns An empty like-kind instance.
12070
+ * Print a human-friendly representation.
12071
+ * @remarks Time O(n), Space O(n)
12119
12072
  */
12120
- _createInstance(options) {
12121
- var _a, _b;
12122
- const Ctor = this.constructor;
12123
- return new Ctor([], { ...(_b = (_a = this._snapshotOptions) == null ? void 0 : _a.call(this)) != null ? _b : {}, ...options != null ? options : {} });
12073
+ print() {
12074
+ __privateGet(this, _core).print();
12124
12075
  }
12076
+ // Navigable operations
12125
12077
  /**
12126
- * (Protected) Create a like-kind instance and seed it from an iterable.
12127
- * @remarks Time O(N log N), Space O(N)
12128
- * @template TK
12129
- * @template TV
12130
- * @template TR
12131
- * @param iter - Iterable used to seed the new tree.
12132
- * @param [options] - Options merged with the current snapshot.
12133
- * @returns A like-kind AVLTree built from the iterable.
12078
+ * Smallest key in the set.
12134
12079
  */
12135
- _createLike(iter = [], options) {
12136
- var _a, _b;
12137
- const Ctor = this.constructor;
12138
- return new Ctor(iter, { ...(_b = (_a = this._snapshotOptions) == null ? void 0 : _a.call(this)) != null ? _b : {}, ...options != null ? options : {} });
12080
+ first() {
12081
+ return __privateGet(this, _core).getLeftMost();
12139
12082
  }
12140
- };
12141
- __name(_AVLTreeMultiMap, "AVLTreeMultiMap");
12142
- var AVLTreeMultiMap = _AVLTreeMultiMap;
12143
-
12144
- // src/data-structures/binary-tree/tree-multi-map.ts
12145
- var _TreeMultiMapNode = class _TreeMultiMapNode {
12146
12083
  /**
12147
- * Create a TreeMultiMap node with an optional value bucket.
12148
- * @remarks Time O(1), Space O(1)
12149
- * @param key - Key of the node.
12150
- * @param [value] - Initial array of values.
12151
- * @returns New TreeMultiMapNode instance.
12084
+ * Largest key in the set.
12152
12085
  */
12153
- constructor(key, value = [], color = "BLACK") {
12154
- __publicField(this, "key");
12155
- __publicField(this, "value");
12156
- __publicField(this, "parent");
12157
- __publicField(this, "_left");
12158
- __publicField(this, "_right");
12159
- __publicField(this, "_height", 0);
12160
- __publicField(this, "_color", "BLACK");
12161
- __publicField(this, "_count", 1);
12162
- this.key = key;
12163
- this.value = value;
12164
- this.color = color;
12086
+ last() {
12087
+ return __privateGet(this, _core).getRightMost();
12165
12088
  }
12166
12089
  /**
12167
- * Get the left child pointer.
12168
- * @remarks Time O(1), Space O(1)
12169
- * @returns Left child node, or null/undefined.
12090
+ * Remove and return the smallest key.
12170
12091
  */
12171
- get left() {
12172
- return this._left;
12092
+ pollFirst() {
12093
+ const k = this.first();
12094
+ if (k === void 0) return void 0;
12095
+ this.delete(k);
12096
+ return k;
12173
12097
  }
12174
12098
  /**
12175
- * Set the left child and update its parent pointer.
12176
- * @remarks Time O(1), Space O(1)
12177
- * @param v - New left child node, or null/undefined.
12178
- * @returns void
12099
+ * Remove and return the largest key.
12179
12100
  */
12180
- set left(v) {
12181
- if (v) {
12182
- v.parent = this;
12183
- }
12184
- this._left = v;
12101
+ pollLast() {
12102
+ const k = this.last();
12103
+ if (k === void 0) return void 0;
12104
+ this.delete(k);
12105
+ return k;
12185
12106
  }
12186
12107
  /**
12187
- * Get the right child pointer.
12188
- * @remarks Time O(1), Space O(1)
12189
- * @returns Right child node, or null/undefined.
12108
+ * Smallest key that is >= the given key.
12190
12109
  */
12191
- get right() {
12192
- return this._right;
12110
+ ceiling(key) {
12111
+ this._validateKey(key);
12112
+ return __privateGet(this, _core).ceiling(key);
12193
12113
  }
12194
12114
  /**
12195
- * Set the right child and update its parent pointer.
12196
- * @remarks Time O(1), Space O(1)
12197
- * @param v - New right child node, or null/undefined.
12198
- * @returns void
12115
+ * Largest key that is <= the given key.
12199
12116
  */
12200
- set right(v) {
12201
- if (v) {
12202
- v.parent = this;
12203
- }
12204
- this._right = v;
12117
+ floor(key) {
12118
+ this._validateKey(key);
12119
+ return __privateGet(this, _core).floor(key);
12205
12120
  }
12206
12121
  /**
12207
- * Gets the height of the node (used in self-balancing trees).
12208
- * @remarks Time O(1), Space O(1)
12209
- *
12210
- * @returns The height.
12122
+ * Smallest key that is > the given key.
12211
12123
  */
12212
- get height() {
12213
- return this._height;
12124
+ higher(key) {
12125
+ this._validateKey(key);
12126
+ return __privateGet(this, _core).higher(key);
12214
12127
  }
12215
12128
  /**
12216
- * Sets the height of the node.
12217
- * @remarks Time O(1), Space O(1)
12218
- *
12219
- * @param value - The new height.
12129
+ * Largest key that is < the given key.
12220
12130
  */
12221
- set height(value) {
12222
- this._height = value;
12131
+ lower(key) {
12132
+ this._validateKey(key);
12133
+ return __privateGet(this, _core).lower(key);
12223
12134
  }
12224
12135
  /**
12225
- * Gets the color of the node (used in Red-Black trees).
12226
- * @remarks Time O(1), Space O(1)
12136
+ * Return all keys in a given range.
12227
12137
  *
12228
- * @returns The node's color.
12138
+ * @param range `[low, high]`
12139
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12229
12140
  */
12230
- get color() {
12231
- return this._color;
12141
+ rangeSearch(range, options = {}) {
12142
+ const { lowInclusive = true, highInclusive = true } = options;
12143
+ const [low, high] = range;
12144
+ this._validateKey(low);
12145
+ this._validateKey(high);
12146
+ const keys = __privateGet(this, _core).rangeSearch([low, high]);
12147
+ const out = [];
12148
+ const cmp = __privateGet(this, _core).comparator;
12149
+ for (const k of keys) {
12150
+ if (k === void 0) continue;
12151
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12152
+ if (!highInclusive && cmp(k, high) === 0) continue;
12153
+ out.push(k);
12154
+ }
12155
+ return out;
12156
+ }
12157
+ };
12158
+ _core = new WeakMap();
12159
+ _isDefaultComparator = new WeakMap();
12160
+ _userComparator = new WeakMap();
12161
+ __name(_TreeSet, "TreeSet");
12162
+ var TreeSet = _TreeSet;
12163
+
12164
+ // src/data-structures/binary-tree/tree-multi-map.ts
12165
+ var _TreeMultiMapNode = class _TreeMultiMapNode extends RedBlackTreeNode {
12166
+ constructor(key, value = []) {
12167
+ super(key, value);
12232
12168
  }
12169
+ };
12170
+ __name(_TreeMultiMapNode, "TreeMultiMapNode");
12171
+ var TreeMultiMapNode = _TreeMultiMapNode;
12172
+ var _core2, _isDefaultComparator2;
12173
+ var _TreeMultiMap = class _TreeMultiMap {
12233
12174
  /**
12234
- * Sets the color of the node.
12175
+ * Creates a new TreeMultiMap.
12176
+ * @param keysNodesEntriesOrRaws - Initial entries
12177
+ * @param options - Configuration options
12178
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial entries
12179
+ */
12180
+ constructor(keysNodesEntriesOrRaws = [], options = {}) {
12181
+ __privateAdd(this, _core2);
12182
+ __privateAdd(this, _isDefaultComparator2);
12183
+ var _a;
12184
+ const comparator = (_a = options.comparator) != null ? _a : TreeSet.createDefaultComparator();
12185
+ __privateSet(this, _isDefaultComparator2, options.comparator === void 0);
12186
+ __privateSet(this, _core2, new RedBlackTree([], { ...options, comparator, isMapMode: options.isMapMode }));
12187
+ for (const x of keysNodesEntriesOrRaws) {
12188
+ if (x === null || x === void 0) continue;
12189
+ if (Array.isArray(x)) {
12190
+ const [k, bucket] = x;
12191
+ if (k === null || k === void 0) continue;
12192
+ if (bucket !== void 0) {
12193
+ __privateGet(this, _core2).set(k, [...bucket]);
12194
+ } else {
12195
+ __privateGet(this, _core2).set(k, []);
12196
+ }
12197
+ continue;
12198
+ }
12199
+ __privateGet(this, _core2).set(x, []);
12200
+ }
12201
+ }
12202
+ /**
12203
+ * Validates the key against the default comparator rules.
12235
12204
  * @remarks Time O(1), Space O(1)
12236
- *
12237
- * @param value - The new color.
12238
12205
  */
12239
- set color(value) {
12240
- this._color = value;
12206
+ _validateKey(key) {
12207
+ if (!__privateGet(this, _isDefaultComparator2)) return;
12208
+ if (typeof key === "number") {
12209
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiMap: NaN is not a valid key");
12210
+ return;
12211
+ }
12212
+ if (typeof key === "string") return;
12213
+ if (key instanceof Date) {
12214
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiMap: invalid Date key");
12215
+ return;
12216
+ }
12217
+ throw new TypeError("TreeMultiMap: comparator is required for non-number/non-string/non-Date keys");
12241
12218
  }
12242
12219
  /**
12243
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12220
+ * Number of distinct keys.
12244
12221
  * @remarks Time O(1), Space O(1)
12245
- *
12246
- * @returns The subtree node count.
12247
12222
  */
12248
- get count() {
12249
- return this._count;
12223
+ get size() {
12224
+ return __privateGet(this, _core2).size;
12250
12225
  }
12251
12226
  /**
12252
- * Sets the count of nodes in the subtree.
12227
+ * Whether the map is empty.
12253
12228
  * @remarks Time O(1), Space O(1)
12254
- *
12255
- * @param value - The new count.
12256
12229
  */
12257
- set count(value) {
12258
- this._count = value;
12230
+ isEmpty() {
12231
+ return this.size === 0;
12259
12232
  }
12260
12233
  /**
12261
- * Gets the position of the node relative to its parent.
12234
+ * Removes all entries from the map.
12262
12235
  * @remarks Time O(1), Space O(1)
12263
- *
12264
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12265
12236
  */
12266
- get familyPosition() {
12267
- if (!this.parent) {
12268
- return this.left || this.right ? "ROOT" : "ISOLATED";
12269
- }
12270
- if (this.parent.left === this) {
12271
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12272
- } else if (this.parent.right === this) {
12273
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12274
- }
12275
- return "MAL_NODE";
12237
+ clear() {
12238
+ __privateGet(this, _core2).clear();
12276
12239
  }
12277
- };
12278
- __name(_TreeMultiMapNode, "TreeMultiMapNode");
12279
- var TreeMultiMapNode = _TreeMultiMapNode;
12280
- var _TreeMultiMap = class _TreeMultiMap extends RedBlackTree {
12281
12240
  /**
12282
- * Create a TreeMultiMap and optionally bulk-insert items.
12283
- * @remarks Time O(N log N), Space O(N)
12284
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12285
- * @param [options] - Options for TreeMultiMap (comparator, reverse, map mode).
12286
- * @returns New TreeMultiMap instance.
12241
+ * Bucket length for a key (missing => 0).
12242
+ * @remarks Time O(log n), Space O(1)
12287
12243
  */
12288
- constructor(keysNodesEntriesOrRaws = [], options) {
12289
- super([], { ...options });
12290
- if (keysNodesEntriesOrRaws) {
12291
- this.setMany(keysNodesEntriesOrRaws);
12292
- }
12244
+ count(key) {
12245
+ const b = this.get(key);
12246
+ return Array.isArray(b) ? b.length : 0;
12293
12247
  }
12294
- createNode(key, value = []) {
12295
- return new TreeMultiMapNode(key, this._isMapMode ? [] : value);
12248
+ /**
12249
+ * Total number of values across all buckets (Σ bucket.length).
12250
+ * @remarks Time O(n), Space O(1)
12251
+ */
12252
+ get totalSize() {
12253
+ let sum = 0;
12254
+ for (const [, bucket] of this) sum += bucket.length;
12255
+ return sum;
12296
12256
  }
12297
12257
  /**
12298
- * Checks if the given item is a `TreeMultiMapNode` instance.
12299
- * @remarks Time O(1), Space O(1)
12300
- *
12301
- * @param keyNodeOrEntry - The item to check.
12302
- * @returns True if it's a TreeMultiMapNode, false otherwise.
12258
+ * Whether the map contains the given key.
12259
+ * @remarks Time O(log n), Space O(1)
12303
12260
  */
12304
- isNode(keyNodeOrEntry) {
12305
- return keyNodeOrEntry instanceof TreeMultiMapNode;
12261
+ has(key) {
12262
+ this._validateKey(key);
12263
+ return __privateGet(this, _core2).has(key);
12306
12264
  }
12307
12265
  /**
12308
- * Insert a value or a list of values into the multimap. If the key exists, values are appended.
12309
- * @remarks Time O(log N + M), Space O(1)
12310
- * @param keyNodeOrEntry - Key, node, or [key, values] entry.
12311
- * @param [value] - Single value to set when a bare key is provided.
12312
- * @returns True if inserted or appended; false if ignored.
12266
+ * Live bucket reference (do not auto-delete key if bucket becomes empty via mutation).
12267
+ * @remarks Time O(log n), Space O(1)
12313
12268
  */
12314
- set(keyNodeOrEntry, value) {
12315
- if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
12316
- const _commonAdd = /* @__PURE__ */ __name((key, values) => {
12317
- if (key === void 0 || key === null) return false;
12318
- const _setToValues = /* @__PURE__ */ __name(() => {
12319
- const existingValues = this.get(key);
12320
- if (existingValues !== void 0 && values !== void 0) {
12321
- for (const value2 of values) existingValues.push(value2);
12322
- return true;
12323
- }
12324
- return false;
12325
- }, "_setToValues");
12326
- const _setByNode = /* @__PURE__ */ __name(() => {
12327
- const existingNode = this.getNode(key);
12328
- if (this.isRealNode(existingNode)) {
12329
- const existingValues = this.get(existingNode);
12330
- if (existingValues === void 0) {
12331
- super.set(key, values);
12332
- return true;
12333
- }
12334
- if (values !== void 0) {
12335
- for (const value2 of values) existingValues.push(value2);
12336
- return true;
12337
- } else {
12338
- return false;
12339
- }
12340
- } else {
12341
- return super.set(key, values);
12342
- }
12343
- }, "_setByNode");
12344
- if (this._isMapMode) {
12345
- return _setByNode() || _setToValues();
12346
- }
12347
- return _setToValues() || _setByNode();
12348
- }, "_commonAdd");
12349
- if (this.isEntry(keyNodeOrEntry)) {
12350
- const [key, values] = keyNodeOrEntry;
12351
- return _commonAdd(key, value !== void 0 ? [value] : values);
12352
- }
12353
- return _commonAdd(keyNodeOrEntry, value !== void 0 ? [value] : void 0);
12269
+ get(key) {
12270
+ this._validateKey(key);
12271
+ return __privateGet(this, _core2).get(key);
12354
12272
  }
12355
12273
  /**
12356
- * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
12357
- * @remarks Time O(log N), Space O(1)
12358
- * @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
12359
- * @param value - Value to remove from the bucket.
12360
- * @returns True if the value was removed; false if not found.
12361
- */
12362
- deleteValue(keyNodeOrEntry, value) {
12363
- const values = this.get(keyNodeOrEntry);
12364
- if (Array.isArray(values)) {
12365
- const index = values.indexOf(value);
12366
- if (index === -1) return false;
12367
- values.splice(index, 1);
12368
- if (values.length === 0) this.delete(keyNodeOrEntry);
12274
+ * Append a single value.
12275
+ * @remarks Time O(log n), Space O(1)
12276
+ */
12277
+ add(key, value) {
12278
+ this._validateKey(key);
12279
+ const bucket = __privateGet(this, _core2).get(key);
12280
+ if (bucket) {
12281
+ bucket.push(value);
12369
12282
  return true;
12370
12283
  }
12371
- return false;
12284
+ return __privateGet(this, _core2).set(key, [value]);
12285
+ }
12286
+ set(entry, value) {
12287
+ if (entry === null || entry === void 0) return false;
12288
+ if (Array.isArray(entry)) {
12289
+ const [k, bucket] = entry;
12290
+ if (k === null || k === void 0) return false;
12291
+ if (value !== void 0) return this.add(k, value);
12292
+ if (bucket === void 0) {
12293
+ return __privateGet(this, _core2).set(k, []);
12294
+ }
12295
+ const existing = __privateGet(this, _core2).get(k);
12296
+ if (existing) {
12297
+ existing.push(...bucket);
12298
+ return true;
12299
+ }
12300
+ return __privateGet(this, _core2).set(k, [...bucket]);
12301
+ }
12302
+ if (value !== void 0) return this.add(entry, value);
12303
+ return __privateGet(this, _core2).set(entry, []);
12372
12304
  }
12373
12305
  /**
12374
- * Create a new tree by mapping each [key, values] bucket.
12375
- * @remarks Time O(N log N), Space O(N)
12376
- * @template MK
12377
- * @template MV
12378
- * @template MR
12379
- * @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
12380
- * @param [options] - Options for the output tree.
12381
- * @param [thisArg] - Value for `this` inside the callback.
12382
- * @returns A new RedBlackTree (or TreeMultiMap when mapping to array values; see overloads).
12306
+ * Deletes a key and its entire bucket.
12307
+ * @remarks Time O(log n), Space O(1)
12383
12308
  */
12384
- map(callback, options, thisArg) {
12385
- const out = this._createLike([], options);
12386
- let i = 0;
12387
- for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
12388
- return out;
12309
+ delete(key) {
12310
+ this._validateKey(key);
12311
+ return __privateGet(this, _core2).delete(key).length > 0;
12389
12312
  }
12390
12313
  /**
12391
- * (Protected) Create an empty instance of the same concrete class.
12392
- * @remarks Time O(1), Space O(1)
12393
- * @template TK
12394
- * @template TV
12395
- * @template TR
12396
- * @param [options] - Optional constructor options for the like-kind instance.
12397
- * @returns An empty like-kind instance.
12314
+ * Check if a specific value exists in a key's bucket.
12315
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12398
12316
  */
12399
- _createInstance(options) {
12400
- var _a, _b;
12401
- const Ctor = this.constructor;
12402
- return new Ctor([], { ...(_b = (_a = this._snapshotOptions) == null ? void 0 : _a.call(this)) != null ? _b : {}, ...options != null ? options : {} });
12317
+ hasEntry(key, value, eq = Object.is) {
12318
+ const bucket = this.get(key);
12319
+ if (!Array.isArray(bucket)) return false;
12320
+ return bucket.some((v) => eq(v, value));
12403
12321
  }
12404
12322
  /**
12405
- * (Protected) Create a like-kind instance and seed it from an iterable.
12406
- * @remarks Time O(N log N), Space O(N)
12407
- * @template TK
12408
- * @template TV
12409
- * @template TR
12410
- * @param iter - Iterable used to seed the new tree.
12411
- * @param [options] - Options merged with the current snapshot.
12412
- * @returns A like-kind RedBlackTree built from the iterable.
12323
+ * Delete a single occurrence of a value from a key's bucket.
12324
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12413
12325
  */
12414
- _createLike(iter = [], options) {
12415
- var _a, _b;
12416
- const Ctor = this.constructor;
12417
- return new Ctor(iter, { ...(_b = (_a = this._snapshotOptions) == null ? void 0 : _a.call(this)) != null ? _b : {}, ...options != null ? options : {} });
12326
+ deleteValue(key, value, eq = Object.is) {
12327
+ const bucket = this.get(key);
12328
+ if (!Array.isArray(bucket)) return false;
12329
+ const idx = bucket.findIndex((v) => eq(v, value));
12330
+ if (idx === -1) return false;
12331
+ bucket.splice(idx, 1);
12332
+ if (bucket.length === 0) this.delete(key);
12333
+ return true;
12418
12334
  }
12419
- };
12420
- __name(_TreeMultiMap, "TreeMultiMap");
12421
- var TreeMultiMap = _TreeMultiMap;
12422
-
12423
- // src/data-structures/binary-tree/tree-counter.ts
12424
- var _TreeCounterNode = class _TreeCounterNode {
12425
12335
  /**
12426
- * Create a tree counter node.
12427
- * @remarks Time O(1), Space O(1)
12428
- * @param key - Key of the node.
12429
- * @param [value] - Value associated with the key (ignored in map mode).
12430
- * @param [count] - Initial count for this node (default 1).
12431
- * @param color - Initial color ('RED' or 'BLACK').
12432
- * @returns New TreeCounterNode instance.
12336
+ * Delete all occurrences of a value from a key's bucket.
12337
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12433
12338
  */
12434
- constructor(key, value, count = 1, color = "BLACK") {
12435
- __publicField(this, "key");
12436
- __publicField(this, "value");
12437
- __publicField(this, "parent");
12438
- __publicField(this, "_left");
12439
- __publicField(this, "_right");
12440
- __publicField(this, "_height", 0);
12441
- __publicField(this, "_color", "BLACK");
12442
- __publicField(this, "_count", 1);
12443
- this.key = key;
12444
- this.value = value;
12445
- this.color = color;
12446
- this.count = count;
12339
+ deleteValues(key, value, eq = Object.is) {
12340
+ const bucket = this.get(key);
12341
+ if (!Array.isArray(bucket) || bucket.length === 0) return 0;
12342
+ let removed = 0;
12343
+ for (let i = bucket.length - 1; i >= 0; i--) {
12344
+ if (eq(bucket[i], value)) {
12345
+ bucket.splice(i, 1);
12346
+ removed++;
12347
+ }
12348
+ }
12349
+ if (bucket.length === 0 && removed > 0) this.delete(key);
12350
+ return removed;
12447
12351
  }
12352
+ // ---- iteration (bucket view) ----
12448
12353
  /**
12449
- * Get the left child pointer.
12450
- * @remarks Time O(1), Space O(1)
12451
- * @returns Left child node, or null/undefined.
12354
+ * Iterates over all entries as [key, bucket] pairs.
12355
+ * @remarks Time O(n), Space O(1)
12452
12356
  */
12453
- get left() {
12454
- return this._left;
12357
+ *[Symbol.iterator]() {
12358
+ for (const [k, v] of __privateGet(this, _core2)) {
12359
+ yield [k, v != null ? v : []];
12360
+ }
12455
12361
  }
12456
12362
  /**
12457
- * Set the left child and update its parent pointer.
12458
- * @remarks Time O(1), Space O(1)
12459
- * @param v - New left child node, or null/undefined.
12460
- * @returns void
12363
+ * Iterates over all keys.
12364
+ * @remarks Time O(n), Space O(1)
12461
12365
  */
12462
- set left(v) {
12463
- if (v) {
12464
- v.parent = this;
12465
- }
12466
- this._left = v;
12366
+ *keys() {
12367
+ yield* __privateGet(this, _core2).keys();
12467
12368
  }
12468
12369
  /**
12469
- * Get the right child pointer.
12470
- * @remarks Time O(1), Space O(1)
12471
- * @returns Right child node, or null/undefined.
12370
+ * Iterates over all buckets.
12371
+ * @remarks Time O(n), Space O(1)
12472
12372
  */
12473
- get right() {
12474
- return this._right;
12373
+ *values() {
12374
+ for (const [, bucket] of this) yield bucket;
12475
12375
  }
12376
+ // ---- entry-flat views ----
12476
12377
  /**
12477
- * Set the right child and update its parent pointer.
12478
- * @remarks Time O(1), Space O(1)
12479
- * @param v - New right child node, or null/undefined.
12480
- * @returns void
12378
+ * Iterates over all entries for a specific key.
12379
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12481
12380
  */
12482
- set right(v) {
12483
- if (v) {
12484
- v.parent = this;
12485
- }
12486
- this._right = v;
12381
+ *entriesOf(key) {
12382
+ const bucket = this.get(key);
12383
+ if (!Array.isArray(bucket)) return;
12384
+ for (const v of bucket) yield [key, v];
12487
12385
  }
12488
12386
  /**
12489
- * Gets the height of the node (used in self-balancing trees).
12490
- * @remarks Time O(1), Space O(1)
12491
- *
12492
- * @returns The height.
12387
+ * Iterates over all values for a specific key.
12388
+ * @remarks Time O(log n + m), Space O(1) where m is bucket size
12493
12389
  */
12494
- get height() {
12495
- return this._height;
12390
+ *valuesOf(key) {
12391
+ const bucket = this.get(key);
12392
+ if (!Array.isArray(bucket)) return;
12393
+ yield* bucket;
12496
12394
  }
12497
12395
  /**
12498
- * Sets the height of the node.
12499
- * @remarks Time O(1), Space O(1)
12500
- *
12501
- * @param value - The new height.
12396
+ * Iterates over all [key, value] pairs (flattened from buckets).
12397
+ * @remarks Time O(T), Space O(1) where T is totalSize
12502
12398
  */
12503
- set height(value) {
12504
- this._height = value;
12399
+ *flatEntries() {
12400
+ for (const [k, bucket] of this) {
12401
+ for (const v of bucket) yield [k, v];
12402
+ }
12505
12403
  }
12404
+ // ━━━ Navigable methods (return [K, V[]] | undefined) ━━━
12506
12405
  /**
12507
- * Gets the color of the node (used in Red-Black trees).
12508
- * @remarks Time O(1), Space O(1)
12509
- *
12510
- * @returns The node's color.
12406
+ * Returns the entry with the smallest key.
12407
+ * @remarks Time O(log n), Space O(1)
12408
+ * @example
12409
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12410
+ * map.first(); // [1, ['a']]
12511
12411
  */
12512
- get color() {
12513
- return this._color;
12412
+ first() {
12413
+ const k = __privateGet(this, _core2).getLeftMost();
12414
+ if (k === void 0) return void 0;
12415
+ const b = this.get(k);
12416
+ return b === void 0 ? void 0 : [k, b];
12514
12417
  }
12515
12418
  /**
12516
- * Sets the color of the node.
12517
- * @remarks Time O(1), Space O(1)
12518
- *
12519
- * @param value - The new color.
12419
+ * Returns the entry with the largest key.
12420
+ * @remarks Time O(log n), Space O(1)
12421
+ * @example
12422
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12423
+ * map.last(); // [2, ['b']]
12520
12424
  */
12521
- set color(value) {
12522
- this._color = value;
12425
+ last() {
12426
+ const k = __privateGet(this, _core2).getRightMost();
12427
+ if (k === void 0) return void 0;
12428
+ const b = this.get(k);
12429
+ return b === void 0 ? void 0 : [k, b];
12523
12430
  }
12524
12431
  /**
12525
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12526
- * @remarks Time O(1), Space O(1)
12527
- *
12528
- * @returns The subtree node count.
12432
+ * Removes and returns the entry with the smallest key.
12433
+ * @remarks Time O(log n), Space O(1)
12434
+ * @example
12435
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12436
+ * map.pollFirst(); // [1, ['a']]
12437
+ * map.has(1); // false
12529
12438
  */
12530
- get count() {
12531
- return this._count;
12439
+ pollFirst() {
12440
+ const e = this.first();
12441
+ if (!e) return void 0;
12442
+ this.delete(e[0]);
12443
+ return e;
12532
12444
  }
12533
12445
  /**
12534
- * Sets the count of nodes in the subtree.
12535
- * @remarks Time O(1), Space O(1)
12536
- *
12537
- * @param value - The new count.
12446
+ * Removes and returns the entry with the largest key.
12447
+ * @remarks Time O(log n), Space O(1)
12448
+ * @example
12449
+ * const map = new TreeMultiMap([[1, ['a']], [2, ['b']]]);
12450
+ * map.pollLast(); // [2, ['b']]
12451
+ * map.has(2); // false
12538
12452
  */
12539
- set count(value) {
12540
- this._count = value;
12453
+ pollLast() {
12454
+ const e = this.last();
12455
+ if (!e) return void 0;
12456
+ this.delete(e[0]);
12457
+ return e;
12541
12458
  }
12542
12459
  /**
12543
- * Gets the position of the node relative to its parent.
12544
- * @remarks Time O(1), Space O(1)
12545
- *
12546
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
12460
+ * Returns the entry with the smallest key >= given key.
12461
+ * @remarks Time O(log n), Space O(1)
12462
+ * @example
12463
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12464
+ * map.ceiling(15); // [20, ['b']]
12465
+ * map.ceiling(20); // [20, ['b']]
12547
12466
  */
12548
- get familyPosition() {
12549
- if (!this.parent) {
12550
- return this.left || this.right ? "ROOT" : "ISOLATED";
12551
- }
12552
- if (this.parent.left === this) {
12553
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
12554
- } else if (this.parent.right === this) {
12555
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
12556
- }
12557
- return "MAL_NODE";
12467
+ ceiling(key) {
12468
+ this._validateKey(key);
12469
+ const k = __privateGet(this, _core2).ceiling(key);
12470
+ if (k === void 0) return void 0;
12471
+ const b = this.get(k);
12472
+ return b === void 0 ? void 0 : [k, b];
12558
12473
  }
12559
- };
12560
- __name(_TreeCounterNode, "TreeCounterNode");
12561
- var TreeCounterNode = _TreeCounterNode;
12562
- var _TreeCounter = class _TreeCounter extends RedBlackTree {
12563
12474
  /**
12564
- * Create a TreeCounter and optionally bulk-insert items.
12565
- * @remarks Time O(N log N), Space O(N)
12566
- * @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
12567
- * @param [options] - Options for TreeCounter (comparator, reverse, map mode).
12568
- * @returns New TreeCounter instance.
12475
+ * Returns the entry with the largest key <= given key.
12476
+ * @remarks Time O(log n), Space O(1)
12477
+ * @example
12478
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12479
+ * map.floor(25); // [20, ['b']]
12480
+ * map.floor(20); // [20, ['b']]
12481
+ */
12482
+ floor(key) {
12483
+ this._validateKey(key);
12484
+ const k = __privateGet(this, _core2).floor(key);
12485
+ if (k === void 0) return void 0;
12486
+ const b = this.get(k);
12487
+ return b === void 0 ? void 0 : [k, b];
12488
+ }
12489
+ /**
12490
+ * Returns the entry with the smallest key > given key.
12491
+ * @remarks Time O(log n), Space O(1)
12492
+ * @example
12493
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12494
+ * map.higher(10); // [20, ['b']]
12495
+ * map.higher(15); // [20, ['b']]
12569
12496
  */
12570
- constructor(keysNodesEntriesOrRaws = [], options) {
12571
- super([], options);
12572
- __publicField(this, "_count", 0);
12573
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
12497
+ higher(key) {
12498
+ this._validateKey(key);
12499
+ const k = __privateGet(this, _core2).higher(key);
12500
+ if (k === void 0) return void 0;
12501
+ const b = this.get(k);
12502
+ return b === void 0 ? void 0 : [k, b];
12574
12503
  }
12575
12504
  /**
12576
- * Get the total aggregate count across all nodes.
12577
- * @remarks Time O(1), Space O(1)
12578
- * @returns Total count.
12505
+ * Returns the entry with the largest key < given key.
12506
+ * @remarks Time O(log n), Space O(1)
12507
+ * @example
12508
+ * const map = new TreeMultiMap([[10, ['a']], [20, ['b']], [30, ['c']]]);
12509
+ * map.lower(20); // [10, ['a']]
12510
+ * map.lower(15); // [10, ['a']]
12579
12511
  */
12580
- get count() {
12581
- return this._count;
12512
+ lower(key) {
12513
+ this._validateKey(key);
12514
+ const k = __privateGet(this, _core2).lower(key);
12515
+ if (k === void 0) return void 0;
12516
+ const b = this.get(k);
12517
+ return b === void 0 ? void 0 : [k, b];
12582
12518
  }
12519
+ // ━━━ Tree utilities ━━━
12583
12520
  /**
12584
- * Compute the total count by traversing the tree (sums node.count).
12585
- * @remarks Time O(N), Space O(H)
12586
- * @returns Total count recomputed from nodes.
12521
+ * Prints the internal tree structure (for debugging).
12522
+ * @remarks Time O(n), Space O(n)
12587
12523
  */
12588
- getComputedCount() {
12589
- let sum = 0;
12590
- this.dfs((node) => sum += node ? node.count : 0);
12591
- return sum;
12524
+ print(...args) {
12525
+ return __privateGet(this, _core2).print(...args);
12592
12526
  }
12593
- createNode(key, value, color = "BLACK", count) {
12594
- return new TreeCounterNode(key, this._isMapMode ? void 0 : value, count, color);
12527
+ /**
12528
+ * Executes a callback for each entry.
12529
+ * @remarks Time O(n), Space O(1)
12530
+ */
12531
+ forEach(callback) {
12532
+ for (const [k, v] of this) {
12533
+ callback(v, k, this);
12534
+ }
12595
12535
  }
12596
12536
  /**
12597
- * Type guard: check whether the input is a TreeCounterNode.
12598
- * @remarks Time O(1), Space O(1)
12599
- * @returns True if the value is a TreeCounterNode.
12537
+ * Creates a new map with entries that pass the predicate.
12538
+ * @remarks Time O(n), Space O(n)
12600
12539
  */
12601
- isNode(keyNodeOrEntry) {
12602
- return keyNodeOrEntry instanceof TreeCounterNode;
12540
+ filter(predicate) {
12541
+ const filtered = [];
12542
+ for (const [k, v] of this) {
12543
+ if (predicate(v, k, this)) filtered.push([k, v]);
12544
+ }
12545
+ return new _TreeMultiMap(filtered, { comparator: this.comparator });
12603
12546
  }
12604
12547
  /**
12605
- * Insert or increment a node and update aggregate count.
12606
- * @remarks Time O(log N), Space O(1)
12607
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
12608
- * @param [value] - Value when a bare key is provided (ignored in map mode).
12609
- * @param [count] - How much to increase the node's count (default 1).
12610
- * @returns True if inserted/updated; false if ignored.
12611
- */
12612
- set(keyNodeOrEntry, value, count = 1) {
12613
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
12614
- const orgCount = (newNode == null ? void 0 : newNode.count) || 0;
12615
- const isSuccessAdded = super.set(newNode, newValue);
12616
- if (isSuccessAdded) {
12617
- this._count += orgCount;
12618
- return true;
12619
- } else {
12620
- return false;
12548
+ * Creates a new map by transforming each entry.
12549
+ * @remarks Time O(n log n), Space O(n)
12550
+ */
12551
+ map(mapper) {
12552
+ const mapped = [];
12553
+ for (const [k, v] of this) {
12554
+ mapped.push(mapper(v, k, this));
12621
12555
  }
12556
+ return new _TreeMultiMap(mapped, { comparator: this.comparator });
12622
12557
  }
12623
12558
  /**
12624
- * Delete a node (or decrement its count) and rebalance if needed.
12625
- * @remarks Time O(log N), Space O(1)
12626
- * @param keyNodeEntryRawOrPredicate - Key, node, or [key, value] entry identifying the node.
12627
- * @param [ignoreCount] - If true, remove the node regardless of its count.
12628
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
12559
+ * Reduces all entries to a single value.
12560
+ * @remarks Time O(n), Space O(1)
12629
12561
  */
12630
- delete(keyNodeEntryRawOrPredicate, ignoreCount = false) {
12631
- if (keyNodeEntryRawOrPredicate === null) return [];
12562
+ reduce(callback, initialValue) {
12563
+ let acc = initialValue;
12564
+ for (const [k, v] of this) {
12565
+ acc = callback(acc, v, k, this);
12566
+ }
12567
+ return acc;
12568
+ }
12569
+ /**
12570
+ * Sets multiple entries at once.
12571
+ * @remarks Time O(m log n), Space O(m) where m is input size
12572
+ */
12573
+ setMany(keysNodesEntriesOrRaws) {
12632
12574
  const results = [];
12633
- let nodeToDelete;
12634
- if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);
12635
- else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);
12636
- if (!nodeToDelete) {
12637
- return results;
12575
+ for (const x of keysNodesEntriesOrRaws) {
12576
+ results.push(this.set(x, void 0));
12638
12577
  }
12639
- let originalColor = nodeToDelete.color;
12640
- let replacementNode;
12641
- if (!this.isRealNode(nodeToDelete.left)) {
12642
- if (nodeToDelete.right !== null) replacementNode = nodeToDelete.right;
12643
- if (ignoreCount || nodeToDelete.count <= 1) {
12644
- if (nodeToDelete.right !== null) {
12645
- this._transplant(nodeToDelete, nodeToDelete.right);
12646
- this._count -= nodeToDelete.count;
12647
- }
12648
- } else {
12649
- nodeToDelete.count--;
12650
- this._count--;
12651
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12652
- return results;
12653
- }
12654
- } else if (!this.isRealNode(nodeToDelete.right)) {
12655
- replacementNode = nodeToDelete.left;
12656
- if (ignoreCount || nodeToDelete.count <= 1) {
12657
- this._transplant(nodeToDelete, nodeToDelete.left);
12658
- this._count -= nodeToDelete.count;
12659
- } else {
12660
- nodeToDelete.count--;
12661
- this._count--;
12662
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12663
- return results;
12664
- }
12665
- } else {
12666
- const successor = this.getLeftMost((node) => node, nodeToDelete.right);
12667
- if (successor) {
12668
- originalColor = successor.color;
12669
- if (successor.right !== null) replacementNode = successor.right;
12670
- if (successor.parent === nodeToDelete) {
12671
- if (this.isRealNode(replacementNode)) {
12672
- replacementNode.parent = successor;
12673
- }
12674
- } else {
12675
- if (ignoreCount || nodeToDelete.count <= 1) {
12676
- if (successor.right !== null) {
12677
- this._transplant(successor, successor.right);
12678
- }
12679
- } else {
12680
- nodeToDelete.count--;
12681
- this._count--;
12682
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12683
- return results;
12684
- }
12685
- successor.right = nodeToDelete.right;
12686
- if (this.isRealNode(successor.right)) {
12687
- successor.right.parent = successor;
12688
- }
12689
- }
12690
- if (ignoreCount || nodeToDelete.count <= 1) {
12691
- this._transplant(nodeToDelete, successor);
12692
- this._count -= nodeToDelete.count;
12693
- } else {
12694
- nodeToDelete.count--;
12695
- this._count--;
12696
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12697
- return results;
12698
- }
12699
- successor.left = nodeToDelete.left;
12700
- if (this.isRealNode(successor.left)) {
12701
- successor.left.parent = successor;
12702
- }
12703
- successor.color = nodeToDelete.color;
12578
+ return results;
12579
+ }
12580
+ /**
12581
+ * Searches for entries within a key range.
12582
+ * @remarks Time O(log n + k), Space O(k) where k is result size
12583
+ */
12584
+ rangeSearch(range, callback, isBalanced) {
12585
+ return __privateGet(this, _core2).rangeSearch(range, callback, isBalanced);
12586
+ }
12587
+ /**
12588
+ * Creates a shallow clone of this map.
12589
+ * @remarks Time O(n log n), Space O(n)
12590
+ */
12591
+ clone() {
12592
+ return new _TreeMultiMap(this, { comparator: this.comparator, isMapMode: __privateGet(this, _core2)._isMapMode });
12593
+ }
12594
+ /**
12595
+ * Expose comparator for advanced usage/testing (read-only).
12596
+ * @remarks Time O(1), Space O(1)
12597
+ */
12598
+ get comparator() {
12599
+ return __privateGet(this, _core2)._comparator;
12600
+ }
12601
+ };
12602
+ _core2 = new WeakMap();
12603
+ _isDefaultComparator2 = new WeakMap();
12604
+ __name(_TreeMultiMap, "TreeMultiMap");
12605
+ var TreeMultiMap = _TreeMultiMap;
12606
+
12607
+ // src/data-structures/binary-tree/tree-map.ts
12608
+ var _core3, _isDefaultComparator3, _userComparator2;
12609
+ var _TreeMap = class _TreeMap {
12610
+ /**
12611
+ * Create a TreeMap from an iterable of `[key, value]` entries.
12612
+ *
12613
+ * @throws {TypeError} If any entry is not a 2-tuple-like value, or when using the default comparator
12614
+ * and encountering unsupported/invalid keys (e.g. `NaN`, invalid `Date`).
12615
+ */
12616
+ constructor(entries = [], options = {}) {
12617
+ __privateAdd(this, _core3);
12618
+ __privateAdd(this, _isDefaultComparator3);
12619
+ __privateAdd(this, _userComparator2);
12620
+ var _a;
12621
+ __privateSet(this, _userComparator2, options.comparator);
12622
+ const comparator = (_a = options.comparator) != null ? _a : _TreeMap.createDefaultComparator();
12623
+ __privateSet(this, _isDefaultComparator3, options.comparator === void 0);
12624
+ __privateSet(this, _core3, 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");
12704
12628
  }
12629
+ const k = item[0];
12630
+ const v = item[1];
12631
+ this.set(k, v);
12705
12632
  }
12706
- this._size--;
12707
- if (originalColor === "BLACK") {
12708
- this._deleteFixup(replacementNode);
12633
+ }
12634
+ /**
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.
12643
+ */
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 (!__privateGet(this, _isDefaultComparator3)) return;
12666
+ if (typeof key === "number") {
12667
+ if (Number.isNaN(key)) throw new TypeError("TreeMap: NaN is not a valid key");
12668
+ return;
12709
12669
  }
12710
- results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12711
- return results;
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;
12674
+ }
12675
+ throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
12712
12676
  }
12713
12677
  /**
12714
- * Remove all nodes and reset aggregate counters.
12715
- * @remarks Time O(N), Space O(1)
12716
- * @returns void
12678
+ * Number of entries in the map.
12679
+ */
12680
+ get size() {
12681
+ return __privateGet(this, _core3).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
+ __privateGet(this, _core3).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 __privateGet(this, _core3).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 __privateGet(this, _core3).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
+ var _a;
12721
+ this._validateKey(key);
12722
+ const res = __privateGet(this, _core3).delete(key);
12723
+ return Array.isArray(res) && res.length > 0 && !!((_a = res[0]) == null ? void 0 : _a.deleted);
12724
+ }
12725
+ /**
12726
+ * Remove all entries.
12717
12727
  */
12718
12728
  clear() {
12719
- super.clear();
12720
- this._count = 0;
12729
+ __privateGet(this, _core3).clear();
12721
12730
  }
12722
12731
  /**
12723
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
12724
- * @remarks Time O(N), Space O(N)
12725
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
12726
- * @returns True if rebalancing succeeded (tree not empty).
12732
+ * Iterate over keys in ascending order.
12727
12733
  */
12728
- perfectlyBalance(iterationType = this.iterationType) {
12729
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
12730
- const n = nodes.length;
12731
- if (n < 1) return false;
12732
- let total = 0;
12733
- for (const nd of nodes) total += nd ? nd.count : 0;
12734
- this._clearNodes();
12735
- const build = /* @__PURE__ */ __name((l, r, parent) => {
12736
- if (l > r) return void 0;
12737
- const m = l + (r - l >> 1);
12738
- const root = nodes[m];
12739
- const leftChild = build(l, m - 1, root);
12740
- const rightChild = build(m + 1, r, root);
12741
- root.left = leftChild;
12742
- root.right = rightChild;
12743
- root.parent = parent;
12744
- return root;
12745
- }, "build");
12746
- const newRoot = build(0, n - 1, void 0);
12747
- this._setRoot(newRoot);
12748
- this._size = n;
12749
- this._count = total;
12750
- return true;
12734
+ keys() {
12735
+ return __privateGet(this, _core3).keys();
12736
+ }
12737
+ _entryFromKey(k) {
12738
+ return [k, __privateGet(this, _core3).get(k)];
12751
12739
  }
12752
12740
  /**
12753
- * Create a new TreeCounter by mapping each [key, value] entry.
12754
- * @remarks Time O(N log N), Space O(N)
12755
- * @template MK
12756
- * @template MV
12757
- * @template MR
12758
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
12759
- * @param [options] - Options for the output tree.
12760
- * @param [thisArg] - Value for `this` inside the callback.
12761
- * @returns A new TreeCounter with mapped entries.
12741
+ * Iterate over values in ascending key order.
12742
+ *
12743
+ * Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
12762
12744
  */
12763
- map(callback, options, thisArg) {
12764
- const out = this._createLike([], options);
12745
+ *values() {
12746
+ for (const k of this.keys()) yield this._entryFromKey(k)[1];
12747
+ }
12748
+ /**
12749
+ * Iterate over `[key, value]` entries in ascending key order.
12750
+ *
12751
+ * Note: values may be `undefined`.
12752
+ */
12753
+ *entries() {
12754
+ for (const k of this.keys()) yield this._entryFromKey(k);
12755
+ }
12756
+ [Symbol.iterator]() {
12757
+ return this.entries();
12758
+ }
12759
+ /**
12760
+ * Visit each entry in ascending key order.
12761
+ *
12762
+ * Note: callback value may be `undefined`.
12763
+ */
12764
+ forEach(cb, thisArg) {
12765
+ for (const [k, v] of this) cb.call(thisArg, v, k, this);
12766
+ }
12767
+ /**
12768
+ * Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
12769
+ *
12770
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
12771
+ * @remarks Time O(n log n) expected, Space O(n)
12772
+ */
12773
+ map(callbackfn, options = {}, thisArg) {
12774
+ const out = new _TreeMap([], options);
12765
12775
  let index = 0;
12766
- for (const [key, value] of this) {
12767
- out.set(callback.call(thisArg, value, key, index++, this));
12776
+ for (const [k, v] of this) {
12777
+ const [mk, mv] = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12778
+ out.set(mk, mv);
12768
12779
  }
12769
12780
  return out;
12770
12781
  }
12771
12782
  /**
12772
- * Deep copy this tree, preserving map mode and aggregate counts.
12773
- * @remarks Time O(N), Space O(N)
12774
- * @returns A deep copy of this tree.
12783
+ * Create a new TreeMap containing only entries that satisfy the predicate.
12784
+ * @remarks Time O(n log n) expected, Space O(n)
12775
12785
  */
12776
- clone() {
12777
- const out = this._createInstance();
12778
- this._clone(out);
12779
- out._count = this._count;
12780
- for (const node of this.dfs((n) => n, "IN")) {
12781
- if (!node) continue;
12782
- const outNode = out.getNode(node.key);
12783
- if (outNode) outNode.count = node.count;
12786
+ filter(callbackfn, thisArg) {
12787
+ const out = new _TreeMap([], { comparator: __privateGet(this, _userComparator2) });
12788
+ let index = 0;
12789
+ for (const [k, v] of this) {
12790
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12791
+ if (ok) out.set(k, v);
12784
12792
  }
12785
12793
  return out;
12786
12794
  }
12787
12795
  /**
12788
- * (Protected) Create an empty instance of the same concrete class.
12789
- * @remarks Time O(1), Space O(1)
12790
- * @template TK
12791
- * @template TV
12792
- * @template TR
12793
- * @param [options] - Optional constructor options for the like-kind instance.
12794
- * @returns An empty like-kind instance.
12796
+ * Reduce entries into a single accumulator.
12797
+ * @remarks Time O(n), Space O(1)
12795
12798
  */
12796
- _createInstance(options) {
12797
- const Ctor = this.constructor;
12798
- return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });
12799
+ reduce(callbackfn, initialValue) {
12800
+ let acc = initialValue;
12801
+ let index = 0;
12802
+ for (const [k, v] of this) acc = callbackfn(acc, v, k, index++, this);
12803
+ return acc;
12799
12804
  }
12800
12805
  /**
12801
- * (Protected) Create a like-kind instance and seed it from an iterable.
12802
- * @remarks Time O(N log N), Space O(N)
12803
- * @template TK
12804
- * @template TV
12805
- * @template TR
12806
- * @param iter - Iterable used to seed the new tree.
12807
- * @param [options] - Options merged with the current snapshot.
12808
- * @returns A like-kind TreeCounter built from the iterable.
12806
+ * Test whether all entries satisfy a predicate.
12807
+ * @remarks Time O(n), Space O(1)
12809
12808
  */
12810
- _createLike(iter = [], options) {
12811
- const Ctor = this.constructor;
12812
- return new Ctor(iter, {
12813
- ...this._snapshotOptions(),
12814
- ...options != null ? options : {}
12815
- });
12809
+ every(callbackfn, thisArg) {
12810
+ let index = 0;
12811
+ for (const [k, v] of this) {
12812
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12813
+ if (!ok) return false;
12814
+ }
12815
+ return true;
12816
12816
  }
12817
12817
  /**
12818
- * (Protected) Normalize input into a node plus its effective value and count.
12819
- * @remarks Time O(1), Space O(1)
12820
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
12821
- * @param [value] - Value used when a bare key is provided.
12822
- * @param [count] - Count increment to apply (default 1).
12823
- * @returns Tuple [node, value] where node may be undefined.
12818
+ * Test whether any entry satisfies a predicate.
12819
+ * @remarks Time O(n), Space O(1)
12824
12820
  */
12825
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
12826
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
12827
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
12828
- if (this.isEntry(keyNodeOrEntry)) {
12829
- const [key, entryValue] = keyNodeOrEntry;
12830
- if (key === void 0 || key === null) return [void 0, void 0];
12831
- const finalValue = value != null ? value : entryValue;
12832
- return [this.createNode(key, finalValue, "BLACK", count), finalValue];
12821
+ some(callbackfn, thisArg) {
12822
+ let index = 0;
12823
+ for (const [k, v] of this) {
12824
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12825
+ if (ok) return true;
12833
12826
  }
12834
- return [this.createNode(keyNodeOrEntry, value, "BLACK", count), value];
12827
+ return false;
12835
12828
  }
12836
12829
  /**
12837
- * (Protected) Swap keys/values/counters between the source and destination nodes.
12838
- * @remarks Time O(1), Space O(1)
12839
- * @param srcNode - Source node (or key) whose properties will be moved.
12840
- * @param destNode - Destination node (or key) to receive properties.
12841
- * @returns Destination node after swap, or undefined.
12830
+ * Find the first entry that satisfies a predicate.
12831
+ * @returns The first matching `[key, value]` tuple, or `undefined`.
12832
+ * @remarks Time O(n), Space O(1)
12842
12833
  */
12843
- _swapProperties(srcNode, destNode) {
12844
- srcNode = this.ensureNode(srcNode);
12845
- destNode = this.ensureNode(destNode);
12846
- if (srcNode && destNode) {
12847
- const { key, value, count, color } = destNode;
12848
- const tempNode = this.createNode(key, value, color, count);
12849
- if (tempNode) {
12850
- tempNode.color = color;
12851
- destNode.key = srcNode.key;
12852
- if (!this._isMapMode) destNode.value = srcNode.value;
12853
- destNode.count = srcNode.count;
12854
- destNode.color = srcNode.color;
12855
- srcNode.key = tempNode.key;
12856
- if (!this._isMapMode) srcNode.value = tempNode.value;
12857
- srcNode.count = tempNode.count;
12858
- srcNode.color = tempNode.color;
12859
- }
12860
- return destNode;
12834
+ find(callbackfn, thisArg) {
12835
+ let index = 0;
12836
+ for (const [k, v] of this) {
12837
+ const ok = thisArg === void 0 ? callbackfn(v, k, index++, this) : callbackfn.call(thisArg, v, k, index++, this);
12838
+ if (ok) return [k, v];
12861
12839
  }
12862
12840
  return void 0;
12863
12841
  }
12864
12842
  /**
12865
- * (Protected) Replace one node by another and adjust counters accordingly.
12866
- * @remarks Time O(1), Space O(1)
12867
- * @param oldNode - Node being replaced.
12868
- * @param newNode - Replacement node.
12869
- * @returns The new node after replacement.
12843
+ * Materialize the map into an array of `[key, value]` tuples.
12844
+ * @remarks Time O(n), Space O(n)
12870
12845
  */
12871
- _replaceNode(oldNode, newNode) {
12872
- newNode.count = oldNode.count + newNode.count;
12873
- return super._replaceNode(oldNode, newNode);
12846
+ toArray() {
12847
+ return [...this];
12848
+ }
12849
+ /**
12850
+ * Print a human-friendly representation.
12851
+ * @remarks Time O(n), Space O(n)
12852
+ */
12853
+ print() {
12854
+ __privateGet(this, _core3).print();
12855
+ }
12856
+ // Navigable operations (return entry tuples)
12857
+ // Note: returned tuple values may be `undefined`.
12858
+ /**
12859
+ * Smallest entry by key.
12860
+ */
12861
+ first() {
12862
+ const k = __privateGet(this, _core3).getLeftMost();
12863
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12864
+ }
12865
+ /**
12866
+ * Largest entry by key.
12867
+ */
12868
+ last() {
12869
+ const k = __privateGet(this, _core3).getRightMost();
12870
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12871
+ }
12872
+ /**
12873
+ * Remove and return the smallest entry.
12874
+ */
12875
+ pollFirst() {
12876
+ const entry = this.first();
12877
+ if (!entry) return void 0;
12878
+ this.delete(entry[0]);
12879
+ return entry;
12880
+ }
12881
+ /**
12882
+ * Remove and return the largest entry.
12883
+ */
12884
+ pollLast() {
12885
+ const entry = this.last();
12886
+ if (!entry) return void 0;
12887
+ this.delete(entry[0]);
12888
+ return entry;
12889
+ }
12890
+ /**
12891
+ * Smallest entry whose key is >= the given key.
12892
+ */
12893
+ ceiling(key) {
12894
+ this._validateKey(key);
12895
+ const k = __privateGet(this, _core3).ceiling(key);
12896
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12897
+ }
12898
+ /**
12899
+ * Largest entry whose key is <= the given key.
12900
+ */
12901
+ floor(key) {
12902
+ this._validateKey(key);
12903
+ const k = __privateGet(this, _core3).floor(key);
12904
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12905
+ }
12906
+ /**
12907
+ * Smallest entry whose key is > the given key.
12908
+ */
12909
+ higher(key) {
12910
+ this._validateKey(key);
12911
+ const k = __privateGet(this, _core3).higher(key);
12912
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12913
+ }
12914
+ /**
12915
+ * Largest entry whose key is < the given key.
12916
+ */
12917
+ lower(key) {
12918
+ this._validateKey(key);
12919
+ const k = __privateGet(this, _core3).lower(key);
12920
+ return k === void 0 ? void 0 : this._entryFromKey(k);
12921
+ }
12922
+ /**
12923
+ * Return all entries in a given key range.
12924
+ *
12925
+ * @param range `[low, high]`
12926
+ * @param options Inclusive/exclusive bounds (defaults to inclusive).
12927
+ */
12928
+ rangeSearch(range, options = {}) {
12929
+ const { lowInclusive = true, highInclusive = true } = options;
12930
+ const [low, high] = range;
12931
+ this._validateKey(low);
12932
+ this._validateKey(high);
12933
+ const keys = __privateGet(this, _core3).rangeSearch([low, high]);
12934
+ const out = [];
12935
+ const cmp = __privateGet(this, _core3).comparator;
12936
+ for (const k of keys) {
12937
+ if (k === void 0) continue;
12938
+ if (!lowInclusive && cmp(k, low) === 0) continue;
12939
+ if (!highInclusive && cmp(k, high) === 0) continue;
12940
+ out.push(this._entryFromKey(k));
12941
+ }
12942
+ return out;
12874
12943
  }
12875
12944
  };
12876
- __name(_TreeCounter, "TreeCounter");
12877
- var TreeCounter = _TreeCounter;
12945
+ _core3 = new WeakMap();
12946
+ _isDefaultComparator3 = new WeakMap();
12947
+ _userComparator2 = new WeakMap();
12948
+ __name(_TreeMap, "TreeMap");
12949
+ var TreeMap = _TreeMap;
12878
12950
 
12879
- // src/data-structures/binary-tree/avl-tree-counter.ts
12880
- var _AVLTreeCounterNode = class _AVLTreeCounterNode {
12951
+ // src/data-structures/binary-tree/tree-multi-set.ts
12952
+ var _core4, _isDefaultComparator4;
12953
+ var _TreeMultiSet = class _TreeMultiSet {
12954
+ // total occurrences (sumCounts)
12955
+ /**
12956
+ * Creates a new TreeMultiSet.
12957
+ * @param elements - Initial elements to add
12958
+ * @param options - Configuration options
12959
+ * @remarks Time O(m log m), Space O(m) where m is the number of initial elements
12960
+ */
12961
+ constructor(elements = [], options = {}) {
12962
+ __privateAdd(this, _core4);
12963
+ __privateAdd(this, _isDefaultComparator4);
12964
+ __publicField(this, "_size", 0);
12965
+ var _a;
12966
+ const comparator = (_a = options.comparator) != null ? _a : TreeSet.createDefaultComparator();
12967
+ __privateSet(this, _isDefaultComparator4, options.comparator === void 0);
12968
+ __privateSet(this, _core4, new RedBlackTree([], { comparator, isMapMode: options.isMapMode }));
12969
+ for (const k of elements) this.add(k);
12970
+ }
12881
12971
  /**
12882
- * Create an AVL counter node.
12972
+ * Validates the key against the default comparator rules.
12883
12973
  * @remarks Time O(1), Space O(1)
12884
- * @param key - Key of the node.
12885
- * @param [value] - Associated value (ignored in map mode).
12886
- * @param [count] - Initial count for this node (default 1).
12887
- * @returns New AVLTreeCounterNode instance.
12888
12974
  */
12889
- constructor(key, value, count = 1) {
12890
- __publicField(this, "key");
12891
- __publicField(this, "value");
12892
- __publicField(this, "parent");
12893
- __publicField(this, "_left");
12894
- __publicField(this, "_right");
12895
- __publicField(this, "_height", 0);
12896
- __publicField(this, "_color", "BLACK");
12897
- __publicField(this, "_count", 1);
12898
- this.key = key;
12899
- this.value = value;
12900
- this.count = count;
12975
+ _validateKey(key) {
12976
+ if (!__privateGet(this, _isDefaultComparator4)) return;
12977
+ if (typeof key === "number") {
12978
+ if (Number.isNaN(key)) throw new TypeError("TreeMultiSet: NaN is not a valid key");
12979
+ return;
12980
+ }
12981
+ if (typeof key === "string") return;
12982
+ if (key instanceof Date) {
12983
+ if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiSet: invalid Date key");
12984
+ return;
12985
+ }
12986
+ throw new TypeError("TreeMultiSet: comparator is required for non-number/non-string/non-Date keys");
12987
+ }
12988
+ /**
12989
+ * Validates that count is a non-negative safe integer.
12990
+ * @remarks Time O(1), Space O(1)
12991
+ */
12992
+ _validateCount(n) {
12993
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError("TreeMultiSet: count must be a safe integer >= 0");
12901
12994
  }
12902
12995
  /**
12903
- * Get the left child pointer.
12996
+ * Total occurrences (sumCounts).
12904
12997
  * @remarks Time O(1), Space O(1)
12905
- * @returns Left child node, or null/undefined.
12906
12998
  */
12907
- get left() {
12908
- return this._left;
12999
+ get size() {
13000
+ return this._size;
12909
13001
  }
12910
13002
  /**
12911
- * Set the left child and update its parent pointer.
13003
+ * Number of distinct keys.
12912
13004
  * @remarks Time O(1), Space O(1)
12913
- * @param v - New left child node, or null/undefined.
12914
- * @returns void
12915
13005
  */
12916
- set left(v) {
12917
- if (v) {
12918
- v.parent = this;
12919
- }
12920
- this._left = v;
13006
+ get distinctSize() {
13007
+ return __privateGet(this, _core4).size;
12921
13008
  }
12922
13009
  /**
12923
- * Get the right child pointer.
13010
+ * Whether the multiset is empty.
12924
13011
  * @remarks Time O(1), Space O(1)
12925
- * @returns Right child node, or null/undefined.
12926
13012
  */
12927
- get right() {
12928
- return this._right;
13013
+ isEmpty() {
13014
+ return this.size === 0;
12929
13015
  }
12930
13016
  /**
12931
- * Set the right child and update its parent pointer.
12932
- * @remarks Time O(1), Space O(1)
12933
- * @param v - New right child node, or null/undefined.
12934
- * @returns void
13017
+ * Whether the multiset contains the given key.
13018
+ * @remarks Time O(log n), Space O(1)
12935
13019
  */
12936
- set right(v) {
12937
- if (v) {
12938
- v.parent = this;
12939
- }
12940
- this._right = v;
13020
+ has(key) {
13021
+ this._validateKey(key);
13022
+ return this.count(key) > 0;
12941
13023
  }
12942
13024
  /**
12943
- * Gets the height of the node (used in self-balancing trees).
12944
- * @remarks Time O(1), Space O(1)
12945
- *
12946
- * @returns The height.
13025
+ * Returns the count of occurrences for the given key.
13026
+ * @remarks Time O(log n), Space O(1)
12947
13027
  */
12948
- get height() {
12949
- return this._height;
13028
+ count(key) {
13029
+ var _a;
13030
+ this._validateKey(key);
13031
+ return (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;
12950
13032
  }
12951
13033
  /**
12952
- * Sets the height of the node.
12953
- * @remarks Time O(1), Space O(1)
12954
- *
12955
- * @param value - The new height.
13034
+ * Add `n` occurrences of `key`.
13035
+ * @returns True if the multiset changed.
13036
+ * @remarks Time O(log n), Space O(1)
12956
13037
  */
12957
- set height(value) {
12958
- this._height = value;
13038
+ add(key, n = 1) {
13039
+ var _a;
13040
+ this._validateKey(key);
13041
+ this._validateCount(n);
13042
+ if (n === 0) return false;
13043
+ const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;
13044
+ const next = old + n;
13045
+ __privateGet(this, _core4).set(key, next);
13046
+ this._size += n;
13047
+ return true;
12959
13048
  }
12960
13049
  /**
12961
- * Gets the color of the node (used in Red-Black trees).
12962
- * @remarks Time O(1), Space O(1)
12963
- *
12964
- * @returns The node's color.
13050
+ * Set count for `key` to exactly `n`.
13051
+ * @returns True if changed.
13052
+ * @remarks Time O(log n), Space O(1)
12965
13053
  */
12966
- get color() {
12967
- return this._color;
13054
+ setCount(key, n) {
13055
+ var _a;
13056
+ this._validateKey(key);
13057
+ this._validateCount(n);
13058
+ const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;
13059
+ if (old === n) return false;
13060
+ if (n === 0) {
13061
+ if (old !== 0) __privateGet(this, _core4).delete(key);
13062
+ } else {
13063
+ __privateGet(this, _core4).set(key, n);
13064
+ }
13065
+ this._size += n - old;
13066
+ return true;
12968
13067
  }
12969
13068
  /**
12970
- * Sets the color of the node.
12971
- * @remarks Time O(1), Space O(1)
12972
- *
12973
- * @param value - The new color.
13069
+ * Delete `n` occurrences of `key` (default 1).
13070
+ * @returns True if any occurrence was removed.
13071
+ * @remarks Time O(log n), Space O(1)
12974
13072
  */
12975
- set color(value) {
12976
- this._color = value;
13073
+ delete(key, n = 1) {
13074
+ var _a;
13075
+ this._validateKey(key);
13076
+ this._validateCount(n);
13077
+ if (n === 0) return false;
13078
+ const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;
13079
+ if (old === 0) return false;
13080
+ const removed = Math.min(old, n);
13081
+ const next = old - removed;
13082
+ if (next === 0) __privateGet(this, _core4).delete(key);
13083
+ else __privateGet(this, _core4).set(key, next);
13084
+ this._size -= removed;
13085
+ return true;
12977
13086
  }
12978
13087
  /**
12979
- * Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).
12980
- * @remarks Time O(1), Space O(1)
12981
- *
12982
- * @returns The subtree node count.
13088
+ * Delete all occurrences of the given key.
13089
+ * @returns True if any occurrence was removed.
13090
+ * @remarks Time O(log n), Space O(1)
12983
13091
  */
12984
- get count() {
12985
- return this._count;
13092
+ deleteAll(key) {
13093
+ var _a;
13094
+ this._validateKey(key);
13095
+ const old = (_a = __privateGet(this, _core4).get(key)) != null ? _a : 0;
13096
+ if (old === 0) return false;
13097
+ __privateGet(this, _core4).delete(key);
13098
+ this._size -= old;
13099
+ return true;
12986
13100
  }
12987
13101
  /**
12988
- * Sets the count of nodes in the subtree.
12989
- * @remarks Time O(1), Space O(1)
12990
- *
12991
- * @param value - The new count.
13102
+ * Iterates over distinct keys (each key yielded once).
13103
+ * @remarks Time O(n), Space O(1)
12992
13104
  */
12993
- set count(value) {
12994
- this._count = value;
13105
+ *keysDistinct() {
13106
+ yield* __privateGet(this, _core4).keys();
12995
13107
  }
12996
13108
  /**
12997
- * Gets the position of the node relative to its parent.
12998
- * @remarks Time O(1), Space O(1)
12999
- *
13000
- * @returns The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').
13109
+ * Iterates over entries as [key, count] pairs.
13110
+ * @remarks Time O(n), Space O(1)
13001
13111
  */
13002
- get familyPosition() {
13003
- if (!this.parent) {
13004
- return this.left || this.right ? "ROOT" : "ISOLATED";
13112
+ *entries() {
13113
+ for (const [k, v] of __privateGet(this, _core4)) {
13114
+ yield [k, v != null ? v : 0];
13005
13115
  }
13006
- if (this.parent.left === this) {
13007
- return this.left || this.right ? "ROOT_LEFT" : "LEFT";
13008
- } else if (this.parent.right === this) {
13009
- return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
13116
+ }
13117
+ /**
13118
+ * Expanded iteration (default). Each key is yielded `count(key)` times.
13119
+ * @remarks Time O(size), Space O(1) where size is total occurrences
13120
+ */
13121
+ *[Symbol.iterator]() {
13122
+ for (const [k, c] of this.entries()) {
13123
+ for (let i = 0; i < c; i++) yield k;
13010
13124
  }
13011
- return "MAL_NODE";
13012
13125
  }
13013
- };
13014
- __name(_AVLTreeCounterNode, "AVLTreeCounterNode");
13015
- var AVLTreeCounterNode = _AVLTreeCounterNode;
13016
- var _AVLTreeCounter = class _AVLTreeCounter extends AVLTree {
13017
13126
  /**
13018
- * Create a AVLTreeCounter instance
13019
- * @remarks Time O(n), Space O(n)
13020
- * @param keysNodesEntriesOrRaws
13021
- * @param options
13022
- * @returns New AVLTreeCounterNode instance.
13127
+ * Returns an array with all elements (expanded).
13128
+ * @remarks Time O(size), Space O(size)
13023
13129
  */
13024
- constructor(keysNodesEntriesOrRaws = [], options) {
13025
- super([], options);
13026
- __publicField(this, "_count", 0);
13027
- if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
13130
+ toArray() {
13131
+ return [...this];
13028
13132
  }
13029
- get count() {
13030
- return this._count;
13133
+ /**
13134
+ * Returns an array with distinct keys only.
13135
+ * @remarks Time O(n), Space O(n)
13136
+ */
13137
+ toDistinctArray() {
13138
+ return [...this.keysDistinct()];
13031
13139
  }
13032
13140
  /**
13033
- * Compute the total count by traversing the tree (sums node.count).
13034
- * @remarks Time O(N), Space O(H)
13035
- * @returns Total count recomputed from nodes.
13141
+ * Returns an array of [key, count] entries.
13142
+ * @remarks Time O(n), Space O(n)
13036
13143
  */
13037
- getComputedCount() {
13038
- let sum = 0;
13039
- this.dfs((node) => sum += node.count);
13040
- return sum;
13144
+ toEntries() {
13145
+ return [...this.entries()];
13041
13146
  }
13042
- createNode(key, value, count) {
13043
- return new AVLTreeCounterNode(key, this._isMapMode ? void 0 : value, count);
13147
+ /**
13148
+ * Expose comparator for advanced usage/testing (read-only).
13149
+ * @remarks Time O(1), Space O(1)
13150
+ */
13151
+ get comparator() {
13152
+ return __privateGet(this, _core4)._comparator;
13044
13153
  }
13154
+ // ━━━ clear ━━━
13045
13155
  /**
13046
- * Type guard: check whether the input is an AVLTreeCounterNode.
13156
+ * Remove all elements from the multiset.
13047
13157
  * @remarks Time O(1), Space O(1)
13048
- * @returns True if the value is an AVLTreeCounterNode.
13158
+ * @example
13159
+ * const ms = new TreeMultiSet([1, 2, 2, 3]);
13160
+ * ms.clear();
13161
+ * ms.size; // 0
13049
13162
  */
13050
- isNode(keyNodeOrEntry) {
13051
- return keyNodeOrEntry instanceof AVLTreeCounterNode;
13163
+ clear() {
13164
+ __privateGet(this, _core4).clear();
13165
+ this._size = 0;
13052
13166
  }
13167
+ // ━━━ Navigable methods ━━━
13053
13168
  /**
13054
- * Insert or increment a node and update aggregate count.
13055
- * @remarks Time O(log N), Space O(1)
13056
- * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
13057
- * @param [value] - Value when a bare key is provided (ignored in map mode).
13058
- * @param [count] - How much to increase the node's count (default 1).
13059
- * @returns True if inserted/updated; false if ignored.
13169
+ * Returns the smallest 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.first(); // 1
13060
13174
  */
13061
- set(keyNodeOrEntry, value, count = 1) {
13062
- const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
13063
- if (newNode === void 0) return false;
13064
- const orgNodeCount = (newNode == null ? void 0 : newNode.count) || 0;
13065
- const inserted = super.set(newNode, newValue);
13066
- if (inserted) {
13067
- this._count += orgNodeCount;
13068
- }
13069
- return true;
13175
+ first() {
13176
+ return __privateGet(this, _core4).getLeftMost();
13070
13177
  }
13071
13178
  /**
13072
- * Delete a node (or decrement its count) and rebalance if needed.
13073
- * @remarks Time O(log N), Space O(1)
13074
- * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
13075
- * @param [ignoreCount] - If true, remove the node regardless of its count.
13076
- * @returns Array of deletion results including deleted node and a rebalance hint when present.
13179
+ * Returns the largest key, or undefined if empty.
13180
+ * @remarks Time O(log n), Space O(1)
13181
+ * @example
13182
+ * const ms = new TreeMultiSet([3, 1, 4]);
13183
+ * ms.last(); // 4
13077
13184
  */
13078
- delete(keyNodeOrEntry, ignoreCount = false) {
13079
- var _a;
13080
- const deletedResult = [];
13081
- if (!this.root) return deletedResult;
13082
- const curr = (_a = this.getNode(keyNodeOrEntry)) != null ? _a : void 0;
13083
- if (!curr) return deletedResult;
13084
- const parent = (curr == null ? void 0 : curr.parent) ? curr.parent : void 0;
13085
- let needBalanced = void 0, orgCurrent = curr;
13086
- if (curr.count > 1 && !ignoreCount) {
13087
- curr.count--;
13088
- this._count--;
13089
- } else {
13090
- if (!curr.left) {
13091
- if (!parent) {
13092
- if (curr.right !== void 0 && curr.right !== null) this._setRoot(curr.right);
13093
- } else {
13094
- const { familyPosition: fp } = curr;
13095
- if (fp === "LEFT" || fp === "ROOT_LEFT") {
13096
- parent.left = curr.right;
13097
- } else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
13098
- parent.right = curr.right;
13099
- }
13100
- needBalanced = parent;
13101
- }
13102
- } else {
13103
- const leftSubTreeRightMost = curr.left ? this.getRightMost((node) => node, curr.left) : void 0;
13104
- if (leftSubTreeRightMost) {
13105
- const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
13106
- orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
13107
- if (parentOfLeftSubTreeMax) {
13108
- if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
13109
- parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
13110
- } else {
13111
- parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
13112
- }
13113
- needBalanced = parentOfLeftSubTreeMax;
13114
- }
13115
- }
13116
- }
13117
- this._size = this._size - 1;
13118
- if (orgCurrent) this._count -= orgCurrent.count;
13119
- }
13120
- deletedResult.push({ deleted: orgCurrent, needBalanced });
13121
- if (needBalanced) {
13122
- this._balancePath(needBalanced);
13123
- }
13124
- return deletedResult;
13185
+ last() {
13186
+ return __privateGet(this, _core4).getRightMost();
13125
13187
  }
13126
13188
  /**
13127
- * Remove all nodes and reset aggregate counters.
13128
- * @remarks Time O(N), Space O(1)
13129
- * @returns void
13189
+ * Removes all occurrences of the smallest key and returns it.
13190
+ * @remarks Time O(log n), Space O(1)
13191
+ * @example
13192
+ * const ms = new TreeMultiSet([1, 1, 2, 3]);
13193
+ * ms.pollFirst(); // 1
13194
+ * ms.has(1); // false
13130
13195
  */
13131
- clear() {
13132
- super.clear();
13133
- this._count = 0;
13196
+ pollFirst() {
13197
+ const key = this.first();
13198
+ if (key === void 0) return void 0;
13199
+ this.deleteAll(key);
13200
+ return key;
13134
13201
  }
13135
13202
  /**
13136
- * Rebuild the tree into a perfectly balanced form using in-order nodes.
13137
- * @remarks Time O(N), Space O(N)
13138
- * @param [iterationType] - Traversal style to use when constructing the balanced tree.
13139
- * @returns True if rebalancing succeeded (tree not empty).
13203
+ * Removes all occurrences of the largest key and returns it.
13204
+ * @remarks Time O(log n), Space O(1)
13205
+ * @example
13206
+ * const ms = new TreeMultiSet([1, 2, 3, 3]);
13207
+ * ms.pollLast(); // 3
13208
+ * ms.has(3); // false
13140
13209
  */
13141
- perfectlyBalance(iterationType = this.iterationType) {
13142
- const nodes = this.dfs((node) => node, "IN", false, this._root, iterationType);
13143
- const n = nodes.length;
13144
- if (n === 0) return false;
13145
- let total = 0;
13146
- for (const nd of nodes) total += nd ? nd.count : 0;
13147
- this._clearNodes();
13148
- const build = /* @__PURE__ */ __name((l, r, parent) => {
13149
- if (l > r) return void 0;
13150
- const m = l + (r - l >> 1);
13151
- const root = nodes[m];
13152
- root.left = build(l, m - 1, root);
13153
- root.right = build(m + 1, r, root);
13154
- root.parent = parent;
13155
- const lh = root.left ? root.left.height : -1;
13156
- const rh = root.right ? root.right.height : -1;
13157
- root.height = Math.max(lh, rh) + 1;
13158
- return root;
13159
- }, "build");
13160
- const newRoot = build(0, n - 1, void 0);
13161
- this._setRoot(newRoot);
13162
- this._size = n;
13163
- this._count = total;
13164
- return true;
13210
+ pollLast() {
13211
+ const key = this.last();
13212
+ if (key === void 0) return void 0;
13213
+ this.deleteAll(key);
13214
+ return key;
13165
13215
  }
13166
13216
  /**
13167
- * Deep copy this tree, preserving map mode and aggregate counts.
13168
- * @remarks Time O(N), Space O(N)
13169
- * @returns A deep copy of this tree.
13217
+ * Returns the smallest key >= given key, or undefined.
13218
+ * @remarks Time O(log n), Space O(1)
13219
+ * @example
13220
+ * const ms = new TreeMultiSet([10, 20, 30]);
13221
+ * ms.ceiling(15); // 20
13222
+ * ms.ceiling(20); // 20
13170
13223
  */
13171
- clone() {
13172
- const out = this._createInstance();
13173
- if (this._isMapMode) {
13174
- this.bfs((node) => out.set(node.key, void 0, node.count));
13175
- } else {
13176
- this.bfs((node) => out.set(node.key, node.value, node.count));
13177
- }
13178
- if (this._isMapMode) out._store = this._store;
13179
- return out;
13224
+ ceiling(key) {
13225
+ this._validateKey(key);
13226
+ return __privateGet(this, _core4).ceiling(key);
13180
13227
  }
13181
13228
  /**
13182
- * Create a new AVLTreeCounter by mapping each [key, value] entry.
13183
- * @remarks Time O(N log N), Space O(N)
13184
- * @template MK
13185
- * @template MV
13186
- * @template MR
13187
- * @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
13188
- * @param [options] - Options for the output tree.
13189
- * @param [thisArg] - Value for `this` inside the callback.
13190
- * @returns A new AVLTreeCounter with mapped entries.
13229
+ * Returns the largest key <= given key, or undefined.
13230
+ * @remarks Time O(log n), Space O(1)
13231
+ * @example
13232
+ * const ms = new TreeMultiSet([10, 20, 30]);
13233
+ * ms.floor(25); // 20
13234
+ * ms.floor(20); // 20
13191
13235
  */
13192
- map(callback, options, thisArg) {
13193
- const out = this._createLike([], options);
13194
- let index = 0;
13195
- for (const [key, value] of this) {
13196
- out.set(callback.call(thisArg, value, key, index++, this));
13197
- }
13198
- return out;
13236
+ floor(key) {
13237
+ this._validateKey(key);
13238
+ return __privateGet(this, _core4).floor(key);
13199
13239
  }
13200
13240
  /**
13201
- * (Protected) Create an empty instance of the same concrete class.
13202
- * @remarks Time O(1), Space O(1)
13203
- * @template TK
13204
- * @template TV
13205
- * @template TR
13206
- * @param [options] - Optional constructor options for the like-kind instance.
13207
- * @returns An empty like-kind instance.
13241
+ * Returns the smallest key > given key, or undefined.
13242
+ * @remarks Time O(log n), Space O(1)
13243
+ * @example
13244
+ * const ms = new TreeMultiSet([10, 20, 30]);
13245
+ * ms.higher(10); // 20
13246
+ * ms.higher(15); // 20
13208
13247
  */
13209
- _createInstance(options) {
13210
- const Ctor = this.constructor;
13211
- return new Ctor([], { ...this._snapshotOptions(), ...options != null ? options : {} });
13248
+ higher(key) {
13249
+ this._validateKey(key);
13250
+ return __privateGet(this, _core4).higher(key);
13212
13251
  }
13213
13252
  /**
13214
- * (Protected) Create a like-kind instance and seed it from an iterable.
13215
- * @remarks Time O(N log N), Space O(N)
13216
- * @template TK
13217
- * @template TV
13218
- * @template TR
13219
- * @param iter - Iterable used to seed the new tree.
13220
- * @param [options] - Options merged with the current snapshot.
13221
- * @returns A like-kind AVLTreeCounter built from the iterable.
13253
+ * Returns the largest key < given key, or undefined.
13254
+ * @remarks Time O(log n), Space O(1)
13255
+ * @example
13256
+ * const ms = new TreeMultiSet([10, 20, 30]);
13257
+ * ms.lower(20); // 10
13258
+ * ms.lower(15); // 10
13222
13259
  */
13223
- _createLike(iter = [], options) {
13224
- const Ctor = this.constructor;
13225
- return new Ctor(iter, { ...this._snapshotOptions(), ...options != null ? options : {} });
13260
+ lower(key) {
13261
+ this._validateKey(key);
13262
+ return __privateGet(this, _core4).lower(key);
13226
13263
  }
13264
+ // ━━━ Functional methods ━━━
13227
13265
  /**
13228
- * (Protected) Normalize input into a node plus its effective value and count.
13229
- * @remarks Time O(1), Space O(1)
13230
- * @param keyNodeOrEntry - Key, node, or [key, value] entry.
13231
- * @param [value] - Value used when a bare key is provided.
13232
- * @param [count] - Count increment to apply (default 1).
13233
- * @returns Tuple [node, value] where node may be undefined.
13266
+ * Iterates over distinct keys with their counts.
13267
+ * @remarks Time O(n), Space O(1)
13268
+ * @example
13269
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13270
+ * ms.forEach((key, count) => console.log(`${key}: ${count}`));
13271
+ * // 1: 2, 2: 1, 3: 3
13234
13272
  */
13235
- _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
13236
- if (keyNodeOrEntry === void 0 || keyNodeOrEntry === null) return [void 0, void 0];
13237
- if (this.isNode(keyNodeOrEntry)) return [keyNodeOrEntry, value];
13238
- if (this.isEntry(keyNodeOrEntry)) {
13239
- const [key, entryValue] = keyNodeOrEntry;
13240
- if (key === void 0 || key === null) return [void 0, void 0];
13241
- const finalValue = value != null ? value : entryValue;
13242
- return [this.createNode(key, finalValue, count), finalValue];
13273
+ forEach(callback) {
13274
+ for (const [k, c] of this.entries()) {
13275
+ callback(k, c);
13243
13276
  }
13244
- return [this.createNode(keyNodeOrEntry, value, count), value];
13245
13277
  }
13246
13278
  /**
13247
- * (Protected) Swap keys/values/counters between the source and destination nodes.
13248
- * @remarks Time O(1), Space O(1)
13249
- * @param srcNode - Source node (or key) whose properties will be moved.
13250
- * @param destNode - Destination node (or key) to receive properties.
13251
- * @returns Destination node after swap, or undefined.
13279
+ * Creates a new TreeMultiSet with entries that match the predicate.
13280
+ * @remarks Time O(n log n), Space O(n)
13281
+ * @example
13282
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13283
+ * const filtered = ms.filter((key, count) => count >= 2);
13284
+ * // TreeMultiSet { 1: 2, 3: 3 }
13252
13285
  */
13253
- _swapProperties(srcNode, destNode) {
13254
- srcNode = this.ensureNode(srcNode);
13255
- destNode = this.ensureNode(destNode);
13256
- if (srcNode && destNode) {
13257
- const { key, value, count, height } = destNode;
13258
- const tempNode = this.createNode(key, value, count);
13259
- if (tempNode) {
13260
- tempNode.height = height;
13261
- destNode.key = srcNode.key;
13262
- if (!this._isMapMode) destNode.value = srcNode.value;
13263
- destNode.count = srcNode.count;
13264
- destNode.height = srcNode.height;
13265
- srcNode.key = tempNode.key;
13266
- if (!this._isMapMode) srcNode.value = tempNode.value;
13267
- srcNode.count = tempNode.count;
13268
- srcNode.height = tempNode.height;
13286
+ filter(predicate) {
13287
+ const result = new _TreeMultiSet([], {
13288
+ comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13289
+ isMapMode: __privateGet(this, _core4)._isMapMode
13290
+ });
13291
+ for (const [k, c] of this.entries()) {
13292
+ if (predicate(k, c)) {
13293
+ result.add(k, c);
13269
13294
  }
13270
- return destNode;
13271
13295
  }
13272
- return void 0;
13296
+ return result;
13273
13297
  }
13274
13298
  /**
13275
- * (Protected) Replace one node by another and adjust counters accordingly.
13276
- * @remarks Time O(1), Space O(1)
13277
- * @param oldNode - Node being replaced.
13278
- * @param newNode - Replacement node.
13279
- * @returns The new node after replacement.
13299
+ * Reduces the multiset to a single value.
13300
+ * @remarks Time O(n), Space O(1)
13301
+ * @example
13302
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13303
+ * const total = ms.reduce((acc, key, count) => acc + count, 0); // 6
13280
13304
  */
13281
- _replaceNode(oldNode, newNode) {
13282
- newNode.count = oldNode.count + newNode.count;
13283
- return super._replaceNode(oldNode, newNode);
13305
+ reduce(callback, initialValue) {
13306
+ let acc = initialValue;
13307
+ for (const [k, c] of this.entries()) {
13308
+ acc = callback(acc, k, c);
13309
+ }
13310
+ return acc;
13311
+ }
13312
+ /**
13313
+ * Maps keys and counts to a new TreeMultiSet.
13314
+ * When multiple keys map to the same new key, counts are merged (added).
13315
+ * @remarks Time O(n log n), Space O(n)
13316
+ * @example
13317
+ * const ms = new TreeMultiSet([1, 1, 2, 3, 3, 3]);
13318
+ * const mapped = ms.map((key, count) => [key * 10, count]);
13319
+ * // TreeMultiSet { 10: 2, 20: 1, 30: 3 }
13320
+ * @example
13321
+ * // Collision: counts merge
13322
+ * const ms = new TreeMultiSet([1, 2, 3]);
13323
+ * const merged = ms.map((key, count) => [key % 2, count]);
13324
+ * // { 0: 1, 1: 2 } (1 and 3 both map to 1, counts add)
13325
+ */
13326
+ map(mapper, options) {
13327
+ const result = new _TreeMultiSet([], {
13328
+ comparator: options == null ? void 0 : options.comparator,
13329
+ isMapMode: __privateGet(this, _core4)._isMapMode
13330
+ });
13331
+ for (const [k, c] of this.entries()) {
13332
+ const [newKey, newCount] = mapper(k, c);
13333
+ result.add(newKey, newCount);
13334
+ }
13335
+ return result;
13336
+ }
13337
+ /**
13338
+ * Creates an independent copy of this multiset.
13339
+ * @remarks Time O(n log n), Space O(n)
13340
+ * @example
13341
+ * const ms = new TreeMultiSet([1, 1, 2]);
13342
+ * const copy = ms.clone();
13343
+ * copy.add(3);
13344
+ * ms.has(3); // false (original unchanged)
13345
+ */
13346
+ clone() {
13347
+ const result = new _TreeMultiSet([], {
13348
+ comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13349
+ isMapMode: __privateGet(this, _core4)._isMapMode
13350
+ });
13351
+ for (const [k, c] of this.entries()) {
13352
+ result.add(k, c);
13353
+ }
13354
+ return result;
13355
+ }
13356
+ // ━━━ Tree utilities ━━━
13357
+ /**
13358
+ * Returns keys within the given range.
13359
+ * @remarks Time O(log n + k), Space O(k) where k is result size
13360
+ * @example
13361
+ * const ms = new TreeMultiSet([10, 20, 30, 40, 50]);
13362
+ * ms.rangeSearch([15, 45]); // [20, 30, 40]
13363
+ */
13364
+ rangeSearch(range, callback) {
13365
+ const cb = callback != null ? callback : ((k) => k);
13366
+ return __privateGet(this, _core4).rangeSearch(range, (node) => cb(node.key));
13367
+ }
13368
+ /**
13369
+ * Prints the internal tree structure (for debugging).
13370
+ * @remarks Time O(n), Space O(n)
13371
+ * @example
13372
+ * const ms = new TreeMultiSet([1, 2, 3]);
13373
+ * ms.print();
13374
+ */
13375
+ print() {
13376
+ __privateGet(this, _core4).print();
13284
13377
  }
13285
13378
  };
13286
- __name(_AVLTreeCounter, "AVLTreeCounter");
13287
- var AVLTreeCounter = _AVLTreeCounter;
13379
+ _core4 = new WeakMap();
13380
+ _isDefaultComparator4 = new WeakMap();
13381
+ __name(_TreeMultiSet, "TreeMultiSet");
13382
+ var TreeMultiSet = _TreeMultiSet;
13288
13383
 
13289
13384
  // src/data-structures/priority-queue/priority-queue.ts
13290
13385
  var _PriorityQueue = class _PriorityQueue extends Heap {
@@ -14491,6 +14586,13 @@ var TreeNode = _TreeNode;
14491
14586
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
14492
14587
  * @license MIT License
14493
14588
  */
14589
+ /**
14590
+ * data-structure-typed
14591
+ *
14592
+ * @author Pablo Zeng
14593
+ * @copyright Copyright (c) 2022 Pablo Zeng
14594
+ * @license MIT License
14595
+ */
14494
14596
  /**
14495
14597
  * data-structure-typed
14496
14598
  *
@@ -14500,10 +14602,6 @@ var TreeNode = _TreeNode;
14500
14602
  */
14501
14603
 
14502
14604
  exports.AVLTree = AVLTree;
14503
- exports.AVLTreeCounter = AVLTreeCounter;
14504
- exports.AVLTreeCounterNode = AVLTreeCounterNode;
14505
- exports.AVLTreeMultiMap = AVLTreeMultiMap;
14506
- exports.AVLTreeMultiMapNode = AVLTreeMultiMapNode;
14507
14605
  exports.AVLTreeNode = AVLTreeNode;
14508
14606
  exports.AbstractEdge = AbstractEdge;
14509
14607
  exports.AbstractGraph = AbstractGraph;
@@ -14550,11 +14648,12 @@ exports.SinglyLinkedListNode = SinglyLinkedListNode;
14550
14648
  exports.SkipList = SkipList;
14551
14649
  exports.SkipListNode = SkipListNode;
14552
14650
  exports.Stack = Stack;
14553
- exports.TreeCounter = TreeCounter;
14554
- exports.TreeCounterNode = TreeCounterNode;
14651
+ exports.TreeMap = TreeMap;
14555
14652
  exports.TreeMultiMap = TreeMultiMap;
14556
14653
  exports.TreeMultiMapNode = TreeMultiMapNode;
14654
+ exports.TreeMultiSet = TreeMultiSet;
14557
14655
  exports.TreeNode = TreeNode;
14656
+ exports.TreeSet = TreeSet;
14558
14657
  exports.Trie = Trie;
14559
14658
  exports.TrieNode = TrieNode;
14560
14659
  exports.UndirectedEdge = UndirectedEdge;