13template <
typename Key,
typename Value>
15 const Key&
operator()(
const std::pair<Key, Value>& entry)
const {
20template <
typename Key,
typename T>
27 std::string
operator()(const ::roo::string_view& val)
const {
28 return std::string(val.data(), val.size());
41template <
typename Key,
typename Value,
typename HashFn = DefaultHashFn<Key>,
42 typename KeyCmpFn = std::equal_to<Key>>
45 MapKeyFn<Key, Value>, KeyCmpFn> {
67 KeyCmpFn key_cmp_fn = KeyCmpFn())
68 :
Base(size_hint, hash_fn,
MapKeyFn<Key, Value>(), key_cmp_fn) {}
71 template <
typename InputIt>
73 KeyCmpFn key_cmp_fn = KeyCmpFn())
74 :
Base(first, last, hash_fn,
MapKeyFn<Key, Value>(), key_cmp_fn) {}
78 HashFn hash_fn = HashFn(), KeyCmpFn key_cmp_fn = KeyCmpFn())
79 :
Base(init, hash_fn,
MapKeyFn<Key, Value>(), key_cmp_fn) {}
87 const Value&
at(
const Key& key)
const {
88 auto it = this->
find(key);
89 assert(it != this->
end());
96 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
97 typename = has_is_transparent_t<KeyCmpFn, K>>
98 const Value&
at(
const K& key)
const {
99 auto it = this->
find(key);
100 assert(it != this->
end());
107 Value&
at(
const Key& key) {
108 auto it = this->
lookup(key);
109 assert(it != this->
end());
116 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
117 typename = has_is_transparent_t<KeyCmpFn, K>>
118 Value&
at(
const K& key) {
119 auto it = this->
lookup(key);
120 assert(it != this->
end());
128 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
129 typename = has_is_transparent_t<KeyCmpFn, K>>
141 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
142 typename = has_is_transparent_t<KeyCmpFn, K>>
151 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
152 typename = has_is_transparent_t<KeyCmpFn, K>>
161 auto it = this->
lookup(key);
162 if (it == this->
end()) {
163 return (*this->
insert(std::make_pair(key, Value())).first).second;
172 template <
typename K,
typename = has_is_transparent_t<HashFn, K>,
173 typename = has_is_transparent_t<KeyCmpFn, K>>
175 auto it = this->
lookup(key);
176 if (it == this->
end()) {
190template <
typename Value>
Flat, memory-conscious hash map optimized for small collections.
typename Base::hasher hasher
FlatSmallHashMap(const FlatSmallHashMap &other)
Copy constructor.
typename Base::value_type value_type
Value & at(const K &key)
Returns a mutable reference to the mapped value for key.
FlatSmallHashMap(HashFn hash_fn=HashFn(), KeyCmpFn key_cmp_fn=KeyCmpFn())
Creates an empty hash map.
FlatSmallHashMap(InputIt first, InputIt last, HashFn hash_fn=HashFn(), KeyCmpFn key_cmp_fn=KeyCmpFn())
Builds a map from an iterator range.
Value & operator[](const K &key)
Heterogeneous mutable overload of operator[].
const Value & operator[](const Key &key) const
Returns a const reference to the value for key.
const Value & at(const Key &key) const
Returns a const reference to the mapped value for key.
Base::ConstIterator find(const Key &key) const
Finds key and returns a const iterator to the entry, or end().
typename Base::const_iterator const_iterator
const Value & operator[](const K &key) const
Heterogeneous const lookup overload of operator[].
Base::ConstIterator find(const K &key) const
Heterogeneous const lookup overload of find.
typename Base::iterator iterator
Base::Iterator find(const Key &key)
Finds key and returns an iterator to the entry, or end().
typename Base::key_equal key_equal
typename Base::key_type key_type
Base::Iterator find(const K &key)
Heterogeneous lookup overload of find.
Value & at(const Key &key)
Returns a mutable reference to the mapped value for key.
FlatSmallHashMap(std::initializer_list< value_type > init, HashFn hash_fn=HashFn(), KeyCmpFn key_cmp_fn=KeyCmpFn())
Builds a map from an initializer list.
const Value & at(const K &key) const
Returns a const reference to the mapped value for key.
Value & operator[](const Key &key)
Returns a mutable reference to the value for key.
FlatSmallHashMap(uint16_t size_hint, HashFn hash_fn=HashFn(), KeyCmpFn key_cmp_fn=KeyCmpFn())
Creates a hash map with capacity for approximately size_hint elements without rehashing.
Constant forward iterator.
Mutable forward iterator.
Flat, memory-conscious hash table optimized for small collections.
ConstIterator const_iterator
std::pair< Iterator, bool > insert(Entry val)
Inserts val if key is not present.
Iterator lookup(const Key &key)
Iterator end()
Returns iterator past the end.
ConstIterator find(const Key &key) const
Finds key and returns a const iterator to the matching entry.
Flat, memory-conscious hash table implementation.
std::string operator()(const ::roo::string_view &val) const
Key operator()(const T &val) const
const Key & operator()(const std::pair< Key, Value > &entry) const