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