STD::UNORDERED_MULTIMAP(3cxx)

โœจ NAME โœจ

okay bestie, quick vibe check: this is the (3cxx) manual page for std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >, and the manual name is folded right in here so we can skip the boring header repeat. Itโ€™s a standard container composed of equivalent keys โ€” possibly multiple of each key value โ€” that associates values of another type with the keys. no cap, thatโ€™s the whole assignment. ๐Ÿ’–


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <unordered_map>

๐ŸŽ€ Public Types ๐ŸŽ€

okay these typedefs are lowkey the backbone of the whole thing. first up:

  • using node_type = typename _Hashtable::node_type โ€” node type, slay.

Public typedefs. the public typedef squad:

  • typedef _Hashtable::key_type key_type โ€” Public typedefs.
  • typedef _Hashtable::value_type value_type โ€” Public typedefs.
  • typedef _Hashtable::mapped_type mapped_type โ€” Public typedefs.
  • typedef _Hashtable::hasher hasher โ€” Public typedefs.
  • typedef _Hashtable::key_equal key_equal โ€” Public typedefs.
  • typedef _Hashtable::allocator_type allocator_type โ€” Public typedefs.

Iterator-related typedefs. different flock, same icon energy:

  • typedef _Hashtable::pointer pointer โ€” Iterator-related typedefs.
  • typedef _Hashtable::const_pointer const_pointer โ€” Iterator-related typedefs.
  • typedef _Hashtable::reference reference โ€” Iterator-related typedefs.
  • typedef _Hashtable::const_reference const_reference โ€” Iterator-related typedefs.
  • typedef _Hashtable::iterator iterator โ€” Iterator-related typedefs.
  • typedef _Hashtable::const_iterator const_iterator โ€” Iterator-related typedefs.
  • typedef _Hashtable::local_iterator local_iterator โ€” Iterator-related typedefs.
  • typedef _Hashtable::const_local_iterator const_local_iterator โ€” Iterator-related typedefs.
  • typedef _Hashtable::size_type size_type โ€” Iterator-related typedefs.
  • typedef _Hashtable::difference_type difference_type โ€” Iterator-related typedefs.

๐Ÿ’… Public Member Functions ๐Ÿ’…

this is the long part, bestie โ€” Iโ€™m splitting it into little group-chat threads so it doesnโ€™t eat the whole timeline. every signature is here, exactly as the page gives it. ๐Ÿซถ

๐Ÿผ Constructors ๐Ÿผ

  • unordered_multimap ()=default โ€” Default constructor.
  • template<typename _InputIterator > unordered_multimap (_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type &__a) โ€” range constructor, signature-only moment.
  • template<typename _InputIterator > unordered_multimap (_InputIterator __first, _InputIterator __last, size_type __n, const hasher &__hf, const allocator_type &__a) โ€” range constructor, signature-only moment.
  • template<typename _InputIterator > unordered_multimap (_InputIterator __first, _InputIterator __last, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) โ€” Builds an unordered_multimap from a range.
  • unordered_multimap (const allocator_type &__a) โ€” Creates an unordered_multimap with no elements.
  • unordered_multimap (const unordered_multimap &)=default โ€” Copy constructor.
  • unordered_multimap (const unordered_multimap &__ummap, const allocator_type &__a) โ€” signature-only moment.
  • unordered_multimap (initializer_list< value_type > __l, size_type __n, const allocator_type &__a) โ€” signature-only moment.
  • unordered_multimap (initializer_list< value_type > __l, size_type __n, const hasher &__hf, const allocator_type &__a) โ€” signature-only moment.
  • unordered_multimap (initializer_list< value_type > __l, size_type __n=0, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) โ€” Builds an unordered_multimap from an initializer_list.
  • unordered_multimap (size_type __n, const allocator_type &__a) โ€” signature-only moment.
  • unordered_multimap (size_type __n, const hasher &__hf, const allocator_type &__a) โ€” signature-only moment.
  • unordered_multimap (size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type()) โ€” Default constructor creates no elements.
  • unordered_multimap (unordered_multimap &&)=default โ€” Move constructor.
  • unordered_multimap (unordered_multimap &&__ummap, const allocator_type &__a) noexcept(noexcept(_Hashtable(std::move(__ummap._M_h), __a))) โ€” signature-only moment.

โœจ Everything Else, In Order โœจ

these are the rest of the member functions, bestie, and yes Iโ€™m keeping the order because we are respectful like that:

  • iterator begin () noexcept โ€” signature-only moment.
  • local_iterator begin (size_type __n) โ€” Returns a read/write iterator pointing to the first bucket element.
  • size_type bucket (const key_type &__key) const โ€” signature-only moment.
  • size_type bucket_count () const noexcept โ€” Returns the number of buckets of the unordered_multimap.
  • size_type bucket_size (size_type __n) const โ€” signature-only moment.
  • void clear () noexcept โ€” signature-only moment.
  • template<typename... _Args> iterator emplace (_Args &&... __args) โ€” Attempts to build and insert a std::pair into the unordered_multimap.
  • template<typename... _Args> iterator emplace_hint (const_iterator __pos, _Args &&... __args) โ€” Attempts to build and insert a std::pair into the unordered_multimap.
  • bool empty () const noexcept โ€” Returns true if the unordered_multimap is empty.
  • iterator end () noexcept โ€” signature-only moment.
  • local_iterator end (size_type __n) โ€” Returns a read/write iterator pointing to one past the last bucket elements.
  • size_type erase (const key_type &__x) โ€” Erases elements according to the provided key.
  • iterator erase (const_iterator __first, const_iterator __last) โ€” Erases a [__first,__last) range of elements from an unordered_multimap.
  • node_type extract (const key_type &__key) โ€” Extract a node.
  • node_type extract (const_iterator __pos) โ€” Extract a node.
  • allocator_type get_allocator () const noexcept โ€” Returns the allocator object used by the unordered_multimap.
  • hasher hash_function () const โ€” Returns the hash functor object with which the unordered_multimap was constructed.
  • template<typename _InputIterator > void insert (_InputIterator __first, _InputIterator __last) โ€” A template function that attempts to insert a range of elements.
  • iterator insert (const_iterator __hint, node_type &&__nh) โ€” Re-insert an extracted node.
  • void insert (initializer_list< value_type > __l) โ€” Attempts to insert a list of elements into the unordered_multimap.
  • iterator insert (node_type &&__nh) โ€” Re-insert an extracted node.
  • key_equal key_eq () const โ€” Returns the key comparison object with which the unordered_multimap was constructed.
  • float load_factor () const noexcept โ€” Returns the average number of elements per bucket.
  • size_type max_bucket_count () const noexcept โ€” Returns the maximum number of buckets of the unordered_multimap.
  • float max_load_factor () const noexcept โ€” Returns a positive number that the unordered_multimap tries to keep the load factor less than or equal to.
  • void max_load_factor (float __z) โ€” Change the unordered_multimap maximum load factor.
  • size_type max_size () const noexcept โ€” Returns the maximum size of the unordered_multimap.
  • template<typename _H2 , typename _P2 > void merge (unordered_map< _Key, _Tp, _H2, _P2, _Alloc > &&__source) โ€” merge overload, signature-only moment.
  • template<typename _H2 , typename _P2 > void merge (unordered_map< _Key, _Tp, _H2, _P2, _Alloc > &__source) โ€” merge overload, signature-only moment.
  • template<typename _H2 , typename _P2 > void merge (unordered_multimap< _Key, _Tp, _H2, _P2, _Alloc > &&__source) โ€” merge overload, signature-only moment.
  • template<typename _H2 , typename _P2 > void merge (unordered_multimap< _Key, _Tp, _H2, _P2, _Alloc > &__source) โ€” merge overload, signature-only moment.
  • unordered_multimap & operator= (const unordered_multimap &)=default โ€” Copy assignment operator.
  • unordered_multimap & operator= (initializer_list< value_type > __l) โ€” Unordered_multimap list assignment operator.
  • unordered_multimap & operator= (unordered_multimap &&)=default โ€” Move assignment operator.
  • void rehash (size_type __n) โ€” May rehash the unordered_multimap.
  • void reserve (size_type __n) โ€” Prepare the unordered_multimap for a specified number of elements.
  • size_type size () const noexcept โ€” Returns the size of the unordered_multimap.
  • void swap (unordered_multimap &__x) noexcept(noexcept(_M_h.swap(__x._M_h))) โ€” Swaps data with another unordered_multimap.

๐Ÿซถ The Extra Indented Squad ๐Ÿซถ

these came indented on the page, so here they are in their own little thread:

  • const_iterator begin () const noexcept โ€” signature-only moment.
  • const_iterator cbegin () const noexcept โ€” signature-only moment.
  • const_iterator end () const noexcept โ€” signature-only moment.
  • const_iterator cend () const noexcept โ€” signature-only moment.
  • iterator insert (const value_type &__x) โ€” Inserts a std::pair into the unordered_multimap.
  • iterator insert (value_type &&__x) โ€” Inserts a std::pair into the unordered_multimap.
  • template<typename _Pair > __enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert (_Pair &&__x) โ€” Inserts a std::pair into the unordered_multimap.
  • iterator insert (const_iterator __hint, const value_type &__x) โ€” Inserts a std::pair into the unordered_multimap.
  • iterator insert (const_iterator __hint, value_type &&__x) โ€” Inserts a std::pair into the unordered_multimap.
  • template<typename _Pair > __enable_if_t< is_constructible< value_type, _Pair && >::value, iterator > insert (const_iterator __hint, _Pair &&__x) โ€” Inserts a std::pair into the unordered_multimap.
  • iterator erase (const_iterator __position) โ€” Erases an element from an unordered_multimap.
  • iterator erase (iterator __position) โ€” Erases an element from an unordered_multimap.
  • iterator find (const key_type &__x) โ€” Tries to locate an element in an unordered_multimap.
  • template<typename _Kt > auto find (const _Kt &__x) -> decltype(_M_h._M_find_tr(__x)) โ€” Tries to locate an element in an unordered_multimap.
  • const_iterator find (const key_type &__x) const โ€” Tries to locate an element in an unordered_multimap.
  • template<typename _Kt > auto find (const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x)) โ€” Tries to locate an element in an unordered_multimap.
  • size_type count (const key_type &__x) const โ€” Finds the number of elements.
  • template<typename _Kt > auto count (const _Kt &__x) const -> decltype(_M_h._M_count_tr(__x)) โ€” Finds the number of elements.
  • bool contains (const key_type &__x) const โ€” Finds whether an element with the given key exists.
  • template<typename _Kt > auto contains (const _Kt &__x) const -> decltype(_M_h._M_find_tr(__x), void(), true) โ€” Finds whether an element with the given key exists.
  • std::pair< iterator, iterator > equal_range (const key_type &__x) โ€” Finds a subsequence matching given key.
  • template<typename _Kt > auto equal_range (const _Kt &__x) -> decltype(_M_h._M_equal_range_tr(__x)) โ€” Finds a subsequence matching given key.
  • std::pair< const_iterator, const_iterator > equal_range (const key_type &__x) const โ€” Finds a subsequence matching given key.
  • template<typename _Kt > auto equal_range (const _Kt &__x) const -> decltype(_M_h._M_equal_range_tr(__x)) โ€” Finds a subsequence matching given key.
  • const_local_iterator begin(size_type __n) const โ€” gives you a read-only (constant) iterator pointing at the first element in that bucket. ๐Ÿชฃ
  • const_local_iterator cbegin(size_type __n) const โ€” same energy, same deal: a read-only (constant) iterator pointing at the first element of the bucket. โœจ
  • const_local_iterator end(size_type __n) const โ€” read-only (constant) iterator pointing at one past the last element of that bucket. classic off-the-end behavior, no cap. ๐Ÿซถ
  • const_local_iterator cend(size_type __n) const โ€” and here's the c twin: read-only (constant) iterator pointing one past the last bucket elements. ๐Ÿ’ซ

๐Ÿซ‚ Friends

okay so this container is friends with these two, they get the keys to the group chat ๐Ÿ”‘

  • ```cpp template<typename _Key1, typename _Tp1, typename _Hash1, typename _Pred1, typename _Alloc1> bool operator==(const unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, const unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)
- ```cpp
template<typename, typename, typename> class std::_Hash_merge_helper

๐Ÿ’– Detailed Description

okay bestie, here's the whole entire vibe of the class. it lives in this template:

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>, typename _Pred = equal_to<_Key>, typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
class std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>

and what it is: "A standard container composed of equivalent keys (possibly containing multiple of each key value) that associates values of another type with the keys." no cap, that's the whole personality ๐Ÿ’…

Since: C++11 โณ

๐ŸŽ€ Template Parameters

  • _Key โ€” type of key objects. ๐Ÿ”‘
  • _Tp โ€” type of mapped objects. ๐Ÿ—บ๏ธ
  • _Hash โ€” hashing function object type, defaults to hash<_Value>. ๐ŸŒ€
  • _Pred โ€” predicate function object type, defaults to equal_to<_Value>. โš–๏ธ
  • _Alloc โ€” allocator type, defaults to std::allocator<std::pair<const _Key, _Tp>>. ๐Ÿงบ

it Meets the requirements of a container, and unordered associative container โ€” it's giving qualified icon behavior ๐Ÿ‘‘

the resulting value type of the container is std::pair<const _Key, _Tp>. periodt.

base is _Hashtable, dispatched at compile time via template alias __ummap_hashtable. iykyk ๐Ÿงš


๐ŸŒธ Member Typedef Documentation

everything below is nested in this template, so like, imagine this line wrapped around each one of them:

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>, typename _Pred = equal_to<_Key>, typename _Alloc = allocator<std::pair<const _Key, _Tp>>>

๐Ÿ’– Public typedefs

  • allocator_type โ€” typedef _Hashtable::allocator_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::allocator_type ๐Ÿงบ
  • hasher โ€” typedef _Hashtable::hasher std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hasher ๐ŸŒ€
  • key_equal โ€” typedef _Hashtable::key_equal std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::key_equal โš–๏ธ
  • key_type โ€” typedef _Hashtable::key_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type ๐Ÿ”‘
  • mapped_type โ€” typedef _Hashtable::mapped_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type ๐Ÿ—บ๏ธ
  • value_type โ€” typedef _Hashtable::value_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::value_type ๐Ÿ’Ž
  • const_iterator โ€” typedef _Hashtable::const_iterator std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator ๐Ÿซถ
  • const_local_iterator โ€” typedef _Hashtable::const_local_iterator std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_local_iterator ๐Ÿชฃ
  • const_pointer โ€” typedef _Hashtable::const_pointer std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_pointer ๐ŸŽฏ
  • const_reference โ€” typedef _Hashtable::const_reference std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_reference ๐Ÿ“
  • difference_type โ€” typedef _Hashtable::difference_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::difference_type โž–
  • iterator โ€” typedef _Hashtable::iterator std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator โœจ
  • local_iterator โ€” typedef _Hashtable::local_iterator std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::local_iterator ๐Ÿชฃ
  • pointer โ€” typedef _Hashtable::pointer std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::pointer ๐Ÿ‘‰
  • reference โ€” typedef _Hashtable::reference std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::reference ๐Ÿซด
  • size_type โ€” typedef _Hashtable::size_type std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type ๐Ÿ“

๐Ÿงš Constructor & Destructor Documentation

bestie there are six whole ways to bring one of these into existence and each one has main character energy. all of them sit inside the same class template:

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>, typename _Pred = equal_to<_Key>, typename _Alloc = allocator<std::pair<const _Key, _Tp>>>

โญ the plain one

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap() [default]

Default constructor. that's it, that's the whole thing. ๐Ÿ’…

โญ the one where you say how many buckets

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) [inline], [explicit]

Default constructor creates no elements. (yes the manpage really says "Default constructor creates no elements" here, we are not making the rules, we're just relaying them ๐Ÿ™ˆ)

Parameters

  • __n โ€” Mnimal initial number of buckets. (their typo, not mine, i'm leaving it exactly as it is ๐Ÿ’€)
  • __hf โ€” a hash functor.
  • __eql โ€” a key equality functor.
  • __a โ€” an allocator object.

โญ the range one

template<typename _InputIterator> std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) [inline]

Builds an unordered_multimap from a range. ๐ŸŒˆ

Parameters

  • __first โ€” an input iterator.
  • __last โ€” an input iterator.
  • __n โ€” minimal initial number of buckets.
  • __hf โ€” a hash functor.
  • __eql โ€” a key equality functor.
  • __a โ€” an allocator object.

Create an unordered_multimap consisting of copies of the elements from [__first,__last). this is linear in N (where N is distance(__first,__last)). so like, don't be surprised when it takes a sec on a big range, ok? โณ

โญ the copy one

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&) [default]

Copy constructor. twin behavior ๐Ÿซถ๐Ÿซถ

โญ the move one

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&&) [default]

Move constructor. it's leaving the old one on read, iconic ๐Ÿš€

โญ the allocator-only one

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const allocator_type& __a) [inline], [explicit]

Creates an unordered_multimap with no elements. empty. blank. a fresh start. ๐ŸŽ€

Parameters

  • __a โ€” an allocator object.

โญ the initializer_list one

std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(initializer_list<value_type> __l, size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) [inline]

Builds an unordered_multimap from an initializer_list. the curly-brace brat era ๐Ÿ’š

Parameters

  • __l โ€” an initializer_list.
  • __n โ€” minimal initial number of buckets.
  • __hf โ€” a hash functor.
  • __eql โ€” a key equality functor.
  • __a โ€” an allocator object.

Create an unordered_multimap consisting of copies of the elements in the list. this is linear in N (where N is __l.size()). slay, math. ๐Ÿ”ฅ


โœจ Member Function Documentation

๐Ÿฆ‹ begin (const)

const_iterator std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::begin() const [inline], [noexcept]

Returns a read-only (constant) iterator that points to the first element in the unordered_multimap. it's noexcept, it's inline, it's literally the opening number of the whole container ๐Ÿ˜ญ๐Ÿ’–


begin() ๐ŸŒธ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::begin ()
    [inline], [noexcept]

okay so this one hands you a read/write iterator that points at the first element in the unordered_multimap. that's it, that's the whole vibe. first element. go get 'em bestie ๐Ÿ’…


begin(size_type __n) โ€” the bucket one ๐Ÿชฃ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::begin
    (size_type __n) [inline]

gives you a read/write iterator pointing at the first bucket element. yes, buckets have their own little iterators, they're like the local friend group of iterators, iykyk โœจ

  • Parameters
    • __n โ€” the bucket index ๐ŸŽ€
  • Returns
    • a read/write <italics>local</italics> iterator ๐Ÿซถ

begin(size_type __n) const โ€” const bucket era ๐Ÿฆ‹

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::begin
    (size_type __n) const [inline]

same bucket energy but make it read-only โ€” a read-only (constant) iterator pointing at the first bucket element. no writing, only looking. like window shopping ๐Ÿ˜ญ

  • Parameters
    • __n โ€” the bucket index ๐Ÿ“
  • Returns
    • a read-only <italics>local</italics> iterator ๐Ÿ’œ

bucket_count() ๐Ÿชฃโœจ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> size_type
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::bucket_count ()
    const [inline], [noexcept]

returns the number of buckets in the unordered_multimap. that's literally it. how many buckets. slay ๐ŸŽ€


cbegin() ๐Ÿ‘‘

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::cbegin ()
    const [inline], [noexcept]

the const version of begin() โ€” returns a read-only (constant) iterator pointing at the first element in the unordered_multimap. the "c" stands for can't touch this ๐Ÿ’…โœจ


cbegin(size_type __n) ๐ŸŒˆ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::cbegin
    (size_type __n) const [inline]

read-only local iterator pointing at the first bucket element. bucket but const. iconic behavior honestly ๐Ÿงš

  • Parameters
    • __n โ€” the bucket index ๐ŸŽ€
  • Returns
    • a read-only <italics>local</italics> iterator ๐Ÿ’–

cend() ๐ŸŒ™

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::cend ()
    const [inline], [noexcept]

returns a read-only (constant) iterator pointing one past the last element in the unordered_multimap. the classic past-the-end spot, no elements live there, it's purely a landmark ๐Ÿ—บ๏ธ

Referenced by std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert() ๐Ÿ”

cend(size_type __n) ๐Ÿซง

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::cend
    (size_type __n) const [inline]

read-only (constant) iterator pointing to one past the last bucket elements. yep, plural "elements" โ€” that's exactly how the original says it, no cap ๐Ÿซถ

  • Parameters
    • __n โ€” the bucket index ๐Ÿ“
  • Returns
    • a read-only <italics>local</italics> iterator ๐Ÿ’œ

clear() ๐Ÿ’€๐Ÿงน

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> void
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::clear ()
    [inline], [noexcept]

erases all elements in an unordered_multimap. poof, gone, that's the tweet ๐Ÿ”ฅ

โš ๏ธ real talk bestie: this function only erases the elements. if the elements themselves are pointers, the pointed-to memory is not touched in any way. managing the pointer is the user's responsibility. so likeโ€ฆ don't come crying to me when your news leak, okay? ๐Ÿ˜ญ๐Ÿ’…

contains(const _Kt& __x) โ€” the templated one ๐Ÿ”Ž

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt> auto
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::contains
    (const _Kt & __x) const -> decltype(_M_h._M_find_tr(__x), void(), true)
    [inline]

finds whether an element with the given key exists. yes/no. does it exist. that's the whole function โœจ

  • Parameters
    • __x โ€” key of elements to be located ๐ŸŽ€
  • Returns
    • True if there is any element with the specified key ๐Ÿ‘‘

contains(const key_type& __x) ๐ŸŒธ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> bool
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::contains
    (const key_type & __x) const [inline]

same thing, the non-template twin โ€” finds whether an element with the given key exists ๐Ÿฆ‹

  • Parameters
    • __x โ€” key of elements to be located ๐Ÿ“
  • Returns
    • True if there is any element with the specified key ๐Ÿ’–

count(const _Kt& __x) โ€” templated counting ๐Ÿ”ข

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt> auto
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::count
    (const _Kt & __x) const -> decltype(_M_h._M_count_tr(__x))
    [inline]

finds the number of elements. and because this is a <italics>multi</italics>map, that number can absolutely be more than one โ€” duplicates are kind of the whole point here ๐Ÿ‘‘โœจ

  • Parameters
    • __x โ€” key to count ๐ŸŽ€
  • Returns
    • number of elements with specified key ๐ŸŒˆ

count(const key_type& __x) ๐Ÿ”ข๐Ÿ’œ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> size_type
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::count
    (const key_type & __x) const [inline]

the non-template version โ€” finds the number of elements ๐Ÿซถ

  • Parameters
    • __x โ€” key to count ๐Ÿ“
  • Returns
    • number of elements with specified key ๐Ÿ’…

emplace(_Args&&... __args) ๐Ÿ› ๏ธโœจ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename... _Args>
iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc
    >::emplace (_Args &&... __args) [inline]

attempts to build and insert a std::pair into the unordered_multimap. like, it constructs it right there in place, no awkward middleman, main character energy ๐Ÿ˜Œ

  • Parameters
    • __args โ€” arguments used to generate a new pair instance (see std::piecewise_contruct for passing arguments to each part of the pair constructor) ๐ŸŽ€
  • Returns
    • an iterator that points to the inserted pair ๐Ÿฆ‹

this function attempts to build and insert a (key, value) pair into the unordered_multimap.

insertion requires amortized constant time โšก


emplace_hint(const_iterator __pos, _Args&&... __args) ๐ŸŽฏ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename... _Args>
iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc
    >::emplace_hint (const_iterator __pos, _Args &&... __args) [inline]

attempts to build and insert a std::pair into the unordered_multimap โ€” but this time you're allowed to drop a hint ๐Ÿ˜ฎโ€๐Ÿ’จ

  • Parameters
    • __pos โ€” an iterator that serves as a <italics>hint</italics> as to where the pair should be inserted ๐ŸŽ€
    • __args โ€” arguments used to generate a new pair instance (see std::piecewise_contruct for passing arguments to each part of the pair constructor) ๐Ÿ“
  • Returns
    • an iterator that points to the element with key of the std::pair built from __args ๐Ÿ’–
note: the first parameter is only a hint and can potentially improve the performance of the insertion process. a bad hint would cause no gains in efficiency โ€” so it's giving "helpful suggestion," not "command" ๐Ÿ™ˆ

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting ๐Ÿงš

insertion requires amortized constant time โšก


empty() ๐Ÿซ™

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> bool
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::empty ()
    const [inline], [noexcept]

returns true if the unordered_multimap is empty. that's it. vibe check: is it void? ๐Ÿ’€


end() const ๐ŸŒ™

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::end ()
    const [inline], [noexcept]

returns a read-only (constant) iterator pointing one past the last element in the unordered_multimap ๐Ÿ’œ


end() ๐ŸŒ™๐Ÿ’ซ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::end ()
    [inline], [noexcept]

returns a read/write iterator pointing one past the last element in the unordered_multimap ๐Ÿซถ

Referenced by std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::extract() ๐Ÿ”

end(size_type __n) ๐Ÿชฃ๐ŸŒ™

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::end
    (size_type __n) [inline]

returns a read/write iterator pointing to one past the last bucket elements ๐ŸŒˆ

  • Parameters
    • __n โ€” the bucket index ๐ŸŽ€
  • Returns
    • a read/write <italics>local</italics> iterator ๐Ÿ“

end(size_type __n) const ๐Ÿชฃ๐Ÿ’œ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> const_local_iterator
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::end
    (size_type __n) const [inline]

returns a read-only (constant) iterator pointing to one past the last bucket elements ๐Ÿงš

  • Parameters
    • __n โ€” the bucket index ๐Ÿ“
  • Returns
    • a read-only <italics>local</italics> iterator ๐Ÿ’–

equal_range(const _Kt& __x) โ€” non-const ๐ŸŒธ๐Ÿ”Ž

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt> auto
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::equal_range
    (const _Kt & __x) -> decltype(_M_h._M_equal_range_tr(__x))
    [inline]

finds a subsequence matching given key ๐Ÿฆ‹

  • Parameters
    • __x โ€” key to be located ๐ŸŽ€
  • Returns
    • pair of iterators that <italics>possibly</italics> points to the subsequence matching given key ๐Ÿ‘‘

equal_range(const _Kt& __x) const โ€” const twin ๐Ÿฆ‹๐Ÿ’œ

template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
    typename _Pred = equal_to<_Key>, typename _Alloc =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt> auto
std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::equal_range
    (const _Kt & __x) const -> decltype(_M_h._M_equal_range_tr(__x))
    [inline]

same find-a-subsequence-matching-given-key behavior, just const'd ๐Ÿ˜Œ

  • Parameters
    • __x โ€” key to be located ๐Ÿ“
  • Returns
    • pair of iterators that <italics>possibly</italics> points to the subsequence matching given key ๐Ÿ’–

๐Ÿ’… equal_range โ€” the mutable one

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> std::pair< iterator, iterator >
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::equal_range
    (const key_type & __x) [inline]

Bestie, this one hunts down the whole subsequence that matches the key you hand it. Yes, a subsequence โ€” because this is a multimap, remember? Multiple entries per key is literally the whole point ๐Ÿ’…

  • Parameters
    • __x โ€” the key you're looking for.
  • Returns
    • a pair of iterators that possibly points to the subsequence matching the given key.

It's giving "range, but make it a pair." Obsessed. ๐ŸŽ€


๐Ÿฆ‹ equal_range โ€” the const twin

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> std::pair< const_iterator,
    const_iterator > std::unordered_multimap< _Key, _Tp, _Hash, _Pred,
    _Alloc >::equal_range (const key_type & __x) const [inline]

Same exact energy as above, just const-correct so nobody gets any ideas about mutating through your iterators โœจ

  • Parameters
    • __x โ€” key to be located.
  • Returns
    • pair of iterators that possibly points to the subsequence matching given key.

๐Ÿ”ฅ erase โ€” by key (the dramatic one)

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> size_type
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::erase (const
    key_type & __x) [inline]

Erases elements according to the key you provide. Not one element โ€” all of them for that key. It's a purge, a clean slate, main character energy ๐Ÿ’€

  • Parameters
    • __x โ€” key of the elements to be erased.
  • Returns
    • the number of elements erased.

This function erases all the elements located by the given key from an unordered_multimap. Heads up though: this function only erases the element itself, so if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing that pointer? That's on you, bestie. ๐Ÿซถ


๐ŸŒธ erase โ€” by range [__first,__last)

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::erase (const_iterator __first,
    const_iterator __last) [inline]

Erases a [__first,__last) range of elements from an unordered_multimap. Half-open range, iconic behaviour, no notes โœจ

  • Parameters
    • __first โ€” iterator pointing to the start of the range to be erased.
    • __last โ€” iterator pointing to the end of the range to be erased.
  • Returns
    • the iterator __last.

This function erases a sequence of elements from an unordered_multimap. Same caveat as always, and it's a big one: this function only erases the elements, so if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. Don't forget it ๐Ÿ˜ญ


๐Ÿ’œ erase โ€” single element, const_iterator flavour

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::erase (const_iterator __position)
    [inline]

Erases an element from an unordered_multimap. Just the one. So surgical. ๐Ÿ’…

  • Parameters
    • __position โ€” an iterator pointing to the element to be erased.
  • Returns
    • an iterator pointing to the element immediately following __position prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from an unordered_multimap. And yeah, say it with me: this function only erases the element, and if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility ๐Ÿ”ฅ


๐ŸŒˆ erase โ€” single element, plain iterator flavour

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::erase (iterator __position) [inline]

Same deal as the one above, just taking a non-const iterator. Twin behaviour, zero surprises.

  • Parameters
    • __position โ€” an iterator pointing to the element to be erased.
  • Returns
    • an iterator pointing to the element immediately following __position prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from an unordered_multimap. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility โญ


๐Ÿงš extract โ€” by key

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> node_type
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::extract
    (const key_type & __key) [inline]

Extract a node. That's it, that's the whole description. Short king behaviour ๐Ÿ‘‘


๐Ÿ“ extract โ€” by iterator position

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> node_type
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::extract
    (const_iterator __pos) [inline]

Extract a node. (Same two-word energy, different entry point โœจ)

References std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::end().


๐ŸŽ€ find โ€” transparent overload, non-const

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt > auto
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::find (const
    _Kt & __x) -> decltype(_M_h._M_find_tr(__x))
          [inline]"

Tries to locate an element in an unordered_multimap. (Yes, that trailing quote is literally in the docs. We leave artifacts alone. ๐Ÿ™ˆ)

  • Parameters
    • __x โ€” key to be located.
  • Returns
    • iterator pointing to the sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful, the function returns an iterator pointing to the sought-after element. If unsuccessful, it returns the past-the-end (end()) iterator. Lowkey the most-used function in the whole container, ngl ๐Ÿ’…


๐Ÿฆ‹ find โ€” transparent overload, const

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Kt > auto
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::find (const
    _Kt & __x) const -> decltype(_M_h._M_find_tr(__x))
          [inline]"

Tries to locate an element in an unordered_multimap. Const version, same quest ๐Ÿซถ

  • Parameters
    • __x โ€” key to be located.
  • Returns
    • iterator pointing to the sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful, the function returns an iterator pointing to the sought-after element. If unsuccessful, it returns the past-the-end (end()) iterator.


๐Ÿ”ฅ find โ€” plain key_type, non-const

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::find (const key_type & __x) [inline]

Tries to locate an element in an unordered_multimap.

  • Parameters
    • __x โ€” key to be located.
  • Returns
    • iterator pointing to the sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful, the function returns an iterator pointing to the sought-after element. If unsuccessful, it returns the past-the-end (end()) iterator.


๐ŸŒธ find โ€” plain key_type, const

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> const_iterator
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::find (const
    key_type & __x) const [inline]

Tries to locate an element in an unordered_multimap. Last of the four, we ate ๐Ÿ’…

  • Parameters
    • __x โ€” key to be located.
  • Returns
    • iterator pointing to the sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful, the function returns an iterator pointing to the sought-after element. If unsuccessful, it returns the past-the-end (end()) iterator.


๐Ÿ‘‘ get_allocator

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> allocator_type
    std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc
    >::get_allocator () const [inline],  [noexcept]

Returns the allocator object used by the unordered_multimap. Short, sweet, noexcept โ€” the holy trinity โœจ


๐Ÿ’œ hash_function

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> hasher std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::hash_function () const [inline]

Returns the hash functor object with which the unordered_multimap was constructed. Like, the actual hasher it was born with ๐ŸŽ€


๐ŸŒˆ insert โ€” range insert

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> template<typename _InputIterator
    > void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc
    >::insert (_InputIterator __first, _InputIterator __last) [inline]

A template function that attempts to insert a range of elements. "Attempts" โ€” cute, it's trying its best ๐Ÿซถ

  • Parameters
    • __first โ€” iterator pointing to the start of the range to be inserted.
    • __last โ€” iterator pointing to the end of the range.
  • Complexity
    • similar to that of the range constructor.

โญ insert โ€” perfect-forwarded pair

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Pair >
    __enable_if_t< is_constructible< value_type, _Pair && >::value, iterator
    > std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert
    (_Pair && __x) [inline]

Inserts a std::pair into the unordered_multimap. Note the SFINAE gatekeeping โ€” it only shows up if is_constructible< value_type, _Pair && >::value is true. We love a conditional icon ๐Ÿ’…

  • Parameters
    • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).
  • Returns
    • an iterator that points to the inserted pair.

Insertion requires amortized constant time. Fr fr, it's fast ๐Ÿ”ฅ


๐Ÿงš insert โ€” const value_type reference

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap<
    _Key, _Tp, _Hash, _Pred, _Alloc >::insert (const value_type & __x)
    [inline]

Inserts a std::pair into the unordered_multimap. The classic, the original, the blueprint ๐ŸŽ€

  • Parameters
    • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).
  • Returns
    • an iterator that points to the inserted pair.

Insertion requires amortized constant time.


๐Ÿ“ insert โ€” with a hint

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>,
    typename _Pred  = equal_to<_Key>, typename _Alloc  =
    allocator<std::pair<const _Key, _Tp>>> template<typename _Pair >
    __enable_if_t< is_constructible< value_type, _Pair && >::value, iterator
    > std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert
    (const_iterator __hint, _Pair && __x) [inline]

Inserts a std::pair into the unordered_multimap โ€” and this time you get to pass a __hint const_iterator as a little suggestion of where it might go. That's all the docs say, so that's all we're claiming ๐Ÿ˜Œ

Okay so for this hinted insert that was mid-explanation, the params are:

  • __hint โ€” an iterator that serves as a hint as to where the pair should be inserted.
  • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).

Returns: an iterator that points to the element with key of __x (may or may not be the pair passed in).

Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting.

Insertion requires amortized constant time.


Next up, bestie, it's the hinted const value_type & version:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (const_iterator __hint, const value_type & __x) [inline]

Inserts a std::pair into the unordered_multimap. Obsessed with how direct that is.

  • __hint โ€” an iterator that serves as a hint as to where the pair should be inserted.
  • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).

Returns: an iterator that points to the element with key of __x (may or may not be the pair passed in).

Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting.

Insertion requires amortized constant time. Fr fr, that's the whole vibe.


Then there's the node re-insert with a hint:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (const_iterator __hint, node_type && __nh) [inline]

Re-insert an extracted node. That's it, that's the whole function. It references std::move(). Slay.


And here's the hinted value_type && flavor:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (const_iterator __hint, value_type && __x) [inline]

Inserts a std::pair into the unordered_multimap. Same iconic energy as before:

  • __hint โ€” an iterator that serves as a hint as to where the pair should be inserted.
  • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).

Returns: an iterator that points to the element with key of __x (may or may not be the pair passed in).

Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting.

Insertion requires amortized constant time. Also references std::move(). Periodt.


Next, the initializer-list insert:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (initializer_list< value_type > __l) [inline]

Attempts to insert a list of elements into the unordered_multimap. It's giving "bring the whole group chat."

  • __l โ€” a std::initializer_list<value_type> of elements to be inserted.

Complexity similar to that of the range constructor. Ngl, that's a cute little detail to keep.


Then the non-hinted extracted-node insert:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (node_type && __nh) [inline]

Re-insert an extracted node. It references std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::cend(), and std::move(). Lowkey a whole little crossover episode.


And the non-hinted value_type && insert:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> iterator std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::insert (value_type && __x) [inline]

Inserts a std::pair into the unordered_multimap.

  • __x โ€” pair to be inserted (see std::make_pair for easy creation of pairs).

Returns: an iterator that points to the inserted pair.

Insertion requires amortized constant time. References std::move(). That's the tea. ๐Ÿซถ


Now for the key-comparison check-in:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> key_equal std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::key_eq () const [inline]

Returns the key comparison object with which the unordered_multimap was constructed. Iconic little origin-story moment.


Load factor time:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> float std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::load_factor () const [inline], [noexcept]

Returns the average number of elements per bucket. Math girlie behavior, honestly.


Max bucket count:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> size_type std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::max_bucket_count () const [inline], [noexcept]

Returns the maximum number of buckets of the unordered_multimap. Bucket maximum, no cap. ๐Ÿ’…


Max load factor getter:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> float std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::max_load_factor () const [inline], [noexcept]

Returns a positive number that the unordered_multimap tries to keep the load factor less than or equal to. It's giving "boundaries, bestie."


Max load factor setter:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::max_load_factor (float __z) [inline]

Change the unordered_multimap maximum load factor.

  • __z โ€” the new maximum load factor.

That's the whole adjustment. Very main character of it.


Max size:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> size_type std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::max_size () const [inline], [noexcept]

Returns the maximum size of the unordered_multimap. Maximum capacity, literally.


Copy assignment operator, default behavior and all:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> unordered_multimap & std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::operator= (const unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc > &) [default]

Copy assignment operator. Default. We love a reliable classic. ๐ŸŒธ


Initializer-list assignment:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> unordered_multimap & std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::operator= (initializer_list< value_type > __l) [inline]

Unordered_multimap list assignment operator.

  • __l โ€” an initializer_list.

This function fills an unordered_multimap with copies of the elements in the initializer list __l.

Note that the assignment completely changes the unordered_multimap and that the resulting unordered_multimap's size is the same as the number of elements assigned. Not me warning you that it's a full glow-up, not a little touch-up.

Move assignment operator:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> unordered_multimap & std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::operator= (unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc > &&) [default]

Move assignment operator. Default. Efficient little icon. โœจ


Rehash:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::rehash (size_type __n) [inline]

May rehash the unordered_multimap.

  • __n โ€” the new number of buckets.

Rehash will occur only if the new number of buckets respect the unordered_multimap maximum load factor. So it's a "may," not a "will," bestie. Important.


Reserve:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::reserve (size_type __n) [inline]

Prepare the unordered_multimap for a specified number of elements.

  • __n โ€” number of elements required.

Same as rehash(ceil(n / max_load_factor())). That's not me doing math, that's literally the page. ๐Ÿ’€


Size:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> size_type std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::size () const [inline], [noexcept]

Returns the size of the unordered_multimap. Short king of a description, honestly.


Swap:

template<typename _Key , typename _Tp , typename _Hash  = hash<_Key>, typename _Pred  = equal_to<_Key>, typename _Alloc  = allocator<std::pair<const _Key, _Tp>>> void std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >::swap (unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc > & __x) [inline], [noexcept]

Swaps data with another unordered_multimap.

  • __x โ€” an unordered_multimap of the same element and allocator types.

This exchanges the elements between two unordered_multimap in constant time. Note that the global std::swap() function is specialized such that std::swap(m1,m2) will feed to this function. Cute little handoff, iykyk. ๐Ÿฆ‹


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. No cap, the robots handled the paperwork. ๐Ÿค–๐Ÿ’–


And that's the tea: the footer's source/version and date marker is libststd::unordered_..._Pred, _Alloc >(3cxx) โ€” official stamp, iconic energy, slay your containers bestie. ๐Ÿ’…๐ŸŒˆ

๐Ÿ“ฆ where this page comes from