std::unordered_map::try_emplace

template <class... Args> pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); (1) (since C++17) template <class... Args> pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); (2) (since C++17) template <class... Args> iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); (3) (since C++17) template <class... Args> iterator try_emplace(const_iterator hin

std::unordered_map::rehash

void rehash( size_type count ); (since C++11) Sets the number of buckets to count and rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. If the new number of buckets makes load factor more than maximum load factor (count < size() / max_load_factor()), then the new number of buckets is at least size() / max_load_factor(). Parameters count - new number of buckets Return value (none). Complexity

std::unordered_map::size

size_type size() const; (since C++11) Returns the number of elements in the container, i.e. std::distance(begin(), end()). Parameters (none). Return value The number of elements in the container. Exceptions noexcept specification: noexcept Complexity Constant. Example The following code uses size to display the number of elements in a std::unordered_map: #include <unordered_map> #include <iostream> int main() { std::unordered_map<int,char> nums

std::unordered_map::swap

void swap( unordered_map& other ); (since C++11) Exchanges the contents of the container with those of other. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. The Hash and KeyEqual objects must be Swappable, and they are exchanged using unqualified calls to non-member swap. If std::allocator_traits<allocator_type>::propagate_on_container_swap::value is true, then the

std::unordered_map::reserve

void reserve( size_type count ); (since C++11) Sets the number of buckets to the number needed to accomodate at least count elements 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 calls rehash(std::ceil(count / max_load_factor())). Parameters count - new capacity of the container Return value (none). Complexity Average case linear in the s

std::unordered_map::operator[]

T& operator[]( const Key& key ); (1) (since C++11) T& operator[]( Key&& key ); (2) (since C++11) Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion if such key does not already exist. 1) Inserts a value_type object constructed in-place from std::piecewise_construct, std::forward_as_tuple(key), std::tuple<>() if the key does not exist. This function is equivalent to return this->try_emplace(key).first-&

std::unordered_map::key_eq

key_equal key_eq() const; (since C++11) Returns the function that compares keys for equality. Parameters (none). Return value The key comparison function. Complexity Constant. See also hash_function returns function used to hash the keys (public member function)

std::unordered_map::max_bucket_count

size_type max_bucket_count() const; (since C++11) Returns the maximum number of buckets the container is able to hold due to system or library implementation limitations. Parameters (none). Return value Maximum number of buckets. Complexity Constant. See also bucket_count returns the number of buckets (public member function)

std::unordered_map::max_size

size_type max_size() const; (since C++11) Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container. Parameters (none). Return value Maximum number of elements. Exceptions noexcept specification: noexcept Complexity Constant. Notes This value is typically equal to std::numeric_limits<size_type>::max(), and reflects the theoretical limit on t

std::unordered_map::load_factor

float load_factor() const; (since C++11) Returns the average number of elements per bucket. Parameters (none). Return value Average number of elements per bucket. Complexity Constant. See also max_load_factor manages maximum average number of elements per bucket (public member function)