STD::UNORDERED_MULTISET(3)

โœจ std::unordered_multiset โ€” Library Functions Manual โœจ

okay bestie, welcome to part 1 of the std::unordered_multiset manual ๐Ÿ’… this is the C++ standard container that's giving set energy but it can hold multiple equivalent keys, and the keys are the elements themselves. no cap. let's get into it ๐Ÿฆ‹


๐ŸŒธ NAME ๐ŸŒธ

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc > โ€” a standard container composed of equivalent keys (possibly containing multiple of each key value) in which the elements' keys are the elements themselves. so like, multiset but unordered, and every key is literally the element. iconic. โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <unordered_set>

๐Ÿ’– Public Types ๐Ÿ’–

  • typedef _Hashtable::key_type key_type โ€” public typedef, bestie. ๐Ÿ’–
  • typedef _Hashtable::value_type value_type โ€” public typedef. ๐Ÿ’–
  • typedef _Hashtable::hasher hasher โ€” public typedef. ๐Ÿ’–
  • typedef _Hashtable::key_equal key_equal โ€” public typedef. ๐Ÿ’–
  • typedef _Hashtable::allocator_type allocator_type โ€” public typedef. ๐Ÿ’–

iterator-related typedefs, lowkey essential:

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

โœจ Public Member Functions โœจ

  • unordered_multiset ()=default โ€” default constructor. slay. โœจ
  • template<typename _InputIterator> unordered_multiset (_InputIterator __first, _InputIterator __last, const allocator_type &__a) โ€” constructor from a range plus allocator.
  • template<typename _InputIterator> unordered_multiset (_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type &__a) โ€” constructor from a range, bucket count, and allocator.
  • template<typename _InputIterator> unordered_multiset (_InputIterator __first, _InputIterator __last, size_type __n, const hasher &__hf, const allocator_type &__a) โ€” constructor from a range, bucket count, hasher, and allocator.
  • template<typename _InputIterator> unordered_multiset (_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_multiset from a range. defaults are right there, bestie. ๐Ÿซถ
  • unordered_multiset (const allocator_type &__a) โ€” creates an unordered_multiset with no elements.
  • unordered_multiset (const unordered_multiset &)=default โ€” copy constructor. periodt. ๐Ÿ’…
  • unordered_multiset (const unordered_multiset &__umset, const allocator_type &__a) โ€” copy constructor with allocator.
  • unordered_multiset (initializer_list< value_type > __l, const allocator_type &__a) โ€” constructor from an initializer_list plus allocator.
  • unordered_multiset (initializer_list< value_type > __l, size_type __n, const allocator_type &__a) โ€” constructor from an initializer_list, bucket count, and allocator.
  • unordered_multiset (initializer_list< value_type > __l, size_type __n, const hasher &__hf, const allocator_type &__a) โ€” constructor from an initializer_list, bucket count, hasher, and allocator.
  • unordered_multiset (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_multiset from an initializer_list. yup, defaults included. ๐ŸŒธ
  • unordered_multiset (size_type __n, const allocator_type &__a) โ€” constructor with bucket count and allocator.
  • unordered_multiset (size_type __n, const hasher &__hf, const allocator_type &__a) โ€” constructor with bucket count, hasher, and allocator.
  • unordered_multiset (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_multiset (unordered_multiset &&)=default โ€” move constructor. main character energy. ๐Ÿ‘‘
  • unordered_multiset (unordered_multiset &&__umset, const allocator_type &__a) noexcept(noexcept(_Hashtable(std::move(__umset._M_h), __a))) โ€” move constructor with allocator, with that exact noexcept expression. no cap.
  • size_type bucket_count () const noexcept โ€” returns the number of buckets of the unordered_multiset.
  • size_type bucket_size (size_type __n) const โ€” bucket size, bestie. it's giving bucket behavior.
  • const_iterator cbegin () const noexcept โ€” const beginning iterator.
  • const_iterator cend () const noexcept โ€” const ending iterator.
  • void clear () noexcept โ€” clears it. poof. ๐Ÿ’€
  • template<typename... _Args> iterator emplace (_Args &&... __args) โ€” builds and inserts an element into the unordered_multiset.
  • template<typename... _Args> iterator emplace_hint (const_iterator __pos, _Args &&... __args) โ€” inserts an element into the unordered_multiset with a hint.
  • bool empty () const noexcept โ€” returns true if the unordered_multiset is empty.
  • template<__heterogeneous_hash_key< unordered_multiset > _Kt> size_type erase (_Kt &&__x) โ€” heterogeneous erase by key.
  • 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_multiset.
  • allocator_type get_allocator () const noexcept โ€” returns the allocator object used by the unordered_multiset.
  • hasher hash_function () const โ€” returns the hash functor object with which the unordered_multiset was constructed.
  • template<typename _InputIterator> void insert (_InputIterator __first, _InputIterator __last) โ€” a template function that inserts a range of elements.
  • void insert (initializer_list< value_type > __l) โ€” inserts a list of elements into the unordered_multiset.
  • key_equal key_eq () const โ€” returns the key comparison object with which the unordered_multiset 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_multiset.
  • float max_load_factor () const noexcept โ€” returns a positive number that the unordered_multiset tries to keep the load factor less than or equal to.
  • void max_load_factor (float __z) โ€” change the unordered_multiset maximum load factor.
  • size_type max_size () const noexcept โ€” returns the maximum size of the unordered_multiset.
  • unordered_multiset & operator= (const unordered_multiset &)=default โ€” copy assignment operator. slay. ๐Ÿ’…
  • unordered_multiset & operator= (initializer_list< value_type > __l) โ€” unordered_multiset list assignment operator.
  • unordered_multiset & operator= (unordered_multiset &&)=default โ€” move assignment operator.
  • void rehash (size_type __n) โ€” may rehash the unordered_multiset.
  • void reserve (size_type __n) โ€” prepare the unordered_multiset for a specified number of elements.
  • size_type size () const noexcept โ€” returns the size of the unordered_multiset.
  • void swap (unordered_multiset &__x) noexcept(noexcept(_M_h.swap(__x._M_h))) โ€” swaps data with another unordered_multiset, with that exact noexcept expression. ๐Ÿ”ฅ

more member functions, because she contains multitudes:

  • iterator begin () noexcept โ€” beginning iterator.
  • const_iterator begin () const noexcept โ€” const beginning iterator.
  • iterator end () noexcept โ€” ending iterator.
  • const_iterator end () const noexcept โ€” const ending iterator.
  • iterator insert (const value_type &__x) โ€” inserts an element into the unordered_multiset.
  • iterator insert (value_type &&__x) โ€” inserts an element into the unordered_multiset.
  • iterator insert (const_iterator __hint, const value_type &__x) โ€” inserts an element into the unordered_multiset with a hint.
  • iterator insert (const_iterator __hint, value_type &&__x) โ€” inserts an element into the unordered_multiset with a hint.
  • iterator erase (const_iterator __position) โ€” erases an element from an unordered_multiset.
  • iterator erase (iterator __position) โ€” erases an element from an unordered_multiset.
  • iterator find (const key_type &__x) โ€” tries to locate an element in an unordered_multiset.
  • const_iterator find (const key_type &__x) const โ€” tries to locate an element in an unordered_multiset.
  • size_type count (const key_type &__x) const โ€” 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. yes, that exact trailing return type. ๐Ÿซถ
  • std::pair< iterator, iterator > equal_range (const key_type &__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.
  • size_type bucket (const key_type &__key) const โ€” bucket lookup by key.
  • template<__heterogeneous_hash_key< unordered_multiset > _Kt> size_type bucket (const _Kt &__key) const โ€” heterogeneous bucket lookup by key.
  • local_iterator begin (size_type __n) โ€” returns a read-only (constant) iterator pointing to the first bucket element.
  • const_local_iterator begin (size_type __n) const โ€” returns a read-only (constant) iterator pointing to the first bucket element.
  • const_local_iterator cbegin (size_type __n) const โ€” returns a read-only (constant) iterator pointing to the first bucket element.
  • local_iterator end (size_type __n) โ€” returns a read-only (constant) iterator pointing to one past the last bucket elements.
  • const_local_iterator end (size_type __n) const โ€” returns a read-only (constant) iterator pointing to one past the last bucket elements.
  • const_local_iterator cend (size_type __n) const โ€” returns a read-only (constant) iterator pointing to one past the last bucket elements.

๐Ÿซถ Friends ๐Ÿซถ

  • template<typename _Value1, typename _Hash1, typename _Pred1, typename _Alloc1> bool operator== (const unordered_multiset< _Value1, _Hash1, _Pred1, _Alloc1 > &, const unordered_multiset< _Value1, _Hash1, _Pred1, _Alloc1 > &) โ€” friendship equality operator. bestie behavior. ๐Ÿซถ

๐Ÿ‘‘ Detailed Description ๐Ÿ‘‘

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>>
    class std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >

"A standard container composed of equivalent keys (possibly containing multiple of each key value) in which the elements' keys are the elements themselves." okay so that's the whole vibe. โœจ

Since: C++11

๐Ÿ’œ Template Parameters ๐Ÿ’œ

  • _Value โ€” type of key 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 allocator<_Key>.

Meets the requirements of a container, and unordered associative container. periodt. ๐Ÿ’…

Base is _Hashtable, dispatched at compile time via template alias __umset_hashtable.

๐ŸŒธ Member Typedef Documentation ๐ŸŒธ

ok so before we even get to the โœจactionsโœจ, here's the whole cast of characters. Every single one of these is a typedef, and they all hide behind the exact same template fit, so learn this one signature and you've learned them all:

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred = equal_to<_Value>, typename _Alloc = allocator<_Value>>

periodt. now let's meet the girlies ๐Ÿ’–


๐ŸŽ€ allocator_type

typedef _Hashtable::allocator_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::allocator_type

She's filed under Public typedefs. that's the allocator, bestie.

๐Ÿฆ‹ const_iterator

typedef _Hashtable::const_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::const_iterator

Iterator-related typedefs โ€” she's read-only and she knows it ๐Ÿ‘‘

๐Ÿฆ‹ const_local_iterator

typedef _Hashtable::const_local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::const_local_iterator

Iterator-related typedefs. the read-only, bucket-scoped cousin. she stays in her lane (literally, one bucket) ๐Ÿ’…

๐Ÿฆ‹ const_pointer

typedef _Hashtable::const_pointer std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::const_pointer

Iterator-related typedefs โ€” pointer but make it const ๐Ÿ”’

๐Ÿฆ‹ const_reference

typedef _Hashtable::const_reference std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::const_reference

Iterator-related typedefs โ€” reference but make it const ๐Ÿ”’

๐Ÿฆ‹ difference_type

typedef _Hashtable::difference_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::difference_type

Iterator-related typedefs โ€” for when you need to subtract two iterators and find out how far apart they are ๐Ÿ˜ญ

๐Ÿฆ‹ hasher

typedef _Hashtable::hasher std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::hasher

Public typedefs. the hash functor, the one doing the actual math ๐Ÿงฎโœจ

๐Ÿฆ‹ iterator

typedef _Hashtable::iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::iterator

Iterator-related typedefs โ€” the main character iterator ๐Ÿซถ

๐Ÿฆ‹ key_equal

typedef _Hashtable::key_equal std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::key_equal

Public typedefs. the key equality functor, deciding if two things are "the same" ๐Ÿ’…

๐Ÿฆ‹ key_type

typedef _Hashtable::key_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::key_type

Public typedefs โ€” the key, obviously ๐ŸŽ€

๐Ÿฆ‹ local_iterator

typedef _Hashtable::local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::local_iterator

Iterator-related typedefs โ€” the bucket-scoped iterator, non-const edition ๐ŸŒˆ

๐Ÿฆ‹ pointer

typedef _Hashtable::pointer std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::pointer

Iterator-related typedefs โ€” pointer, regular flavour ๐Ÿ’–

๐Ÿฆ‹ reference

typedef _Hashtable::reference std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::reference

Iterator-related typedefs โ€” reference, regular flavour ๐Ÿ’–

๐Ÿฆ‹ size_type

typedef _Hashtable::size_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::size_type

Iterator-related typedefs โ€” for counting and indexing, she's your girl ๐Ÿ”ข

๐Ÿฆ‹ value_type

typedef _Hashtable::value_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::value_type

Public typedefs โ€” the actual thing being stored. the moment. the icon โญ


๐Ÿงš Constructor & Destructor Documentation ๐Ÿงš

now the part where the object is born ๐ŸŽ€ (and moved, and copied, and built from ranges, because she contains multitudes). every single one of these wears the same template crown:

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred = equal_to<_Value>, typename _Alloc = allocator<_Value>>

๐Ÿ’œ unordered_multiset () [default]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset () [default]

Default constructor. no cap, that's the whole description. she's here, she's empty, she's serving ๐ŸŒธ

๐Ÿ’œ unordered_multiset (size_type __n, const hasher & __hf = hasher(), const key_equal & __eql = key_equal(), const allocator_type & __a = allocator_type()) [inline], [explicit]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (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 bestie, the description says "default constructor" even though she takes args โ€” that's just how the page is written, I don't make the rules ๐Ÿ˜ญ

Parameters

  • __n โ€” Minimal initial number of buckets.
  • __hf โ€” A hash functor.
  • __eql โ€” A key equality functor.
  • __a โ€” An allocator object.

๐Ÿ’œ unordered_multiset (_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]

template<typename _InputIterator>
std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (_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_multiset 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_multiset consisting of copies of the elements from [__first,__last). This is linear in N (where N is distance(__first,__last)).

๐Ÿ’œ unordered_multiset (const unordered_multiset< _Value, _Hash, _Pred, _Alloc > & ) [default]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (const unordered_multiset< _Value, _Hash, _Pred, _Alloc > & ) [default]

Copy constructor. she's a twin, not the same person ๐Ÿ’…

๐Ÿ’œ unordered_multiset (unordered_multiset< _Value, _Hash, _Pred, _Alloc > && ) [default]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (unordered_multiset< _Value, _Hash, _Pred, _Alloc > && ) [default]

Move constructor. the other one's stuff is hers now, no take-backsies ๐Ÿฆ‹

๐Ÿ’œ unordered_multiset (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]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (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_multiset from an initializer_list. the curly-brace girlies ate ๐Ÿ”ฅ

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_multiset consisting of copies of the elements in the list. This is linear in N (where N is __l.size()).

๐Ÿ’œ unordered_multiset (const allocator_type & __a) [inline], [explicit]

std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::unordered_multiset (const allocator_type & __a) [inline], [explicit]

Creates an unordered_multiset with no elements. empty queen ๐Ÿ‘‘

Parameters

  • __a โ€” An allocator object.

๐Ÿ’– Member Function Documentation ๐Ÿ’–

the main event. all of these wear the same template fit too:

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred = equal_to<_Value>, typename _Alloc = allocator<_Value>>

๐Ÿ“ const_iterator begin () const [inline], [noexcept]

const_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::begin () const [inline], [noexcept]

Returns a read-only (constant) iterator that points to the first element in the unordered_multiset.

๐Ÿ“ iterator begin () [inline], [noexcept]

iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::begin () [inline], [noexcept]

Returns a read-only (constant) iterator that points to the first element in the unordered_multiset.

yeah bestie, the non-const overload says "read-only (constant)" too โ€” that's literally what the page says, I'm just the messenger ๐Ÿ™ˆ

๐Ÿ“ local_iterator begin (size_type __n) [inline]

local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::begin (size_type __n) [inline]

Returns a read-only (constant) iterator pointing to the first bucket element.

Parameters

  • __n โ€” The bucket index.

Returns

A read-only local iterator.

๐Ÿ“ const_local_iterator begin (size_type __n) const [inline]

const_local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::begin (size_type __n) const [inline]

Returns a read-only (constant) iterator pointing to the first bucket element.

Parameters

  • __n โ€” The bucket index.

Returns

A read-only local iterator.

๐Ÿ“ size_type bucket_count () const [inline], [noexcept]

size_type std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::bucket_count () const [inline], [noexcept]

Returns the number of buckets of the unordered_multiset. that's how many lil homes the elements are sorted into ๐Ÿชฃโœจ

๐Ÿ“ const_iterator cbegin () const [inline], [noexcept]

const_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::cbegin () const [inline], [noexcept]

Returns a read-only (constant) iterator that points to the first element in the unordered_multiset. the c is for const, the c is for certified ๐ŸŽ€

๐Ÿ“ const_local_iterator cbegin (size_type __n) const [inline]

const_local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::cbegin (size_type __n) const [inline]

Returns a read-only (constant) iterator pointing to the first bucket element.

Parameters

  • __n โ€” The bucket index.

Returns

A read-only local iterator.

๐Ÿ“ const_iterator cend () const [inline], [noexcept]

const_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::cend () const [inline], [noexcept]

Returns a read-only (constant) iterator that points one past the last element in the unordered_multiset. she's past the finish line, she's not in the container, she's just vibing at the edge ๐ŸŒˆ

๐Ÿ“ const_local_iterator cend (size_type __n) const [inline]

const_local_iterator std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::cend (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 local iterator.

clear โ€” the ultimate "we're starting over" moment ๐Ÿงนโœจ

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> void
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::clear ()
    [inline],  [noexcept]

Erases all the elements in an unordered_multiset. Every single one. Gone. Not a single survivor, bestie ๐Ÿ’€

Okay but listen โ€” this only erases the elements themselves. If those elements are pointers, the memory they point at is not touched in any way. Like, the box is yeeted but the thing inside the box is still sitting there. Managing the pointer is your responsibility. No cap. ๐Ÿ™ˆ

contains โ€” the "do you have this?? ๐Ÿ‘€" check

Two whole overloads, both iconic:

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> template<typename
    _Kt> auto std::unordered_multiset< _Value, _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. It's giving vibe check but for keys โœจ

Parameters

  • __x โ€” the key of the elements to be located.

Returns

True if there is any element with the specified key.

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

Same energy, same job: finds whether an element with the given key exists. ๐Ÿซถ

Parameters

  • __x โ€” the key of the elements to be located.

Returns

True if there is any element with the specified key.


count โ€” how many of these do we have?? ๐Ÿ”ข

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

Finds the number of elements. (Yes, it's a *multi*set, so this can absolutely be more than one. That's the whole point of her ๐ŸŒธ)

Parameters

  • __x โ€” the element to located. (Their grammar, not mine, bestie โ€” I'm just the messenger ๐Ÿ’…)

Returns

The number of elements with the specified key.


emplace โ€” build it and yeet it in ๐Ÿ› ๏ธ

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>>
    template<typename... _Args> iterator std::unordered_multiset< _Value,
    _Hash, _Pred, _Alloc >::emplace (_Args &&... __args) [inline]

Builds and insert an element into the unordered_multiset. Constructs it right there in place, no extra copies, no drama. Main character energy fr fr ๐Ÿ‘‘

Parameters

  • __args โ€” arguments used to generate an element.

Returns

An iterator that points to the inserted element.

Insertion requires amortized constant time. Slay.


emplace_hint โ€” same but with a lil suggestion ๐ŸŽ€

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>>
    template<typename... _Args> iterator std::unordered_multiset< _Value,
    _Hash, _Pred, _Alloc >::emplace_hint (const_iterator __pos, _Args &&...
    __args) [inline]

Inserts an element into the unordered_multiset. Basically emplace but you get to whisper a hint about where it should go ๐Ÿคซ

Parameters

  • __pos โ€” an iterator that serves as a hint as to where the element should be inserted.
  • __args โ€” arguments used to generate the element to be inserted.

Returns

An iterator that points to the inserted element.

Heads up bestie: that first parameter is only a hint and it can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency. So don't stress about getting it perfect โ€” it's a suggestion, not a binding contract ๐Ÿ’…

For more on hinting, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints

Insertion requires amortized constant time. Periodt.


empty โ€” are you running on fumes or not ๐Ÿซ™

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> bool
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::empty () const
    [inline],  [nodiscard],  [noexcept]

Returns true if the unordered_multiset is empty. That's it, that's the tweet. And yes it's [nodiscard], so don't be ignoring that return value, it literally called you out ๐Ÿ“ข


end โ€” the past-the-end bestie ๐Ÿ

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::end () const
    [inline],  [noexcept]

Returns a read-only (constant) iterator that points one past the last element in the unordered_multiset.

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::end ()
    [inline],  [noexcept]

Returns a read-only (constant) iterator that points one past the last element in the unordered_multiset. (Yes, the non-const one says "read-only (constant)" too โ€” I don't make the rules, I just relay them faithfully ๐Ÿ™ˆ)


end โ€” but make it bucket ๐Ÿชฃ

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> local_iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::end (size_type
    __n) [inline]

Returns a read-only (constant) iterator pointing to one past the last bucket elements.

Parameters

  • __n โ€” the bucket index.

Returns

A read-only local iterator.

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>>
    const_local_iterator std::unordered_multiset< _Value, _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 local iterator.


equal_range โ€” gimme the whole lil squad ๐Ÿ‘ฏ

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

Finds a subsequence matching the given key. Like, all of them. Every matching element, handed to you as a range ๐Ÿซถ

Parameters

  • __x โ€” key to be located.

Returns

Pair of iterators that possibly points to the subsequence matching given key.

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

Finds a subsequence matching the given key. Same deal, just const โœจ

Parameters

  • __x โ€” key to be located.

Returns

Pair of iterators that possibly points to the subsequence matching given key.


erase โ€” the deleting era ๐Ÿ’€

Four overloads. Four. She's thorough.

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

Erases elements according to the provided key.

Parameters

  • __x โ€” key of the element to be erased.

Returns

The number of elements erased.

This function erases all the elements located by the given key from an unordered_multiset.

And again, bestie, listen carefully: this only erases the element. 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. ๐Ÿ”ฅ
template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::erase
    (const_iterator __first, const_iterator __last) [inline]

Erases a [__first,__last) range of elements from an unordered_multiset.

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_multiset.

Same warning, same energy: it 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. ๐Ÿ™ˆ
template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::erase
    (const_iterator __position) [inline]

Erases an element from an unordered_multiset.

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_multiset.

You already know the drill: only the element goes, pointers' pointed-to memory is not touched in any way, managing the pointer is the user's responsibility. ๐Ÿ’…
template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::erase (iterator
    __position) [inline]

Erases an element from an unordered_multiset.

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_multiset.

Final reminder, and I mean it: only the element gets erased. 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. ๐ŸŽ€

find โ€” where u at ๐Ÿ”

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

Tries to locate an element in an unordered_multiset.

Parameters

  • __x โ€” element to be located.

Returns

Iterator pointing to 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. We've all been there ๐Ÿ˜ญ

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

Tries to locate an element in an unordered_multiset.

Parameters

  • __x โ€” element to be located.

Returns

Iterator pointing to 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. Same story, const flavoured ๐Ÿฆ‹


get_allocator โ€” who's paying for all this ๐Ÿช™

template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
    equal_to<_Value>, typename _Alloc = allocator<_Value>> allocator_type
    std::unordered_multiset< _Value, _Hash, _Pred, _Alloc >::get_allocator
    () const [inline],  [noexcept]

Returns the allocator object used by the unordered_multiset. That's the little guy handling all the memory logistics behind the scenes. Respect ๐Ÿ‘‘

okay bestie, deep breath, part 4, we're in the home stretch ๐Ÿ’– every single function in this chunk lives under the exact same template header, so I'm putting it here once and you can mentally glue it to the front of everything below, fr fr:

template<typename _Value, typename _Hash = hash<_Value>,
         typename _Pred = equal_to<_Value>,
         typename _Alloc = allocator<_Value>>

hash_function ๐Ÿ’ซ

hasher std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::hash_function() const [inline]

Hands you back the hash functor object that this unordered_multiset was constructed with. That's the whole vibe. no cap. ๐Ÿซถ


insert โ€” the range one ๐ŸŒˆ

template<typename _InputIterator>
void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) [inline]

A template function that inserts a range of elements. She's a template, she's a girl's girl, she takes iterators and she slays โœจ

Parameters

  • __first โ€” iterator pointing to the start of the range to be inserted.
  • __last โ€” iterator pointing to the end of the range.
Complexity is similar to that of the range constructor. iykyk ๐Ÿ’…

insert โ€” single element, lvalue edition ๐ŸŽ€

iterator std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(const value_type & __x) [inline]

Inserts one element into the unordered_multiset. Very demure, very mindful.

Parameters

  • __x โ€” element to be inserted.

Returns

  • An iterator that points to the inserted element.
Insertion requires amortized constant time. fast girly behavior ๐Ÿ’€

insert โ€” with a hint, lvalue flavor ๐ŸŒธ

iterator std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(const_iterator __hint, const value_type & __x) [inline]

Inserts an element, but you get to whisper a suggestion about where it should go. Cute, right?

Parameters

  • __hint โ€” an iterator that serves as a hint as to where the element should be inserted.
  • __x โ€” element to be inserted.

Returns

  • An iterator that points to the inserted element.

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. So like, don't just pass your ex's iterator and expect magic ๐Ÿ™ˆ

For more on hinting, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints

Insertion requires amortized constant.

insert โ€” with a hint, rvalue flavor ๐Ÿฆ‹

iterator std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(const_iterator __hint, value_type && __x) [inline]

Same energy as above but __x gets moved instead of copied. Move semantics ate, honestly ๐Ÿ‘‘

Parameters

  • __hint โ€” an iterator that serves as a hint as to where the element should be inserted.
  • __x โ€” element to be inserted.

Returns

  • An iterator that points to the inserted element.

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.

For more on hinting, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints

Insertion requires amortized constant.

insert โ€” the initializer_list one ๐Ÿ“

void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(initializer_list< value_type > __l) [inline]

Inserts a whole list of elements in one go. Curly braces girlies, this one's for you โœจ

Parameters

  • __l โ€” a std::initializer_list<value_type> of elements to be inserted.
Complexity is similar to that of the range constructor.

insert โ€” single element, rvalue edition ๐Ÿ”ฅ

iterator std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(value_type && __x) [inline]

Inserts one element that's getting moved in. Same deal, just faster and with more attitude.

Parameters

  • __x โ€” element to be inserted.

Returns

  • An iterator that points to the inserted element.
Insertion requires amortized constant time.

key_eq ๐ŸŒŸ

key_equal std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::key_eq() const [inline]

Returns the key comparison object that this unordered_multiset was constructed with. It's the thing that decides if two keys are "the same key." main character energy, honestly.


load_factor โญ

float std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::load_factor() const [inline], [noexcept]

Returns the average number of elements per bucket. It's giving "how packed is this party rn" ๐Ÿ“Š

Note the [noexcept] โ€” she promises not to throw. reliable queen ๐Ÿ’…


max_bucket_count ๐Ÿ‘‘

size_type std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::max_bucket_count() const [inline], [noexcept]

Returns the maximum number of buckets</bad> of the unordered_multiset. The theoretical ceiling. The sky. The limit. periodt.


max_load_factor โ€” the getter ๐ŸŒˆ

float std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::max_load_factor() const [inline], [noexcept]

Returns a positive number that the unordered_multiset tries to keep the load factor less than or equal to. It's the rule she sets for herself and honestly, boundaries are healthy bestie ๐Ÿซถ


max_load_factor โ€” the setter โœจ

void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::max_load_factor(float __z) [inline]

Changes the unordered_multiset's maximum load factor. Glow-up time.

Parameters

  • __z โ€” the new maximum load factor.

max_size ๐ŸŽ€

size_type std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::max_size() const [inline], [noexcept]

Returns the maximum size of the unordered_multiset. Bigger than you'll ever need, but she said dream big ๐Ÿ’–


operator= โ€” copy assignment ๐ŸŒธ

unordered_multiset & std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc> &) [default]

The copy assignment operator. It's [default], meaning the compiler wrote it for us and honestly she ate ๐Ÿ’…


operator= โ€” the initializer_list one ๐Ÿฆ‹

unordered_multiset & std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list< value_type > __l) [inline]

The unordered_multiset list assignment operator. Curly braces to the rescue.

Parameters

  • __l โ€” an initializer_list.

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

โš ๏ธ Note that the assignment completely changes the unordered_multiset and that the resulting unordered_multiset's size is the same as the number of elements assigned. So it's not an append, bestie. It's a full rewrite. the way that it just replaces everything ๐Ÿ˜ญ

operator= โ€” move assignment ๐Ÿงš

unordered_multiset & std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_multiset<_Value, _Hash, _Pred, _Alloc> &&) [default]

The move assignment operator. Also [default]. Also iconic. Also faster than the copy one. we love efficiency ๐Ÿ”ฅ


rehash ๐ŸŒŸ

void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::rehash(size_type __n) [inline]

May rehash the unordered_multiset. Notice the "may" โ€” she's not making promises she can't keep ๐Ÿ™ˆ

Parameters

  • __n โ€” the new number of buckets.
Rehash will occur only if the new number of buckets respects the unordered_multiset maximum load factor.

reserve ๐Ÿ’ซ

void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::reserve(size_type __n) [inline]

Prepares the unordered_multiset for a specified number of elements. Like pre-gaming but for buckets โœจ

Parameters

  • __n โ€” number of elements required.

Same as rehash(ceil(n / max_load_factor())).


size ๐Ÿ“

size_type std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size() const [inline], [noexcept]

Returns the size of the unordered_multiset. How many elements she's holding. her little headcount ๐Ÿ’–


swap ๐Ÿ‘‘

void std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc> & __x) [inline], [noexcept]

Swaps data with another unordered_multiset. Trading places, but make it O(1).

Parameters

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

This exchanges the elements between two sets in constant time. Note that the global std::swap() function is specialized such that std::swap(s1,s2) will feed to this function. So you can just call the global one and she'll route you here, no extra work, we love a shortcut ๐Ÿซถ


โœจ Author โœจ

Generated automatically by Doxygen for libstdc++ from the source code. she didn't write herself, bestie, she was born ๐Ÿ’…


and that's a wrap on the whole page, you made it to the end ๐ŸŽ€ this one came from libstdc++, it's the std::unord...d, _Alloc >(3) manual page, and the date stamp is whatever your local build was feeling that day ๐ŸŒˆ go forth and bucket responsibly, bestie ๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 ยท GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 ยท GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms