A C++ header-only hash map and hash set that preserve insertion order, similar to Python's OrderedDict.
ordered-map is a C++ header-only library that provides hash map and hash set containers preserving insertion order. It solves the problem of needing predictable iteration sequences in hash-based collections, offering performance comparable to `std::unordered_map` with additional order guarantees and memory efficiency.
C++ developers working on applications requiring ordered hash tables, such as configuration systems, data processing pipelines, or any scenario where insertion sequence matters.
Developers choose ordered-map for its unique combination of insertion-order preservation, high performance, and familiar API. It provides direct access to underlying storage for interoperability and includes features like heterogeneous lookups and serialization not found in standard containers.
C++ hash map and hash set which preserve the order of insertion
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Iteration returns values in the exact insertion order, similar to Python's OrderedDict, filling a gap in the C++ standard library for predictable hash-based containers.
Provides values_container() method to expose the underlying std::vector or std::deque, enabling efficient C API interaction via data() and contiguous storage without holes.
Offers O(1) average lookups with benchmarked performance comparable to std::unordered_map, plus faster insertions and reduced memory usage due to linear robin hood probing.
Supports find with types different from the key, using transparent comparators to avoid temporary object construction, as shown in the employee example.
The erase() function has O(bucket_count) complexity, making it inefficient for frequent deletions; faster unordered_erase breaks insertion order, limiting usability in order-sensitive scenarios.
Iterators return references to const std::pair, requiring it.value() to modify values—a deviation from std::unordered_map that adds boilerplate and can confuse developers.
By default, the container holds only up to 2^32-1 values, necessitating template parameter changes for larger datasets, which adds complexity compared to unbounded standard containers.