A C++ header-only library providing fast hash map and hash set implementations using hopscotch hashing with open addressing.
Hopscotch-map is a C++ library that implements fast hash map and hash set containers using hopscotch hashing with open addressing. It solves the performance limitations of `std::unordered_map` by offering better cache locality, lower memory overhead, and additional features like heterogeneous lookups and DoS-resistant variants.
C++ developers working on performance-critical applications who need efficient hash table implementations, such as game engines, database systems, or high-frequency trading software.
Developers choose hopscotch-map for its superior speed over `std::unordered_map`, memory efficiency compared to `google::dense_hash_map`, and extra capabilities like configurable growth policies and secure variants resistant to hash collision attacks.
C++ implementation of a fast hash map and hash set using hopscotch hashing
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Simply add the include directory to your project, making it easy to integrate without complex build steps, as stated in the README's installation section.
Typically outperforms std::unordered_map and is competitive with google::dense_hash_map while using less memory, based on the provided benchmarks in the README.
Allows lookups with types different from the key, such as using raw pointers instead of std::unique_ptr, reducing unnecessary object constructions, as shown in the example.
bhopscotch_map/set offer O(log n) worst-case lookups, protecting against hash collision attacks, which is crucial for security-sensitive applications, detailed in the Deny of Service attack section.
Differences from std::unordered_map, such as iterator invalidation on insert and the need to use it.value() to modify values, can break existing code expecting standard behavior, as admitted in the README.
Requires move-only types to have a nothrow move constructor, which may not always be feasible, limiting usability with certain custom types, as noted in the differences section.
Lacks support for bucket-related methods like bucket_size and bucket, which are available in std::unordered_map and might be needed for specific debugging or optimization tasks.
Multiple classes with different growth policies and security features can confuse users, requiring careful consideration to choose the right one, as indicated in the benchmark advice.
Hopscotch map is an open-source alternative to the following products: