9#ifndef MCRL2_UTILITIES_UNORDERED_MAP_H
10#define MCRL2_UTILITIES_UNORDERED_MAP_H
40 using allocator_type =
typename std::allocator_traits<Allocator>::template rebind_alloc<value_type>;
44 using pointer =
typename std::allocator_traits<Allocator>::pointer;
45 using const_pointer =
typename std::allocator_traits<Allocator>::const_pointer;
66 return hash(pair.first);
69 template<
typename U,
typename ...V,
typename = std::enable_if_t<!std::is_same_v<U, std::pair<Key, T>>>>
91 return equals(first.first, second.first);
94 template <
typename U,
typename...V,
typename = std::enable_if_t<!std::is_same_v<U, std::pair<Key, T>>>>
97 return equals(first.first, key);
107 using iterator =
typename Set::template unordered_set_iterator<bucket_type, false>;
152 template<
typename ...Args>
153 std::pair<iterator, bool>
emplace(Args&&... args) {
auto[x, y] =
m_set.
emplace(std::forward<Args>(args)...);
return std::make_pair(
iterator(x), y); }
155 template<
typename ...Args>
158 template<
typename ...Args>
161 template<
class... Args >
164 template<
class... Args >
167 template <
typename M>
174 return std::make_pair(it,
true);
178 return emplace(std::forward<Key>(obj), std::forward<M>(obj));
182 template <
typename M>
183 std::pair<iterator, bool>
insert_or_assign(
const Key& k, M&& obj) {
return insert_or_emplace(k, std::forward<M>(obj)); }
185 template <
typename M>
188 template <
typename M>
206 template<
typename ...Args>
209 template<
typename ...Args>
251template<
typename Key,
253 typename Hash = std::hash<Key>,
254 typename Equals = std::equal_to<Key>,
256 bool ThreadSafe =
false,
The block allocator provides the allocator interface for the memory pool class. As such is can be use...
A class for a map of keys to values in T based using the simple hash table set implementation.
void clear()
Clears the content.
hasher hash_function() const
unordered_map(std::size_t initial_size, const hasher &hash=hasher(), const key_equal &equals=key_equal())
Constructs an unordered_map that can store initial_size number of elements before resizing.
size_type bucket_size(size_type n) const noexcept
std::pair< iterator, bool > insert_or_assign(const Key &k, M &&obj)
local_iterator begin(size_type n)
size_type max_size() const noexcept
std::pair< iterator, bool > try_emplace(const key_type &key, Args &&... args)
iterator find(const Args &... args)
typename Set::bucket_type bucket_type
float max_load_factor() const
iterator try_emplace(const_iterator, const Key &k, Args &&... args)
const_iterator cend() const
std::pair< iterator, bool > insert(const_iterator hint, const value_type &pair)
const allocator_type & get_allocator() const noexcept
const_local_iterator cend(size_type n) const
size_type bucket(const key_type &key) const noexcept
typename std::allocator_traits< Allocator >::pointer pointer
std::pair< iterator, bool > insert(const value_type &pair)
Inserts elements.
const_iterator begin() const
std::ptrdiff_t difference_type
float load_factor() const
const_iterator find(const Args &... args) const
typename Set::const_local_iterator const_local_iterator
void rehash(size_type number_of_buckets)
Resize the number buckets to at least number_of_buckets.
typename std::allocator_traits< Allocator >::const_pointer const_pointer
typename Set::template unordered_set_iterator< bucket_type, false > iterator
const T & at(const key_type &key) const
Provides access to the value associated with the given key.
const value_type & const_reference
std::pair< unordered_map::iterator, bool > insert_return_type
typename std::allocator_traits< Allocator >::template rebind_alloc< value_type > allocator_type
std::pair< iterator, bool > insert_or_assign(const_iterator, const Key &k, M &&obj)
allocator_type & get_allocator() noexcept
bool empty() const noexcept
mapped_type & operator[](const key_type &key)
Provides access to the value associated with the given key, constructs a default value whenever the k...
void erase(const key_type &key)
Erases elements.
iterator try_emplace(const_iterator, Key &&k, Args &&... args)
typename Set::const_iterator const_iterator
const_iterator end() const
const_local_iterator end(size_type n) const
std::pair< iterator, bool > insert_or_assign(const_iterator, Key &&k, M &&obj)
Set m_set
The underlying set storing <key, value> pairs.
const_local_iterator cbegin(size_type n) const
std::pair< const Key, T > value_type
size_type count(const key_type &key) const
const_iterator cbegin() const
typename bucket_type::iterator local_iterator
iterator erase(const_iterator it)
void reserve(size_type count)
Resizes the set to the given number of elements.
iterator emplace_hint(const_iterator, Args &&... args)
const_local_iterator begin(size_type n) const
void max_load_factor(float factor)
size_type bucket_count() const noexcept
size_type capacity()
Number of elements that can be stored before rehash.
local_iterator end(size_type n)
size_type max_bucket_count() const noexcept
std::pair< iterator, bool > insert_or_assign(Key &&k, M &&obj)
std::pair< iterator, bool > emplace(Args &&... args)
static constexpr bool allow_transparent
True iff the hash and equals functions allow transparent lookup,.
void erase(const Args &... args)
Erases the given key_type(args...) from the unordered set.
size_type count(const Args &... args) const
Counts the number of occurrences of the given key (1 when it exists and 0 otherwise).
float max_load_factor() const
size_type bucket_count() const noexcept
bool empty() const noexcept
size_type max_bucket_count() const noexcept
typename bucket_type::const_iterator const_local_iterator
std::pair< iterator, bool > emplace(Args &&... args)
Inserts an element Key(args...) into the set if it did not already exist.
detail::bucket_list< value_type, allocator_type > bucket_type
Combine the bucket list and a lock that locks modifications to the bucket list.
unordered_set_iterator< bucket_type, true > const_iterator
size_type size() const noexcept
void clear()
Removes all elements from the set.
size_type max_size() const noexcept
size_type bucket(const key_type &key) const noexcept
hasher hash_function() const
size_type capacity() const noexcept
const_iterator find(const Args &... args) const
Searches whether an object key_type(args...) occurs in the set.
void rehash(size_type number_of_buckets)
Resize the number buckets to at least number_of_buckets.
size_type bucket_size(size_type n) const noexcept
const allocator_type & get_allocator() const noexcept
bool operator()(const value_type &first, const value_type &second) const
PairEquals(const key_equal &equals)
bool operator()(const value_type &first, const U &key, const V &...) const
std::size_t operator()(const U &key, const V &...) const
PairHash(const hasher &hash)
std::size_t operator()(const value_type &pair) const