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