Table of Contents
- Summary
- Template Parameters
- Public Member Types
- Public Data Members
- Public Member Functions
- (constructor)
- (destructor)
- operator=
- get_allocator
- hash_function
- key_eq
- begin, cbegin
- end, cend
- empty
- size
- max_size
- clear
- emplace
- emplace_hint
- insert
- insert_range
- insert_or_assign
- try_emplace
- erase
- swap
- equal_range
- find
- count
- contains
- at
- operator[]
- begin, cbegin (bucket interface)
- end, cend (bucket interface)
- bucket_count
- max_bucket_count
- bucket_size
- bucket
- load_factor
- max_load_factor
- rehash
- reserve
- Non-member Functions
Defined in header sfl/small_unordered_map.hpp:
namespace sfl
{
template < typename Key,
typename T,
std::size_t StaticCapacity,
std::size_t StaticBucketCount = /* see description below */,
typename Hash = sfl::hash<Key>,
typename KeyEqual = std::equal_to<Key>,
typename Allocator = std::allocator<std::pair<const Key, T>> >
class small_unordered_map;
}
sfl::small_unordered_map is an associative container similar to std::unordered_map, but it internally holds a small amount of statically allocated memory to avoid dynamic memory management when the number of stored elements is small. Dynamic memory management is used when the number of elements exceeds StaticCapacity, or when the number of buckets exceeds StaticBucketCount. This design provides a compact and cache-friendly representation optimized for small sizes.
The underlying storage is implemented as a hash table with separate chaining.
The complexity of search, insert, and erase operations is O(1) on average.
References and pointers to elements are stable: insert and erase operations do not invalidate them unless the referenced element is erased.
Iterators to elements are forward iterators, and they meet the requirements of LegacyForwardIterator.
sfl::small_unordered_map meets the requirements of Container, AllocatorAwareContainer, and UnorderedAssociativeContainer.
-
typename KeyKey type.
-
typename TValue type.
-
std::size_t StaticCapacitySize of the internal statically allocated array used for elements.
This parameters can be zero.
-
std::size_t StaticBucketCountSize of the internal statically allocated array used for buckets.
Default value of this parameter is
StaticCapacityrounded up to the nearest power of two.This parameters can be zero.
-
typename HashHash function for keys.
-
typename KeyEqualComparison function for keys.
-
typename AllocatorAllocator used for memory allocation/deallocation and construction/destruction of elements.
This type must meet the requirements of Allocator.
The program is ill-formed if
Allocator::value_typeis not the same asstd::pair<const Key, T>.
| Member Type | Definition |
|---|---|
allocator_type |
Allocator |
key_type |
Key |
mapped_type |
T |
value_type |
std::pair<const Key, T> |
size_type |
Unsigned integer type |
difference_type |
Signed integer type |
hasher |
Hash |
key_equal |
KeyEqual |
reference |
value_type& |
const_reference |
const value_type& |
pointer |
Pointer to value_type |
const_pointer |
Pointer to const value_type |
iterator |
LegacyForwardIterator to value_type |
const_iterator |
LegacyForwardIterator to const value_type |
local_iterator |
LegacyForwardIterator to value_type. This iterator can be used to iterate through a single bucket but not across buckets. |
const_local_iterator |
LegacyForwardIterator to const value_type. This iterator can be used to iterate through a single bucket but not across buckets |
-
static constexpr size_type static_capacity = StaticCapacity;
-
static constexpr size_type static_bucket_count = StaticBucketCount;
-
small_unordered_map(); -
explicit small_unordered_map(const Allocator& alloc); -
explicit small_unordered_map(size_type bucket_count); -
small_unordered_map(size_type bucket_count, const Allocator& alloc); -
small_unordered_map(size_type bucket_count, const Hash& hash); -
small_unordered_map(size_type bucket_count, const Hash& hash, const Allocator& alloc); -
small_unordered_map(size_type bucket_count, const Hash& hash, const KeyEqual& equal); -
small_unordered_map(size_type bucket_count, const Hash& hash, const KeyEqual& equal, const Allocator& alloc);Effects: Constructs an empty container.
Parameter
bucket_countspecifies minimal number of buckets to use on initialization. If it is not specified, an unspecified default value is used.Complexity: Constant.
-
template <typename InputIt> small_unordered_map(InputIt first, InputIt last); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count, const Allocator& alloc); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count, const Hash& hash); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count, const Hash& hash, const Allocator& alloc); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count, const Hash& hash, const KeyEqual& equal); -
template <typename InputIt> small_unordered_map(InputIt first, InputIt last, size_type bucket_count, const Hash& hash, const KeyEqual& equal, const Allocator& alloc);Effects: Constructs the container with the contents of the range
[first, last).If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
Parameter
bucket_countspecifies minimal number of buckets to use on initialization. If it is not specified, an unspecified default value is used.Note: These overloads participate in overload resolution only if
InputItsatisfies requirements of LegacyInputIterator. -
small_unordered_map(std::initializer_list<value_type> ilist); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count, const Allocator& alloc); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count, const Hash& hash); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count, const Hash& hash, const Allocator& alloc); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count, const Hash& hash, const KeyEqual& equal); -
small_unordered_map(std::initializer_list<value_type> ilist, size_type bucket_count, const Hash& hash, const KeyEqual& equal, const Allocator& alloc);Effects: Constructs the container with the contents of the initializer list
ilist.If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
Parameter
bucket_countspecifies minimal number of buckets to use on initialization. If it is not specified, an unspecified default value is used. -
small_unordered_map(const small_unordered_map& other); -
small_unordered_map(const small_unordered_map& other, const Allocator& alloc);Effects: Copy constructor. Constructs the container with the copy of the contents of
other. -
small_unordered_map(small_unordered_map&& other); -
small_unordered_map(small_unordered_map&& other, const Allocator& alloc);Effects: Move constructor. Constructs the container with the contents of
otherusing move semantics.otheris not guaranteed to be empty after the move.otheris in a valid but unspecified state after the move. -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count, const Allocator& alloc); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count, const Hash& hash); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count, const Hash& hash, const Allocator& alloc); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count, const Hash& hash, const KeyEqual& equal); -
template <typename Range> small_unordered_map(sfl::from_range_t, Range&& range, size_type bucket_count, const Hash& hash, const KeyEqual& equal, const Allocator& alloc);Effects: Constructs the container with the contents of
range.If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
Parameter
bucket_countspecifies minimal number of buckets to use on initialization. If it is not specified, an unspecified default value is used.Note: These overloads are available in C++11. If compiled with C++20 or later, proper C++20 range concepts are used.
-
~small_unordered_map();Effects: Destructs the container. The destructors of the elements are called and the used storage is deallocated.
Complexity: Linear in
size().
-
small_unordered_map& operator=(const small_unordered_map& other);Effects: Copy assignment operator. Replaces the contents with a copy of the contents of
other.Returns:
*this(). -
small_unordered_map& operator=(small_unordered_map&& other);Effects: Move assignment operator. Replaces the contents with those of
otherusing move semantics.otheris not guaranteed to be empty after the move.otheris in a valid but unspecified state after the move.Returns:
*this(). -
small_unordered_map& operator=(std::initializer_list<value_type> ilist);Effects: Replaces the contents with those identified by initializer list
ilist.Returns:
*this().
-
allocator_type get_allocator() const noexcept;Effects: Returns the allocator associated with the container.
Complexity: Constant.
-
hasher hash_function() const;Effects: Returns the function object that hashes the keys.
Complexity: Constant.
-
key_equal key_eq() const;Effects: Returns a function object that compares keys for equality.
Complexity: Constant.
-
iterator begin() noexcept; -
const_iterator begin() const noexcept; -
const_iterator cbegin() const noexcept;Effects: Returns an iterator to the first element of the container. If the container is empty, the returned iterator will be equal to
end().Complexity: Constant.
-
iterator end() noexcept; -
const_iterator end() const noexcept; -
const_iterator cend() const noexcept;Effects: Returns an iterator to the element following the last element of the container. This element acts as a placeholder; attempting to access it results in undefined behavior.
Complexity: Constant.
-
bool empty() const noexcept;Effects: Returns
trueif the container has no elements, i.e. whetherbegin() == end().Complexity: Constant.
-
size_type size() const noexcept;Effects: Returns the number of elements in the container, i.e.
std::distance(begin(), end()).Complexity: Constant.
-
size_type max_size() const noexcept;Effects: Returns the maximum number of elements the container is able to hold, i.e.
std::distance(begin(), end())for the largest container.Complexity: Constant.
-
void clear() noexcept;Effects: Erases all elements from the container. After this call,
size()returns zero.Complexity: Linear in
size().
-
template <typename... Args> std::pair<iterator, bool> emplace(Args&&... args);Effects: Inserts new element into the container if the container doesn't already contain an element with an equivalent key.
New element is constructed as
value_type(std::forward<Args>(args)...).The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately.
Returns: The iterator component points to the inserted element or to the already existing element. The
boolcomponent istrueif insertion happened andfalseif it did not.
-
template <typename... Args> iterator emplace_hint(const_iterator hint, Args&&... args);Effects: Inserts new element into the container if the container doesn't already contain an element with an equivalent key.
New element is constructed as
value_type(std::forward<Args>(args)...).The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately.
Iterator
hintis used as a suggestion where to start to search insert position.Returns: Iterator to the inserted element or to the already existing element.
-
std::pair<iterator, bool> insert(const value_type& value);Effects: Inserts copy of
valueif the container doesn't already contain an element with an equivalent key.Returns: The iterator component points to the inserted element or to the already existing element. The
boolcomponent istrueif insertion happened andfalseif it did not. -
std::pair<iterator, bool> insert(value_type&& value);Effects: Inserts
valueusing move semantics if the container doesn't already contain an element with an equivalent key.Returns: The iterator component points to the inserted element or to the already existing element. The
boolcomponent istrueif insertion happened andfalseif it did not. -
template <typename P> std::pair<iterator, bool> insert(P&& value);Effects: Inserts new element into the container if the container doesn't already contain an element with an equivalent key.
New element is constructed as
value_type(std::forward<P>(value)).Note: This overload participates in overload resolution only if
std::is_constructible<value_type, P&&>::valueistrue.Returns: The iterator component points to the inserted element or to the already existing element. The
boolcomponent istrueif insertion happened andfalseif it did not. -
iterator insert(const_iterator hint, const value_type& value);Effects: Inserts copy of
valueif the container doesn't already contain an element with an equivalent key.Iterator
hintis used as a suggestion where to start to search insert position.Returns: Iterator to the inserted element or to the already existing element.
-
iterator insert(const_iterator hint, value_type&& value);Effects: Inserts
valueusing move semantics if the container doesn't already contain an element with an equivalent key.Iterator
hintis used as a suggestion where to start to search insert position.Returns: Iterator to the inserted element or to the already existing element.
-
template <typename P> iterator insert(const_iterator hint, P&& value);Effects: Inserts new element into the container if the container doesn't already contain an element with an equivalent key.
New element is constructed as
value_type(std::forward<P>(value)).Iterator
hintis used as a suggestion where to start to search insert position.Note: This overload participates in overload resolution only if
std::is_constructible<value_type, P&&>::valueistrue.Returns: Iterator to the inserted element or to the already existing element.
-
template <typename InputIt> void insert(InputIt first, InputIt last);Effects: Inserts elements from range
[first, last)if the container doesn't already contain an element with an equivalent key.If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
The call to this function is equivalent to:
while (first != last) { insert(*first); ++first; }Note: This overload participates in overload resolution only if
InputItsatisfies requirements of LegacyInputIterator. -
void insert(std::initializer_list<value_type> ilist);Effects: Inserts elements from initializer list
ilistif the container doesn't already contain an element with an equivalent key.If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
The call to this function is equivalent to
insert(ilist.begin(), ilist.end()).
-
template <typename Range> void insert_range(Range&& range);Effects: Inserts elements from
rangeif the container doesn't already contain an element with an equivalent key.If multiple elements in the range have keys that compare equivalent, then the first element is inserted.
Note: This function is available in C++11. If compiled with C++20 or later, proper C++20 range concepts are used.
-
template <typename M> std::pair<iterator, bool> insert_or_assign(const Key& key, M&& obj); -
template <typename M> std::pair<iterator, bool> insert_or_assign(Key&& key, M&& obj); -
template <typename K, typename M> std::pair<iterator, bool> insert_or_assign(K&& key, M&& obj);Effects: If a key equivalent to
keyalready exists in the container, assignsstd::forward<M>(obj)to the mapped type corresponding to the keykey. If the key does not exist, inserts the new element.-
Overload (1): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if
std::is_assignable_v<mapped_type&, M&&>istrue. -
Overload (2): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if
std::is_assignable_v<mapped_type&, M&&>istrue. -
Overload (3): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(std::forward<K>(key)), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if all following conditions are satisfied:
- Both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey. std::is_assignable_v<mapped_type&, M&&>istrue.
- Both
Returns: The iterator component points to the inserted element or to the updated element. The
boolcomponent istrueif insertion took place andfalseif assignment took place. -
-
template <typename M> iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); -
template <typename M> iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); -
template <typename K, typename M> iterator insert_or_assign(const_iterator hint, K&& key, M&& obj);Effects: If a key equivalent to
keyalready exists in the container, assignsstd::forward<M>(obj)to the mapped type corresponding to the keykey. If the key does not exist, inserts the new element.Iterator
hintis used as a suggestion where to start to search insert position.-
Overload (4): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if
std::is_assignable_v<mapped_type&, M&&>istrue. -
Overload (5): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if
std::is_assignable_v<mapped_type&, M&&>istrue. -
Overload (6): New element is constructed as
value_type( std::piecewise_construct, std::forward_as_tuple(std::forward<K>(key)), std::forward_as_tuple(std::forward<M>(obj)) )Note: This overload participates in overload resolution only if all following conditions are satisfied:
- Both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey. std::is_assignable_v<mapped_type&, M&&>istrue.
- Both
Returns: Iterator to the element that was inserted or updated.
-
-
template <typename... Args> std::pair<iterator, bool> try_emplace(const Key& key, Args&&... args); -
template <typename... Args> std::pair<iterator, bool> try_emplace(Key&& key, Args&&... args); -
template <typename K, typename... Args> std::pair<iterator, bool> try_emplace(K&& key, Args&&... args);Effects: If a key equivalent to
keyalready exists in the container, does nothing. Otherwise, inserts a new element into the container.-
Overload (1): Behaves like
emplaceexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(std::forward<Args>(args)...) ) -
Overload (2): Behaves like
emplaceexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple(std::forward<Args>(args)...) ) -
Overload (3): Behaves like
emplaceexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(std::forward<K>(key)), std::forward_as_tuple(std::forward<Args>(args)...) )Note: This overload participates in overload resolution only if all following conditions are satisfied:
- Both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey. std::is_convertible_v<K&&, iterator>isfalse.std::is_convertible_v<K&&, const_iterator>isfalse.
- Both
Returns: The iterator component points to the inserted element or to the already existing element. The
boolcomponent istrueif insertion happened andfalseif it did not. -
-
template <typename... Args> iterator try_emplace(const_iterator hint, const Key& key, Args&&... args); -
template <typename... Args> iterator try_emplace(const_iterator hint, Key&& key, Args&&... args); -
template <typename K, typename... Args> iterator try_emplace(const_iterator hint, K&& key, Args&&... args);Effects: If a key equivalent to
keyalready exists in the container, does nothing. Otherwise, inserts a new element into the container.Iterator
hintis used as a suggestion where to start to search insert position.-
Overload (4): Behaves like
emplace_hintexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(std::forward<Args>(args)...) ) -
Overload (5): Behaves like
emplace_hintexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple(std::forward<Args>(args)...) ) -
Overload (6): Behaves like
emplace_hintexcept that the element is constructed asvalue_type( std::piecewise_construct, std::forward_as_tuple(std::forward<K>(key)), std::forward_as_tuple(std::forward<Args>(args)...) )Note: This overload participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.
Returns: Iterator to the inserted element or to the already existing element.
-
-
iterator erase(iterator pos); -
iterator erase(const_iterator pos);Effects: Removes the element at
pos.Returns: Iterator following the last removed element.
-
iterator erase(const_iterator first, const_iterator last);Effects: Removes the elements in the range
[first, last).Returns: Iterator following the last removed element.
-
size_type erase(const Key& key); -
template <typename K> size_type erase(K&& x);Effects: Removes the element (if one exists) with the key equivalent to
keyorx.Note: Overload (5) participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.Returns: Number of elements removed (0 or 1).
-
void swap(small_unordered_map& other);Effects: Exchanges the contents of the container with those of
other.
-
std::pair<iterator, iterator> equal_range(const Key& key); -
std::pair<const_iterator, const_iterator> equal_range(const Key& key) const; -
template <typename K> std::pair<iterator, iterator> equal_range(const K& x); -
template <typename K> std::pair<const_iterator, const_iterator> equal_range(const K& x) const;Effects: Returns a range containing all elements with key that compares equivalent to
keyorx.- The first iterator in pair points to the first element of range. It is equal to
end()if no such element is found. - The second iterator in pair points to the one-past-last element of range. It is equal to
end()is no such element is found.
Note: Overloads (3) and (4) participate in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows these functions to be called without constructing an instance ofKey.Complexity: Average case linear in number of elements with key that compares equivalent to
keyorx. Worst case linear insize(). - The first iterator in pair points to the first element of range. It is equal to
-
iterator find(const Key& key); -
const_iterator find(const Key& key) const; -
template <typename K> iterator find(const K& x); -
template <typename K> const_iterator find(const K& x) const;Effects: Returns an iterator pointing to the element with key equivalent to
keyorx. Returnsend()if no such element is found.Note: Overloads (3) and (4) participate in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows these functions to be called without constructing an instance ofKey.Complexity: Constant on average. Worst case linear in
size().
-
size_type count(const Key& key) const; -
template <typename K> size_type count(const K& x) const;Effects: Returns the number of elements with key equivalent to
keyorx, which is either 1 or 0 since this container does not allow duplicates.Note: Overload (2) participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.Complexity: Constant on average. Worst case linear in
size().
-
bool contains(const Key& key) const; -
template <typename K> bool contains(const K& x) const;Effects: Returns
trueif the container contains an element with key equivalent tokeyorx, otherwise returnsfalse.Note: Overload (2) participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.Complexity: Constant on average. Worst case linear in
size().
-
T& at(const Key& key); -
const T& at(const Key& key) const; -
template <typename K> T& at(const K& x); -
template <typename K> const T& at(const K& x) const;Effects: Returns a reference to the mapped value of the element with key equivalent to
keyorx. If no such element exists, an exception of typestd::out_of_rangeis thrown.Note: Overloads (3) and (4) participate in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows these functions to be called without constructing an instance ofKey.Complexity: Constant on average. Worst case linear in
size().Exceptions:
std::out_of_rangeif the container does not have an element with the specified key.
-
T& operator[](const Key& key); -
T& operator[](Key&& key); -
template <typename K> T& operator[](K&& x);Effects: Returns a reference to the value that is mapped to a key equivalent to
keyorx, performing an insertion if such key does not already exist.-
Overload (1) is equivalent to
return try_emplace(key).first->second; -
Overload (2) is equivalent to
return try_emplace(std::move(key)).first->second; -
Overload (3) is equivalent to
return try_emplace(std::forward<K>(x)).first->second;
Note: Overload (3) participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.Complexity: Constant on average. Worst case linear in
size(). -
-
local_iterator begin(size_type n) noexcept; -
const_local_iterator begin(size_type n) const noexcept; -
const_local_iterator cbegin(size_type n) const noexcept;Effects: Returns an iterator to the first element of the bucket with index
n.Complexity: Constant.
-
local_iterator end(size_type n) noexcept; -
const_local_iterator end(size_type n) const noexcept; -
const_local_iterator cend(size_type n) const noexcept;Effects: Returns an iterator to the element following the last element of the bucket with index
n. This element acts as a placeholder; attempting to access it results in undefined behavior.Complexity: Constant.
-
size_type bucket_count() const;Effects: Returns the number of buckets in the container.
Complexity: Constant.
-
size_type max_bucket_count() const;Effects: Returns the maximum number of buckets the container is able to hold due to system or library implementation limitations.
Complexity: Constant.
-
size_type bucket_size(size_type n) const;Effects: Returns the number of elements in the bucket with index
n.Complexity: Linear in the size of the bucket
n.
-
size_type bucket(const Key& key) const; -
template <typename K> size_type bucket(const K& x) const;Effects: Returns the index of the bucket for key equivalent to
keyorx.Note: Overload (2) participates in overload resolution only if both
Hash::is_transparentandKeyEqual::is_transparentexist and are valid types. This allows the function to be called without constructing an instance ofKey.Complexity: Constant.
-
float load_factor() const;Effects: Returns the average number of elements per bucket, that is,
size()divided bybucket_count().Complexity: Constant.
-
float max_load_factor() const;Effects: Returns current maximum load factor.
Complexity: Constant.
-
void max_load_factor(float mlf);Effects: Sets the maximum load factor to
mlf.Complexity: Constant.
-
void rehash(size_type count);Effects: Changes the number of buckets to a value
nthat is not less thancountand satisfiesn >= size() / max_load_factor(), then rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed.
-
void reserve(size_type count);Effects: Sets the number of buckets to the number needed to accommodate at least
countelements without exceeding maximum load factor and rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. Effectively callsrehash(std::ceil(count / max_load_factor())).
-
template <typename K, typename T, std::size_t N, std::size_t M, typename H, typename E, typename A> bool operator== ( const small_unordered_map<K, T, N, M, H, E, A>& x, const small_unordered_map<K, T, N, M, H, E, A>& y );Effects: Compares the contents of two containers.
Returns: Returns
trueif the contents of thexandyare equal,falseotherwise.
-
template <typename K, typename T, std::size_t N, std::size_t M, typename H, typename E, typename A> bool operator!= ( const small_unordered_map<K, T, N, M, H, E, A>& x, const small_unordered_map<K, T, N, M, H, E, A>& y );Effects: Compares the contents of two containers.
Returns: Returns
trueif the contents of thexandyare not equal,falseotherwise.
-
template <typename K, typename T, std::size_t N, std::size_t M, typename H, typename E, typename A> void swap ( small_unordered_map<K, T, N, M, H, E, A>& x, small_unordered_map<K, T, N, M, H, E, A>& y );Effects: Swaps the contents of
xandy. Callsx.swap(y).
-
template <typename K, typename T, std::size_t N, std::size_t M, typename H, typename E, typename A, typename Predicate> typename small_unordered_map<K, T, N, M, H, E, A>::size_type erase_if(small_unordered_map<K, T, N, M, H, E, A>& c, Predicate pred);Effects: Erases all elements that satisfy the predicate
predfrom the container.predis unary predicate which returnstrueif the element should be removed.Returns: The number of erased elements.
End of document.