EnTT 3.13.0
|
Associative container for unique objects of a given type. More...
#include <dense_set.hpp>
Public Types | |
using | key_type = Type |
Key type of the container. | |
using | value_type = Type |
Value type of the container. | |
using | size_type = std::size_t |
Unsigned integer type. | |
using | hasher = Hash |
Type of function to use to hash the elements. | |
using | key_equal = KeyEqual |
Type of function to use to compare the elements for equality. | |
using | allocator_type = Allocator |
Allocator type. | |
using | iterator = internal::dense_set_iterator< typename packed_container_type::iterator > |
Random access iterator type. | |
using | const_iterator = internal::dense_set_iterator< typename packed_container_type::const_iterator > |
Constant random access iterator type. | |
using | reverse_iterator = std::reverse_iterator< iterator > |
Reverse iterator type. | |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Constant reverse iterator type. | |
using | local_iterator = internal::dense_set_local_iterator< typename packed_container_type::iterator > |
Forward iterator type. | |
using | const_local_iterator = internal::dense_set_local_iterator< typename packed_container_type::const_iterator > |
Constant forward iterator type. | |
Public Member Functions | |
dense_set () | |
Default constructor. | |
dense_set (const allocator_type &allocator) | |
Constructs an empty container with a given allocator. | |
dense_set (const size_type cnt, const allocator_type &allocator) | |
Constructs an empty container with a given allocator and user supplied minimal number of buckets. | |
dense_set (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_set (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_set (const dense_set &)=default | |
Default copy constructor. | |
dense_set (const dense_set &other, const allocator_type &allocator) | |
Allocator-extended copy constructor. | |
dense_set (dense_set &&) noexcept(std::is_nothrow_move_constructible_v< compressed_pair< sparse_container_type, hasher > > &&std::is_nothrow_move_constructible_v< compressed_pair< packed_container_type, key_equal > >)=default | |
Default move constructor. | |
dense_set (dense_set &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
dense_set & | operator= (const dense_set &)=default |
Default copy assignment operator. | |
dense_set & | operator= (dense_set &&) noexcept(std::is_nothrow_move_assignable_v< compressed_pair< sparse_container_type, hasher > > &&std::is_nothrow_move_assignable_v< compressed_pair< packed_container_type, key_equal > >)=default |
Default move assignment operator. | |
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. | |
const_reverse_iterator | crbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
const_reverse_iterator | rbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
reverse_iterator | rbegin () noexcept |
Returns a reverse iterator to the beginning. | |
const_reverse_iterator | crend () const noexcept |
Returns a reverse iterator to the end. | |
const_reverse_iterator | rend () const noexcept |
Returns a reverse iterator to the end. | |
reverse_iterator | rend () noexcept |
Returns a reverse 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 it does not exist. | |
std::pair< iterator, bool > | insert (value_type &&value) |
Inserts an element into the container, if it does not exist. | |
template<typename It > | |
void | insert (It first, It last) |
Inserts elements into the container, if they do not exist. | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (Args &&...args) |
Constructs an element in-place, if it does not exist. | |
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 value_type &value) |
Removes the element associated with a given value. | |
void | swap (dense_set &other) |
Exchanges the contents with those of a given container. | |
size_type | count (const value_type &key) const |
Returns the number of elements matching a value (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 value_type &value) |
Finds an element with a given value. | |
const_iterator | find (const value_type &value) const |
Finds an element with a given value. | |
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 &value) |
Finds an element that compares equivalent to a given value. | |
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 &value) const |
Finds an element with a given value. | |
std::pair< iterator, iterator > | equal_range (const value_type &value) |
Returns a range containing all elements with a given value. | |
std::pair< const_iterator, const_iterator > | equal_range (const value_type &value) const |
Returns a range containing all elements with a given value. | |
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 &value) |
Returns a range containing all elements that compare equivalent to a given value. | |
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 &value) const |
Returns a range containing all elements with a given value. | |
bool | contains (const value_type &value) const |
Checks if the container contains an element with a given value. | |
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 &value) const |
Checks if the container contains an element 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 value_type &value) const |
Returns the bucket for a given element. | |
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 elements. | |
key_equal | key_eq () const |
Returns the function used to compare elements for equality. | |
Associative container for unique objects of a given type.
Internally, elements are organized into buckets. Which bucket an element is placed into depends entirely on its hash. Elements with the same hash code appear in the same bucket.
Type | Value type of the associative container. |
Hash | Type of function to use to hash the values. |
KeyEqual | Type of function to use to compare the values for equality. |
Allocator | Type of allocator used to manage memory and elements. |
Definition at line 220 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::allocator_type = Allocator |
Allocator type.
Definition at line 301 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::const_iterator = internal::dense_set_iterator<typename packed_container_type::const_iterator> |
Constant random access iterator type.
Definition at line 305 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::const_local_iterator = internal::dense_set_local_iterator<typename packed_container_type::const_iterator> |
Constant forward iterator type.
Definition at line 313 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Constant reverse iterator type.
Definition at line 309 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::hasher = Hash |
Type of function to use to hash the elements.
Definition at line 297 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::iterator = internal::dense_set_iterator<typename packed_container_type::iterator> |
Random access iterator type.
Definition at line 303 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::key_equal = KeyEqual |
Type of function to use to compare the elements for equality.
Definition at line 299 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::key_type = Type |
Key type of the container.
Definition at line 291 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::local_iterator = internal::dense_set_local_iterator<typename packed_container_type::iterator> |
Forward iterator type.
Definition at line 311 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::reverse_iterator = std::reverse_iterator<iterator> |
Reverse iterator type.
Definition at line 307 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::size_type = std::size_t |
Unsigned integer type.
Definition at line 295 of file dense_set.hpp.
using entt::dense_set< Type, Hash, KeyEqual, Allocator >::value_type = Type |
Value type of the container.
Definition at line 293 of file dense_set.hpp.
|
inline |
Default constructor.
Definition at line 316 of file dense_set.hpp.
|
inlineexplicit |
Constructs an empty container with a given allocator.
allocator | The allocator to use. |
Definition at line 323 of file dense_set.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 332 of file dense_set.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 342 of file dense_set.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 353 of file dense_set.hpp.
|
inline |
Allocator-extended copy constructor.
other | The instance to copy from. |
allocator | The allocator to use. |
Definition at line 368 of file dense_set.hpp.
|
inline |
Allocator-extended move constructor.
other | The instance to move from. |
allocator | The allocator to use. |
Definition at line 381 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 418 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 423 of file dense_set.hpp.
|
inline |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 776 of file dense_set.hpp.
|
inline |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 767 of file dense_set.hpp.
|
inline |
Returns the bucket for a given element.
value | The value of the element to examine. |
Definition at line 837 of file dense_set.hpp.
|
inline |
Returns the number of buckets.
Definition at line 811 of file dense_set.hpp.
|
inline |
Returns the number of elements in a given bucket.
index | The index of the bucket to examine. |
Definition at line 828 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the array is empty, the returned iterator will be equal to end()
.
Definition at line 413 of file dense_set.hpp.
|
inline |
Returns an iterator to the beginning of a given bucket.
index | An index of a bucket to access. |
Definition at line 758 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 432 of file dense_set.hpp.
|
inline |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 785 of file dense_set.hpp.
|
inlinenoexcept |
Clears the container.
Definition at line 511 of file dense_set.hpp.
|
inline |
Checks if the container contains an element that compares equivalent to a given value.
Other | Type of an element to search for. |
value | Value of an element to search for. |
Definition at line 749 of file dense_set.hpp.
|
inline |
Checks if the container contains an element with a given value.
value | Value of an element to search for. |
Definition at line 736 of file dense_set.hpp.
|
inline |
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 652 of file dense_set.hpp.
|
inline |
Returns the number of elements matching a value (either 1 or 0).
key | Key value of an element to search for. |
Definition at line 640 of file dense_set.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the array is empty, the returned iterator will be equal to rend()
.
Definition at line 453 of file dense_set.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 472 of file dense_set.hpp.
|
inline |
Constructs an element in-place, if it 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 560 of file dense_set.hpp.
|
inlinenoexcept |
Checks whether a container is empty.
Definition at line 490 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 437 of file dense_set.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 442 of file dense_set.hpp.
|
inline |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 803 of file dense_set.hpp.
|
inline |
Returns an iterator to the end of a given bucket.
index | An index of a bucket to access. |
Definition at line 794 of file dense_set.hpp.
|
inline |
Returns a range containing all elements that compare equivalent to a given value.
Other | Type of an element to search for. |
value | Value of an element to search for. |
Definition at line 718 of file dense_set.hpp.
|
inline |
Returns a range containing all elements with a given value.
value | Value of an element to search for. |
Definition at line 726 of file dense_set.hpp.
|
inline |
Returns a range containing all elements with a given value.
value | Value of an element to search for. |
Definition at line 697 of file dense_set.hpp.
|
inline |
Returns a range containing all elements with a given value.
value | Value of an element to search for. |
Definition at line 703 of file dense_set.hpp.
|
inline |
Removes the element associated with a given value.
value | Value of an element to remove. |
Definition at line 611 of file dense_set.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 596 of file dense_set.hpp.
|
inline |
Removes an element from a given position.
pos | An iterator to the element to remove. |
Definition at line 584 of file dense_set.hpp.
|
inline |
Finds an element that compares equivalent to a given value.
Other | Type of an element to search for. |
value | Value of an element to search for. |
Definition at line 680 of file dense_set.hpp.
|
inline |
Finds an element with a given value.
value | Value of an element to search for. |
Definition at line 687 of file dense_set.hpp.
|
inline |
Finds an element with a given value.
value | Value of an element to search for. |
Definition at line 662 of file dense_set.hpp.
|
inline |
Finds an element with a given value.
value | Value of an element to search for. |
Definition at line 667 of file dense_set.hpp.
|
inlineconstexprnoexcept |
Returns the associated allocator.
Definition at line 402 of file dense_set.hpp.
|
inline |
Returns the function used to hash the elements.
Definition at line 905 of file dense_set.hpp.
|
inline |
Inserts an element into the container, if it does not exist.
value | An element to insert into the container. |
Definition at line 524 of file dense_set.hpp.
|
inline |
Inserts elements into the container, if they 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 540 of file dense_set.hpp.
|
inline |
Inserts an element into the container, if it does not exist.
value | An element to insert into the container. |
Definition at line 529 of file dense_set.hpp.
|
inline |
Returns the function used to compare elements for equality.
Definition at line 913 of file dense_set.hpp.
|
inline |
Returns the average number of elements per bucket.
Definition at line 845 of file dense_set.hpp.
|
inline |
Returns the maximum number of buckets.
Definition at line 819 of file dense_set.hpp.
|
inline |
Returns the maximum average number of elements per bucket.
Definition at line 853 of file dense_set.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 861 of file dense_set.hpp.
|
inlinenoexcept |
Returns the maximum possible number of elements.
Definition at line 506 of file dense_set.hpp.
|
default |
Default copy assignment operator.
|
defaultnoexcept |
Default move assignment operator.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the array is empty, the returned iterator will be equal to rend()
.
Definition at line 458 of file dense_set.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the array is empty, the returned iterator will be equal to rend()
.
Definition at line 463 of file dense_set.hpp.
|
inline |
Reserves at least the specified number of buckets and regenerates the hash table.
cnt | New number of buckets. |
Definition at line 872 of file dense_set.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 477 of file dense_set.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 482 of file dense_set.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 896 of file dense_set.hpp.
|
inlinenoexcept |
Returns the number of elements in a container.
Definition at line 498 of file dense_set.hpp.
|
inline |
Exchanges the contents with those of a given container.
other | Container to exchange the content with. |
Definition at line 628 of file dense_set.hpp.