A memory efficient hashfree hashmap implementation packaged as a header-only library.
Ubuntu (assuming 24.04 LTS):
sudo apt install cmake ninja-build g++
sudo apt install libsparsehash-devmacOS (install XCode from AppStore, and Homebrew) using native AppleClang:
brew install cmake ninja
brew install google-sparsehashmacOS (install XCode from AppStore, and Homebrew) using GCC from brew:
brew install cmake ninja gcc
brew install google-sparsehash
export CC=gcc-15
export CXX=g++-15Windows MSYS2 UCRT64:
PRE=mingw-w64-ucrt-x86_64
pacman -S $PRE-git $PRE-cmake $PRE-ninja $PRE-toolchain $PRE-sparsehashUse CMake to install to $PWD/local (headers and CMake configuration):
cmake --workflow --preset quick-release && \
cmake --install build-quick --config Release --prefix=$PWD/localDirectory example contains a sample project using ptrie.
Test against the ptrie installed in local using ptrie.cmake:
cmake -S example -B build-example-local -DCMAKE_PREFIX_PATH=$PWD/local && \
cmake --build build-example-local && \
ctest --test-dir build-example-local --verboseTest by fetching ptrie from the repository using ptrie.cmake:
cmake -S example -B build-example && \
cmake --build build-example && \
ctest --test-dir build-example --verboseClean all:
rm -Rf local build-quick build-example-local build-exampleBenchmark results are plotted using python when the following packages are installed:
sudo apt install python3-matplotlib python3-pandas python3-scipy python3-pyqt6Test and benchmark a release build:
cmake --workflow --preset releaseTest and debug with sanitizers:
cmake --workflow --preset debug-sanInspect other workflow presets:
cmake --workflow --list-presetsSee also configuration, build and test presets:
cmake --list-presets=configure
cmake --list-presets=build
cmake --list-presets=testFor example multi-config with sanitizers Debug build and test:
cmake --preset multi-san
cmake --build --preset debug-san
ctest --preset debug-sanConfigure with -DPTRIE_COVERAGE=ON and build the coverage target. It runs the
instrumented tests and produces an HTML report under <build>/coverage-html plus a
textual summary on the console. The tooling is selected by the compiler:
gcov/lcov for GCC, llvm-cov for Clang/AppleClang.
cmake --preset multi -DPTRIE_COVERAGE=ON
cmake --build --preset release-deb --target coverage
xdg-open build-multi/coverage-html/index.html # or open ... on macOSCoverage instrumentation is incompatible with the sanitizers, so use a non-sanitized
preset (e.g. multi / release-deb).
Extra tools are needed for the report (instrumentation alone works without them):
sudo apt install lcov # GCC: lcov + genhtml
# Clang: llvm-cov and llvm-profdata ship with the LLVM toolchainWith Clang, llvm-cov prints warning: N functions have mismatched data. This is
benign: the library is header-only, so a templated function that is present but never
called in one test binary keeps a different structural hash than the instantiation
exercised in another. It therefore matches by name but not by hash when the merged
profile is applied across all test binaries. Coverage counts stay correct, and
llvm-cov has no flag to silence just this message (--no-warn does not affect it).