EnTT 3.15.0
|
Associative container for key-value pairs with unique keys. More...
#include <dense_map.hpp>
Public Types | |
using | allocator_type = Allocator |
Allocator type. | |
using | key_type = Key |
Key type of the container. | |
using | mapped_type = Type |
Mapped type of the container. | |
using | value_type = std::pair<const Key, Type> |
Key-value type of the container. | |
using | size_type = std::size_t |
Unsigned integer type. | |
using | difference_type = std::ptrdiff_t |
Signed integer type. | |
using | hasher = Hash |
Type of function to use to hash the keys. | |
using | key_equal = KeyEqual |
Type of function to use to compare the keys for equality. | |
using | iterator = internal::dense_map_iterator<typename packed_container_type::iterator> |
Input iterator type. | |
using | const_iterator = internal::dense_map_iterator<typename packed_container_type::const_iterator> |
Constant input iterator type. | |
using | local_iterator = internal::dense_map_local_iterator<typename packed_container_type::iterator> |
Input iterator type. | |
using | const_local_iterator = internal::dense_map_local_iterator<typename packed_container_type::const_iterator> |
Constant input iterator type. | |
Public Member Functions | |
dense_map () | |
Default constructor. | |
dense_map (const allocator_type &allocator) | |
Constructs an empty container with a given allocator. | |
dense_map (const size_type cnt, const allocator_type &allocator) | |
Constructs an empty container with a given allocator and user supplied minimal number of buckets. | |
dense_map (const size_type cnt, const hasher &hash, const allocator_type &allocator) | |
Constructs an empty container with a given allocator, hash function and user supplied minimal number of buckets. | |
dense_map (const size_type cnt, const hasher &hash=hasher{}, const key_equal &equal=key_equal{}, const allocator_type &allocator=allocator_type{}) | |
Constructs an empty container with a given allocator, hash function, compare function and user supplied minimal number of buckets. | |
dense_map (const dense_map &)=default | |
Default copy constructor. | |
dense_map (const dense_map &other, const allocator_type &allocator) | |
Allocator-extended copy constructor. | |
dense_map (dense_map &&) noexcept=default | |
Default move constructor. | |
dense_map (dense_map &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
~dense_map ()=default | |
Default destructor. | |
dense_map & | operator= (const dense_map &)=default |
Default copy assignment operator. | |
dense_map & | operator= (dense_map &&) noexcept=default |
Default move assignment operator. | |
void | swap (dense_map &other) noexcept |
Exchanges the contents with those of a given container. | |
constexpr allocator_type | get_allocator () const noexcept |
Returns the associated allocator. | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the beginning. | |
const_iterator | begin () const noexcept |
Returns an iterator to the beginning. | |
iterator | begin () noexcept |
Returns an iterator to the beginning. | |
const_iterator | cend () const noexcept |
Returns an iterator to the end. | |
const_iterator | end () const noexcept |
Returns an iterator to the end. | |
iterator | end () noexcept |
Returns an iterator to the end. | |
bool | empty () const noexcept |
Checks whether a container is empty. | |
size_type | size () const noexcept |
Returns the number of elements in a container. | |
size_type | max_size () const noexcept |
Returns the maximum possible number of elements. | |
void | clear () noexcept |
Clears the container. | |
std::pair< iterator, bool > | insert (const value_type &value) |
Inserts an element into the container, if the key does not exist. | |
std::pair< iterator, bool > | insert (value_type &&value) |
Inserts an element into the container, if the key does not exist. | |
template<typename Arg> | |
std::enable_if_t< std::is_constructible_v< value_type, Arg && >, std::pair< iterator, bool > > | insert (Arg &&value) |
Inserts an element into the container, if the key does not exist. | |
template<typename It> | |
void | insert (It first, It last) |
Inserts elements into the container, if their keys do not exist. | |
template<typename Arg> | |
std::pair< iterator, bool > | insert_or_assign (const key_type &key, Arg &&value) |
Inserts an element into the container or assigns to the current element if the key already exists. | |
template<typename Arg> | |
std::pair< iterator, bool > | insert_or_assign (key_type &&key, Arg &&value) |
Inserts an element into the container or assigns to the current element if the key already exists. | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (Args &&...args) |
Constructs an element in-place, if the key does not exist. | |
template<typename... Args> | |
std::pair< iterator, bool > | try_emplace (const key_type &key, Args &&...args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
template<typename... Args> | |
std::pair< iterator, bool > | try_emplace (key_type &&key, Args &&...args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
iterator | erase (const_iterator pos) |
Removes an element from a given position. | |
iterator | erase (const_iterator first, const_iterator last) |
Removes the given elements from a container. | |
size_type | erase (const key_type &key) |
Removes the element associated with a given key. | |
mapped_type & | at (const key_type &key) |
Accesses a given element with bounds checking. | |
const mapped_type & | at (const key_type &key) const |
Accesses a given element with bounds checking. | |
mapped_type & | operator[] (const key_type &key) |
Accesses or inserts a given element. | |
mapped_type & | operator[] (key_type &&key) |
Accesses or inserts a given element. | |
size_type | count (const key_type &key) const |
Returns the number of elements matching a key (either 1 or 0). | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, size_type > > | count (const Other &key) const |
Returns the number of elements matching a key (either 1 or 0). | |
iterator | find (const key_type &key) |
Finds an element with a given key. | |
const_iterator | find (const key_type &key) const |
Finds an element with a given key. | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, iterator > > | find (const Other &key) |
Finds an element with a key that compares equivalent to a given key. | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, const_iterator > > | find (const Other &key) const |
Finds an element with a given key. | |
std::pair< iterator, iterator > | equal_range (const key_type &key) |
Returns a range containing all elements with a given key. | |
std::pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
Returns a range containing all elements with a given key. | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, std::pair< iterator, iterator > > > | equal_range (const Other &key) |
Returns a range containing all elements that compare equivalent to a given key. | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, std::pair< const_iterator, const_iterator > > > | equal_range (const Other &key) const |
Returns a range containing all elements with a given key. | |
bool | contains (const key_type &key) const |
Checks if the container contains an element with a given key. | |
template<typename Other> | |
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, bool > > | contains (const Other &key) const |
Checks if the container contains an element with a key that compares equivalent to a given value. | |
const_local_iterator | cbegin (const size_type index) const |
Returns an iterator to the beginning of a given bucket. | |
const_local_iterator | begin (const size_type index) const |
Returns an iterator to the beginning of a given bucket. | |
local_iterator | begin (const size_type index) |
Returns an iterator to the beginning of a given bucket. | |
const_local_iterator | cend (const size_type index) const |
Returns an iterator to the end of a given bucket. | |
const_local_iterator | end (const size_type index) const |
Returns an iterator to the end of a given bucket. | |
local_iterator | end (const size_type index) |
Returns an iterator to the end of a given bucket. | |
size_type | bucket_count () const |
Returns the number of buckets. | |
size_type | max_bucket_count () const |
Returns the maximum number of buckets. | |
size_type | bucket_size (const size_type index) const |
Returns the number of elements in a given bucket. | |
size_type | bucket (const key_type &key) const |
Returns the bucket for a given key. | |
float | load_factor () const |
Returns the average number of elements per bucket. | |
float | max_load_factor () const |
Returns the maximum average number of elements per bucket. | |
void | max_load_factor (const float value) |
Sets the desired maximum average number of elements per bucket. | |
void | rehash (const size_type cnt) |
Reserves at least the specified number of buckets and regenerates the hash table. | |
void | reserve (const size_type cnt) |
Reserves space for at least the specified number of elements and regenerates the hash table. | |
hasher | hash_function () const |
Returns the function used to hash the keys. | |
key_equal | key_eq () const |
Returns the function used to compare keys for equality. | |
Associative container for key-value pairs with unique keys.
Internally, elements are organized into buckets. Which bucket an element is placed into depends entirely on the hash of its key. Keys with the same hash code appear in the same bucket.
Key | Key type of the associative container. |
Type | Mapped type of the associative container. |
Hash | Type of function to use to hash the keys. |
KeyEqual | Type of function to use to compare the keys for equality. |
Allocator | Type of allocator used to manage memory and elements. |
Definition at line 260 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::allocator_type = Allocator |
Allocator type.
Definition at line 348 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::const_iterator = internal::dense_map_iterator<typename packed_container_type::const_iterator> |
Constant input iterator type.
Definition at line 366 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::const_local_iterator = internal::dense_map_local_iterator<typename packed_container_type::const_iterator> |
Constant input iterator type.
Definition at line 370 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::difference_type = std::ptrdiff_t |
Signed integer type.
Definition at line 358 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::hasher = Hash |
Type of function to use to hash the keys.
Definition at line 360 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::iterator = internal::dense_map_iterator<typename packed_container_type::iterator> |
Input iterator type.
Definition at line 364 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::key_equal = KeyEqual |
Type of function to use to compare the keys for equality.
Definition at line 362 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::key_type = Key |
Key type of the container.
Definition at line 350 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::local_iterator = internal::dense_map_local_iterator<typename packed_container_type::iterator> |
Input iterator type.
Definition at line 368 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::mapped_type = Type |
Mapped type of the container.
Definition at line 352 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::size_type = std::size_t |
Unsigned integer type.
Definition at line 356 of file dense_map.hpp.
using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::value_type = std::pair<const Key, Type> |
Key-value type of the container.
Definition at line 354 of file dense_map.hpp.
|
inline |
Default constructor.
Definition at line 373 of file dense_map.hpp.
|
inlineexplicit |
Constructs an empty container with a given allocator.
allocator | The allocator to use. |
Definition at line 380 of file dense_map.hpp.
|
inline |
Constructs an empty container with a given allocator and user supplied minimal number of buckets.
cnt | Minimal number of buckets. |
allocator | The allocator to use. |
Definition at line 389 of file dense_map.hpp.
|
inline |
Constructs an empty container with a given allocator, hash function and user supplied minimal number of buckets.
cnt | Minimal number of buckets. |
hash | Hash function to use. |
allocator | The allocator to use. |
Definition at line 399 of file dense_map.hpp.
|
inlineexplicit |
Constructs an empty container with a given allocator, hash function, compare function and user supplied minimal number of buckets.
cnt | Minimal number of buckets. |
hash | Hash function to use. |
equal | Compare function to use. |
allocator | The allocator to use. |
Definition at line 410 of file dense_map.hpp.
|
inline |
Allocator-extended copy constructor.
other | The instance to copy from. |
allocator | The allocator to use. |
Definition at line 424 of file dense_map.hpp.
|
inline |
Allocator-extended move constructor.
other | The instance to move from. |
allocator | The allocator to use. |
Definition at line 437 of file dense_map.hpp.
|
inlinenodiscard |
Accesses a given element with bounds checking.
key | A key of an element to find. |
Definition at line 715 of file dense_map.hpp.
|
inlinenodiscard |
Accesses a given element with bounds checking.
key | A key of an element to find. |
Definition at line 722 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 488 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 493 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 888 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 879 of file dense_map.hpp.
|
inlinenodiscard |
Returns the bucket for a given key.
key | The value of the key to examine. |
Definition at line 949 of file dense_map.hpp.
|
inlinenodiscard |
Returns the number of buckets.
Definition at line 923 of file dense_map.hpp.
|
inlinenodiscard |
Returns the number of elements in a given bucket.
index | The index of the bucket to examine. |
Definition at line 940 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 483 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 870 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the end.
Definition at line 502 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 897 of file dense_map.hpp.
|
inlinenoexcept |
Clears the container.
Definition at line 541 of file dense_map.hpp.
|
inlinenodiscard |
Checks if the container contains an element with a given key.
key | Key value of an element to search for. |
Definition at line 848 of file dense_map.hpp.
|
inlinenodiscard |
Checks if the container contains an element with a key that compares equivalent to a given value.
Other | Type of the key value of an element to search for. |
key | Key value of an element to search for. |
Definition at line 861 of file dense_map.hpp.
|
inlinenodiscard |
Returns the number of elements matching a key (either 1 or 0).
key | Key value of an element to search for. |
Definition at line 751 of file dense_map.hpp.
|
inlinenodiscard |
Returns the number of elements matching a key (either 1 or 0).
Other | Type of the key value of an element to search for. |
key | Key value of an element to search for. |
Definition at line 763 of file dense_map.hpp.
|
inline |
Constructs an element in-place, if the key does not exist.
The element is also constructed when the container already has the key, in which case the newly constructed object is destroyed immediately.
Args | Types of arguments to forward to the constructor of the element. |
args | Arguments to forward to the constructor of the element. |
Definition at line 620 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Checks whether a container is empty.
Definition at line 520 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the end.
Definition at line 507 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the end.
Definition at line 512 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 915 of file dense_map.hpp.
|
inlinenodiscard |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 906 of file dense_map.hpp.
|
inlinenodiscard |
Returns a range containing all elements with a given key.
key | Key value of an element to search for. |
Definition at line 809 of file dense_map.hpp.
|
inlinenodiscard |
Returns a range containing all elements with a given key.
key | Key value of an element to search for. |
Definition at line 815 of file dense_map.hpp.
|
inlinenodiscard |
Returns a range containing all elements that compare equivalent to a given key.
Other | Type of an element to search for. |
key | Key value of an element to search for. |
Definition at line 830 of file dense_map.hpp.
|
inlinenodiscard |
Returns a range containing all elements with a given key.
key | Key value of an element to search for. |
Definition at line 838 of file dense_map.hpp.
|
inline |
Removes the element associated with a given key.
key | A key value of an element to remove. |
Definition at line 697 of file dense_map.hpp.
|
inline |
Removes the given elements from a container.
first | An iterator to the first element of the range of elements. |
last | An iterator past the last element of the range of elements. |
Definition at line 682 of file dense_map.hpp.
|
inline |
Removes an element from a given position.
pos | An iterator to the element to remove. |
Definition at line 670 of file dense_map.hpp.
|
inlinenodiscard |
Finds an element with a given key.
key | Key value of an element to search for. |
Definition at line 773 of file dense_map.hpp.
|
inlinenodiscard |
Finds an element with a given key.
key | Key value of an element to search for. |
Definition at line 778 of file dense_map.hpp.
|
inlinenodiscard |
Finds an element with a key that compares equivalent to a given key.
Other | Type of the key value of an element to search for. |
key | Key value of an element to search for. |
Definition at line 792 of file dense_map.hpp.
|
inlinenodiscard |
Finds an element with a given key.
key | Key value of an element to search for. |
Definition at line 799 of file dense_map.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns the associated allocator.
Definition at line 472 of file dense_map.hpp.
|
inlinenodiscard |
Returns the function used to hash the keys.
Definition at line 1017 of file dense_map.hpp.
|
inline |
Inserts an element into the container, if the key does not exist.
value | A key-value pair eventually convertible to the value type. |
Arg | Type of the key-value pair to insert into the container. |
Definition at line 569 of file dense_map.hpp.
|
inline |
Inserts an element into the container, if the key does not exist.
value | A key-value pair eventually convertible to the value type. |
Definition at line 554 of file dense_map.hpp.
|
inline |
Inserts elements into the container, if their keys do not exist.
It | Type of input iterator. |
first | An iterator to the first element of the range of elements. |
last | An iterator past the last element of the range of elements. |
Definition at line 580 of file dense_map.hpp.
|
inline |
Inserts an element into the container, if the key does not exist.
value | A key-value pair eventually convertible to the value type. |
Definition at line 559 of file dense_map.hpp.
|
inline |
Inserts an element into the container or assigns to the current element if the key already exists.
Arg | Type of the value to insert or assign. |
key | A key used both to look up and to insert if not found. |
value | A value to insert or assign. |
Definition at line 596 of file dense_map.hpp.
|
inline |
Inserts an element into the container or assigns to the current element if the key already exists.
Arg | Type of the value to insert or assign. |
key | A key used both to look up and to insert if not found. |
value | A value to insert or assign. |
Definition at line 602 of file dense_map.hpp.
|
inlinenodiscard |
Returns the function used to compare keys for equality.
Definition at line 1025 of file dense_map.hpp.
|
inlinenodiscard |
Returns the average number of elements per bucket.
Definition at line 957 of file dense_map.hpp.
|
inlinenodiscard |
Returns the maximum number of buckets.
Definition at line 931 of file dense_map.hpp.
|
inlinenodiscard |
Returns the maximum average number of elements per bucket.
Definition at line 965 of file dense_map.hpp.
|
inline |
Sets the desired maximum average number of elements per bucket.
value | A desired maximum average number of elements per bucket. |
Definition at line 973 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns the maximum possible number of elements.
Definition at line 536 of file dense_map.hpp.
|
default |
Default copy assignment operator.
|
defaultnoexcept |
Default move assignment operator.
|
inlinenodiscard |
Accesses or inserts a given element.
key | A key of an element to find or insert. |
Definition at line 733 of file dense_map.hpp.
|
inlinenodiscard |
Accesses or inserts a given element.
key | A key of an element to find or insert. |
Definition at line 742 of file dense_map.hpp.
|
inline |
Reserves at least the specified number of buckets and regenerates the hash table.
cnt | New number of buckets. |
Definition at line 984 of file dense_map.hpp.
|
inline |
Reserves space for at least the specified number of elements and regenerates the hash table.
cnt | New number of elements. |
Definition at line 1008 of file dense_map.hpp.
|
inlinenodiscardnoexcept |
Returns the number of elements in a container.
Definition at line 528 of file dense_map.hpp.
|
inlinenoexcept |
Exchanges the contents with those of a given container.
other | Container to exchange the content with. |
Definition at line 461 of file dense_map.hpp.
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
Args | Types of arguments to forward to the constructor of the element. |
key | A key used both to look up and to insert if not found. |
args | Arguments to forward to the constructor of the element. |
Definition at line 655 of file dense_map.hpp.
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
Args | Types of arguments to forward to the constructor of the element. |
key | A key used both to look up and to insert if not found. |
args | Arguments to forward to the constructor of the element. |
Definition at line 661 of file dense_map.hpp.