EnTT: entt::dense_map< Key, Type, Hash, KeyEqual, Allocator > Class Template Reference

EnTT 3.16.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::dense_map< Key, Type, Hash, KeyEqual, Allocator > Class Template Reference

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.
template<typename Other>
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, mapped_type const & > > | at (const Other &key) const
| Accesses a given element with bounds checking.
template<typename Other>
std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, mapped_type & > > | at (const Other &key)
| 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.

## Detailed Description

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
class entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >

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.

Template Parameters

  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.

## Member Typedef Documentation

## ◆ allocator_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 349 of file dense_map.hpp.

## ◆ const_iterator

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 367 of file dense_map.hpp.

## ◆ const_local_iterator

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 371 of file dense_map.hpp.

## ◆ difference_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::difference_type = std::ptrdiff_t

Signed integer type.

Definition at line 359 of file dense_map.hpp.

## ◆ hasher

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::hasher = Hash

Type of function to use to hash the keys.

Definition at line 361 of file dense_map.hpp.

## ◆ iterator

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 365 of file dense_map.hpp.

## ◆ key_equal

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 363 of file dense_map.hpp.

## ◆ key_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::key_type = Key

Key type of the container.

Definition at line 351 of file dense_map.hpp.

## ◆ local_iterator

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 369 of file dense_map.hpp.

## ◆ mapped_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::mapped_type = Type

Mapped type of the container.

Definition at line 353 of file dense_map.hpp.

## ◆ size_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

using entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 357 of file dense_map.hpp.

## ◆ value_type

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

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 355 of file dense_map.hpp.

## Constructor & Destructor Documentation

## ◆ dense_map() [1/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( |  | ) |
| inline

Default constructor.

Definition at line 374 of file dense_map.hpp.

## ◆ dense_map() [2/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | const allocator_type & | allocator | ) |
| inlineexplicit

Constructs an empty container with a given allocator.

Parameters

  allocator | The allocator to use.

Definition at line 381 of file dense_map.hpp.

## ◆ dense_map() [3/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | const size_type | cnt,
|  | const allocator_type & | allocator )
| inline

Constructs an empty container with a given allocator and user supplied minimal number of buckets.

Parameters

  cnt | Minimal number of buckets.
  allocator | The allocator to use.

Definition at line 390 of file dense_map.hpp.

## ◆ dense_map() [4/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | const size_type | cnt,
|  | const hasher & | hash,
|  | const allocator_type & | allocator )
| inline

Constructs an empty container with a given allocator, hash function and user supplied minimal number of buckets.

Parameters

  cnt | Minimal number of buckets.
  hash | Hash function to use.
  allocator | The allocator to use.

Definition at line 400 of file dense_map.hpp.

## ◆ dense_map() [5/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | const size_type | cnt,
|  | const hasher & | hash = hasher{},
|  | const key_equal & | equal = key_equal{},
|  | const allocator_type & | allocator = allocator_type{} )
| inlineexplicit

Constructs an empty container with a given allocator, hash function, compare function and user supplied minimal number of buckets.

Parameters

  cnt | Minimal number of buckets.
  hash | Hash function to use.
  equal | Compare function to use.
  allocator | The allocator to use.

Definition at line 411 of file dense_map.hpp.

## ◆ dense_map() [6/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | const dense_map< Key, Type, Hash, KeyEqual, Allocator > & | other,
|  | const allocator_type & | allocator )
| inline

Allocator-extended copy constructor.

Parameters

  other | The instance to copy from.
  allocator | The allocator to use.

Definition at line 425 of file dense_map.hpp.

## ◆ dense_map() [7/7]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::dense_map | ( | dense_map< Key, Type, Hash, KeyEqual, Allocator > && | other,
|  | const allocator_type & | allocator )
| inline

Allocator-extended move constructor.

Parameters

  other | The instance to move from.
  allocator | The allocator to use.

Definition at line 438 of file dense_map.hpp.

## Member Function Documentation

## ◆ at() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

mapped_type & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::at | ( | const key_type & | key | ) |
| inlinenodiscard

Accesses a given element with bounds checking.

Parameters

  key | A key of an element to find.

Returns
  A reference to the mapped value of the requested element.

Definition at line 716 of file dense_map.hpp.

## ◆ at() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const mapped_type & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::at | ( | const key_type & | key | ) | const
| inlinenodiscard

Accesses a given element with bounds checking.

Parameters

  key | A key of an element to find.

Returns
  A reference to the mapped value of the requested element.

Definition at line 723 of file dense_map.hpp.

## ◆ at() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, mapped_type & > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::at | ( | const Other & | key | ) |
| inlinenodiscard

Accesses a given element with bounds checking.

Parameters

  key | A key of an element to find.

Returns
  A reference to the mapped value of the requested element.

Definition at line 746 of file dense_map.hpp.

## ◆ at() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, mapped_type const & > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::at | ( | const Other & | key | ) | const
| inlinenodiscard

Accesses a given element with bounds checking.

Template Parameters

  Other | Type of the key of an element to find.

Parameters

  key | A key of an element to find.

Returns
  A reference to the mapped value of the requested element.

Definition at line 737 of file dense_map.hpp.

## ◆ begin() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::begin | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an iterator to the beginning.

If the array is empty, the returned iterator will be equal to end().

Returns
  An iterator to the first instance of the internal array.

Definition at line 489 of file dense_map.hpp.

## ◆ begin() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::begin | ( |  | ) |
| inlinenodiscardnoexcept

Returns an iterator to the beginning.

If the array is empty, the returned iterator will be equal to end().

Returns
  An iterator to the first instance of the internal array.

Definition at line 494 of file dense_map.hpp.

## ◆ begin() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::begin | ( | const size_type | index | ) |
| inlinenodiscard

Returns an iterator to the beginning of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the beginning of the given bucket.

Definition at line 912 of file dense_map.hpp.

## ◆ begin() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::begin | ( | const size_type | index | ) | const
| inlinenodiscard

Returns an iterator to the beginning of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the beginning of the given bucket.

Definition at line 903 of file dense_map.hpp.

## ◆ bucket()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::bucket | ( | const key_type & | key | ) | const
| inlinenodiscard

Returns the bucket for a given key.

Parameters

  key | The value of the key to examine.

Returns
  The bucket for the given key.

Definition at line 973 of file dense_map.hpp.

## ◆ bucket_count()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::bucket_count | ( |  | ) | const
| inlinenodiscard

Returns the number of buckets.

Returns
  The number of buckets.

Definition at line 947 of file dense_map.hpp.

## ◆ bucket_size()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::bucket_size | ( | const size_type | index | ) | const
| inlinenodiscard

Returns the number of elements in a given bucket.

Parameters

  index | The index of the bucket to examine.

Returns
  The number of elements in the given bucket.

Definition at line 964 of file dense_map.hpp.

## ◆ cbegin() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::cbegin | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an iterator to the beginning.

If the array is empty, the returned iterator will be equal to end().

Returns
  An iterator to the first instance of the internal array.

Definition at line 484 of file dense_map.hpp.

## ◆ cbegin() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::cbegin | ( | const size_type | index | ) | const
| inlinenodiscard

Returns an iterator to the beginning of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the beginning of the given bucket.

Definition at line 894 of file dense_map.hpp.

## ◆ cend() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::cend | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an iterator to the end.

Returns
  An iterator to the element following the last instance of the internal array.

Definition at line 503 of file dense_map.hpp.

## ◆ cend() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::cend | ( | const size_type | index | ) | const
| inlinenodiscard

Returns an iterator to the end of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the end of the given bucket.

Definition at line 921 of file dense_map.hpp.

## ◆ clear()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::clear | ( |  | ) |
| inlinenoexcept

Clears the container.

Definition at line 542 of file dense_map.hpp.

## ◆ contains() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

bool entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::contains | ( | const key_type & | key | ) | const
| inlinenodiscard

Checks if the container contains an element with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  True if there is such an element, false otherwise.

Definition at line 872 of file dense_map.hpp.

## ◆ contains() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, bool > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::contains | ( | const Other & | key | ) | const
| inlinenodiscard

Checks if the container contains an element with a key that compares equivalent to a given value.

Template Parameters

  Other | Type of the key value of an element to search for.

Parameters

  key | Key value of an element to search for.

Returns
  True if there is such an element, false otherwise.

Definition at line 885 of file dense_map.hpp.

## ◆ count() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::count | ( | const key_type & | key | ) | const
| inlinenodiscard

Returns the number of elements matching a key (either 1 or 0).

Parameters

  key | Key value of an element to search for.

Returns
  Number of elements matching the key (either 1 or 0).

Definition at line 775 of file dense_map.hpp.

## ◆ count() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, size_type > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::count | ( | const Other & | key | ) | const
| inlinenodiscard

Returns the number of elements matching a key (either 1 or 0).

Template Parameters

  Other | Type of the key value of an element to search for.

Parameters

  key | Key value of an element to search for.

Returns
  Number of elements matching the key (either 1 or 0).

Definition at line 787 of file dense_map.hpp.

## ◆ emplace()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename... Args>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::emplace | ( | Args &&... | args | ) |
| 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.

Template Parameters

  Args | Types of arguments to forward to the constructor of the element.

Parameters

  args | Arguments to forward to the constructor of the element.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 621 of file dense_map.hpp.

## ◆ empty()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

bool entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::empty | ( |  | ) | const
| inlinenodiscardnoexcept

Checks whether a container is empty.

Returns
  True if the container is empty, false otherwise.

Definition at line 521 of file dense_map.hpp.

## ◆ end() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::end | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an iterator to the end.

Returns
  An iterator to the element following the last instance of the internal array.

Definition at line 508 of file dense_map.hpp.

## ◆ end() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::end | ( |  | ) |
| inlinenodiscardnoexcept

Returns an iterator to the end.

Returns
  An iterator to the element following the last instance of the internal array.

Definition at line 513 of file dense_map.hpp.

## ◆ end() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::end | ( | const size_type | index | ) |
| inlinenodiscard

Returns an iterator to the end of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the end of the given bucket.

Definition at line 939 of file dense_map.hpp.

## ◆ end() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_local_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::end | ( | const size_type | index | ) | const
| inlinenodiscard

Returns an iterator to the end of a given bucket.

Parameters

  index | An index of a bucket to access.

Returns
  An iterator to the end of the given bucket.

Definition at line 930 of file dense_map.hpp.

## ◆ equal_range() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

std::pair< iterator, iterator > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::equal_range | ( | const key_type & | key | ) |
| inlinenodiscard

Returns a range containing all elements with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  A pair of iterators pointing to the first element and past the last element of the range.

Definition at line 833 of file dense_map.hpp.

## ◆ equal_range() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

std::pair< const_iterator, const_iterator > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::equal_range | ( | const key_type & | key | ) | const
| inlinenodiscard

Returns a range containing all elements with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  A pair of iterators pointing to the first element and past the last element of the range.

Definition at line 839 of file dense_map.hpp.

## ◆ equal_range() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
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 > > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::equal_range | ( | const Other & | key | ) |
| inlinenodiscard

Returns a range containing all elements that compare equivalent to a given key.

Template Parameters

  Other | Type of an element to search for.

Parameters

  key | Key value of an element to search for.

Returns
  A pair of iterators pointing to the first element and past the last element of the range.

Definition at line 854 of file dense_map.hpp.

## ◆ equal_range() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
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 > > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::equal_range | ( | const Other & | key | ) | const
| inlinenodiscard

Returns a range containing all elements with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  A pair of iterators pointing to the first element and past the last element of the range.

Definition at line 862 of file dense_map.hpp.

## ◆ erase() [1/3]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::erase | ( | const key_type & | key | ) |
| inline

Removes the element associated with a given key.

Parameters

  key | A key value of an element to remove.

Returns
  Number of elements removed (either 0 or 1).

Definition at line 698 of file dense_map.hpp.

## ◆ erase() [2/3]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::erase | ( | const_iterator | first,
|  | const_iterator | last )
| inline

Removes the given elements from a container.

Parameters

  first | An iterator to the first element of the range of elements.
  last | An iterator past the last element of the range of elements.

Returns
  An iterator following the last removed element.

Definition at line 683 of file dense_map.hpp.

## ◆ erase() [3/3]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::erase | ( | const_iterator | pos | ) |
| inline

Removes an element from a given position.

Parameters

  pos | An iterator to the element to remove.

Returns
  An iterator following the removed element.

Definition at line 671 of file dense_map.hpp.

## ◆ find() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::find | ( | const key_type & | key | ) |
| inlinenodiscard

Finds an element with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  An iterator to an element with the given key. If no such element is found, a past-the-end iterator is returned.

Definition at line 797 of file dense_map.hpp.

## ◆ find() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

const_iterator entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::find | ( | const key_type & | key | ) | const
| inlinenodiscard

Finds an element with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  An iterator to an element with the given key. If no such element is found, a past-the-end iterator is returned.

Definition at line 802 of file dense_map.hpp.

## ◆ find() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, iterator > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::find | ( | const Other & | key | ) |
| inlinenodiscard

Finds an element with a key that compares equivalent to a given key.

Template Parameters

  Other | Type of the key value of an element to search for.

Parameters

  key | Key value of an element to search for.

Returns
  An iterator to an element with the given key. If no such element is found, a past-the-end iterator is returned.

Definition at line 816 of file dense_map.hpp.

## ◆ find() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Other>

std::enable_if_t< is_transparent_v< hasher > &&is_transparent_v< key_equal >, std::conditional_t< false, Other, const_iterator > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::find | ( | const Other & | key | ) | const
| inlinenodiscard

Finds an element with a given key.

Parameters

  key | Key value of an element to search for.

Returns
  An iterator to an element with the given key. If no such element is found, a past-the-end iterator is returned.

Definition at line 823 of file dense_map.hpp.

## ◆ get_allocator()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

allocator_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::get_allocator | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the associated allocator.

Returns
  The associated allocator.

Definition at line 473 of file dense_map.hpp.

## ◆ hash_function()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

hasher entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::hash_function | ( |  | ) | const
| inlinenodiscard

Returns the function used to hash the keys.

Returns
  The function used to hash the keys.

Definition at line 1041 of file dense_map.hpp.

## ◆ insert() [1/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Arg>

std::enable_if_t< std::is_constructible_v< value_type, Arg && >, std::pair< iterator, bool > > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert | ( | Arg && | value | ) |
| inline

Inserts an element into the container, if the key does not exist.

Parameters

  value | A key-value pair eventually convertible to the value type.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Template Parameters

  Arg | Type of the key-value pair to insert into the container.

Definition at line 570 of file dense_map.hpp.

## ◆ insert() [2/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert | ( | const value_type & | value | ) |
| inline

Inserts an element into the container, if the key does not exist.

Parameters

  value | A key-value pair eventually convertible to the value type.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 555 of file dense_map.hpp.

## ◆ insert() [3/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename It>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert | ( | It | first,
|  | It | last )
| inline

Inserts elements into the container, if their keys do not exist.

Template Parameters

  It | Type of input iterator.

Parameters

  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 581 of file dense_map.hpp.

## ◆ insert() [4/4]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert | ( | value_type && | value | ) |
| inline

Inserts an element into the container, if the key does not exist.

Parameters

  value | A key-value pair eventually convertible to the value type.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 560 of file dense_map.hpp.

## ◆ insert_or_assign() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Arg>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert_or_assign | ( | const key_type & | key,
|  | Arg && | value )
| inline

Inserts an element into the container or assigns to the current element if the key already exists.

Template Parameters

  Arg | Type of the value to insert or assign.

Parameters

  key | A key used both to look up and to insert if not found.
  value | A value to insert or assign.

Returns
  A pair consisting of an iterator to the element and a bool denoting whether the insertion took place.

Definition at line 597 of file dense_map.hpp.

## ◆ insert_or_assign() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename Arg>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::insert_or_assign | ( | key_type && | key,
|  | Arg && | value )
| inline

Inserts an element into the container or assigns to the current element if the key already exists.

Template Parameters

  Arg | Type of the value to insert or assign.

Parameters

  key | A key used both to look up and to insert if not found.
  value | A value to insert or assign.

Returns
  A pair consisting of an iterator to the element and a bool denoting whether the insertion took place.

Definition at line 603 of file dense_map.hpp.

## ◆ key_eq()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

key_equal entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::key_eq | ( |  | ) | const
| inlinenodiscard

Returns the function used to compare keys for equality.

Returns
  The function used to compare keys for equality.

Definition at line 1049 of file dense_map.hpp.

## ◆ load_factor()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

float entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::load_factor | ( |  | ) | const
| inlinenodiscard

Returns the average number of elements per bucket.

Returns
  The average number of elements per bucket.

Definition at line 981 of file dense_map.hpp.

## ◆ max_bucket_count()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::max_bucket_count | ( |  | ) | const
| inlinenodiscard

Returns the maximum number of buckets.

Returns
  The maximum number of buckets.

Definition at line 955 of file dense_map.hpp.

## ◆ max_load_factor() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

float entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::max_load_factor | ( |  | ) | const
| inlinenodiscard

Returns the maximum average number of elements per bucket.

Returns
  The maximum average number of elements per bucket.

Definition at line 989 of file dense_map.hpp.

## ◆ max_load_factor() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::max_load_factor | ( | const float | value | ) |
| inline

Sets the desired maximum average number of elements per bucket.

Parameters

  value | A desired maximum average number of elements per bucket.

Definition at line 997 of file dense_map.hpp.

## ◆ max_size()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::max_size | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the maximum possible number of elements.

Returns
  Maximum possible number of elements.

Definition at line 537 of file dense_map.hpp.

## ◆ operator=() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

dense_map & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::operator= | ( | const dense_map< Key, Type, Hash, KeyEqual, Allocator > & |  | ) |
| default

Default copy assignment operator.

Returns
  This container.

## ◆ operator=() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

dense_map & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::operator= | ( | dense_map< Key, Type, Hash, KeyEqual, Allocator > && |  | ) |
| defaultnoexcept

Default move assignment operator.

Returns
  This container.

## ◆ operator[]() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

mapped_type & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::operator[] | ( | const key_type & | key | ) |
| inlinenodiscard

Accesses or inserts a given element.

Parameters

  key | A key of an element to find or insert.

Returns
  A reference to the mapped value of the requested element.

Definition at line 757 of file dense_map.hpp.

## ◆ operator[]() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

mapped_type & entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::operator[] | ( | key_type && | key | ) |
| inlinenodiscard

Accesses or inserts a given element.

Parameters

  key | A key of an element to find or insert.

Returns
  A reference to the mapped value of the requested element.

Definition at line 766 of file dense_map.hpp.

## ◆ rehash()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::rehash | ( | const size_type | cnt | ) |
| inline

Reserves at least the specified number of buckets and regenerates the hash table.

Parameters

  cnt | New number of buckets.

Definition at line 1008 of file dense_map.hpp.

## ◆ reserve()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::reserve | ( | const size_type | cnt | ) |
| inline

Reserves space for at least the specified number of elements and regenerates the hash table.

Parameters

  cnt | New number of elements.

Definition at line 1032 of file dense_map.hpp.

## ◆ size()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

size_type entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::size | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the number of elements in a container.

Returns
  Number of elements in a container.

Definition at line 529 of file dense_map.hpp.

## ◆ swap()

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>

void entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::swap | ( | dense_map< Key, Type, Hash, KeyEqual, Allocator > & | other | ) |
| inlinenoexcept

Exchanges the contents with those of a given container.

Parameters

  other | Container to exchange the content with.

Definition at line 462 of file dense_map.hpp.

## ◆ try_emplace() [1/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename... Args>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::try_emplace | ( | const key_type & | key,
|  | Args &&... | args )
| inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Template Parameters

  Args | Types of arguments to forward to the constructor of the element.

Parameters

  key | A key used both to look up and to insert if not found.
  args | Arguments to forward to the constructor of the element.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 656 of file dense_map.hpp.

## ◆ try_emplace() [2/2]

template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
template<typename... Args>

std::pair< iterator, bool > entt::dense_map< Key, Type, Hash, KeyEqual, Allocator >::try_emplace | ( | key_type && | key,
|  | Args &&... | args )
| inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Template Parameters

  Args | Types of arguments to forward to the constructor of the element.

Parameters

  key | A key used both to look up and to insert if not found.
  args | Arguments to forward to the constructor of the element.

Returns
  A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 662 of file dense_map.hpp.

The documentation for this class was generated from the following file:

- src/entt/container/dense_map.hpp