Engine → Core
flat_hash_map.h
Open-addressing hash map storing std::pair<const K, V> in place. Iteration order is the slot order (preserved by copies) and changes on rehash. Not thread-safe; concurrent const access is fine. Rehashing happens only when an insertion would push size() above capacity() * MAX_LOAD_FACTOR, so after reserve(n) the next n insertions move nothing. Pointers and references to elements are otherwise invalidated only by erasing an element of the same probe run (backward shift). Re-fetch end() after inserting: an insertion can move the slot the iteration order starts at. Arguments passed to an inserting call must not refer to elements of the same map.
Structs
Classes
| File |
Description |
detail::hash_table |
The table behind flat_hash_map and flat_hash_set. Value is the stored element, KeyOf extracts its key. Not thread-safe; concurrent const access is fine. |
detail::hash_table::basic_iterator |
Forward iterator over occupied slots. Walks the table cyclically from the slot after the anchor and stops at the anchor, so it visits every element exactly once even when a probe run wraps around the end of the table. |
flat_hash_map |
Open-addressing hash map storing std::pair<const K, V> in place. Iteration order is the slot order (preserved by copies) and changes on rehash. Not thread-safe; concurrent const access is fine. Rehashing happens only when an insertion would push size() above capacity() * MAX_LOAD_FACTOR, so after reserve(n) the next n insertions move nothing. Pointers and references to elements are otherwise invalidated only by erasing an element of the same probe run (backward shift). Re-fetch end() after inserting: an insertion can move the slot the iteration order starts at. Arguments passed to an inserting call must not refer to elements of the same map. |
flat_hash_set |
Open-addressing hash set with the same table (and the same rehash and invalidation rules) as flat_hash_map. Elements are immutable through iterators. Not thread-safe; concurrent const access is fine. |
Type Aliases
detail::hash_table::basic_iterator::difference_type
using difference_type = isize;
detail::hash_table::basic_iterator::iterator_category
using iterator_category = std::forward_iterator_tag;
detail::hash_table::basic_iterator::pointer
using pointer = std::conditional_t<IsConst, const Value *, Value *>;
detail::hash_table::basic_iterator::reference
using reference = std::conditional_t<IsConst, const Value &, Value &>;
detail::hash_table::basic_iterator::value_type
using value_type = Value;
detail::hash_table::const_iterator
using const_iterator = basic_iterator<true>;
detail::hash_table::iterator
using iterator = basic_iterator<false>;
detail::hash_table::key_type
using key_type = typename KeyOf::key_type;
detail::hash_table::value_type
using value_type = Value;
detail::identity_key_of::key_type
detail::pair_key_of::key_type
flat_hash_map::const_iterator
using const_iterator = typename table_type::const_iterator;
flat_hash_map::const_reference
using const_reference = const value_type &;
flat_hash_map::difference_type
using difference_type = isize;
flat_hash_map::hasher
flat_hash_map::iterator
using iterator = typename table_type::iterator;
flat_hash_map::key_equal
flat_hash_map::key_type
flat_hash_map::mapped_type
flat_hash_map::reference
using reference = value_type &;
flat_hash_map::size_type
flat_hash_map::table_type
using table_type = detail::hash_table<value_type, detail::pair_key_of<K, V>, Hash, Eq>;
flat_hash_map::value_type
using value_type = std::pair<const K, V>;
flat_hash_set::const_iterator
using const_iterator = typename table_type::const_iterator;
flat_hash_set::const_reference
using const_reference = const K &;
flat_hash_set::difference_type
using difference_type = isize;
flat_hash_set::hasher
flat_hash_set::iterator
using iterator = typename table_type::const_iterator;
flat_hash_set::key_equal
flat_hash_set::key_type
flat_hash_set::reference
using reference = const K &;
flat_hash_set::size_type
flat_hash_set::table_type
using table_type = detail::hash_table<K, detail::identity_key_of<K>, Hash, Eq>;
flat_hash_set::value_type
Functions
Public
swap
template <typename K, typename V, typename Hash, typename Eq> void swap(
flat_hash_map<K, V, Hash, Eq> &left,
flat_hash_map<K, V, Hash, Eq> &right) noexcept;
template <typename K, typename Hash, typename Eq> void swap(
flat_hash_set<K, Hash, Eq> &left,
flat_hash_set<K, Hash, Eq> &right) noexcept;