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 anunordered_multisetfrom a range. defaults are right there, bestie. ๐ซถunordered_multiset (const allocator_type &__a)โ creates anunordered_multisetwith 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 anunordered_multisetfrom aninitializer_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 exactnoexceptexpression. no cap.size_type bucket_count () const noexceptโ returns the number of buckets of theunordered_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 theunordered_multiset.template<typename... _Args> iterator emplace_hint (const_iterator __pos, _Args &&... __args)โ inserts an element into theunordered_multisetwith a hint.bool empty () const noexceptโ returnstrueif theunordered_multisetis 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 anunordered_multiset.allocator_type get_allocator () const noexceptโ returns the allocator object used by theunordered_multiset.hasher hash_function () constโ returns the hash functor object with which theunordered_multisetwas 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 theunordered_multiset.key_equal key_eq () constโ returns the key comparison object with which theunordered_multisetwas 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 theunordered_multiset.float max_load_factor () const noexceptโ returns a positive number that theunordered_multisettries to keep the load factor less than or equal to.void max_load_factor (float __z)โ change theunordered_multisetmaximum load factor.size_type max_size () const noexceptโ returns the maximum size of theunordered_multiset.unordered_multiset & operator= (const unordered_multiset &)=defaultโ copy assignment operator. slay. ๐unordered_multiset & operator= (initializer_list< value_type > __l)โunordered_multisetlist assignment operator.unordered_multiset & operator= (unordered_multiset &&)=defaultโ move assignment operator.void rehash (size_type __n)โ may rehash theunordered_multiset.void reserve (size_type __n)โ prepare theunordered_multisetfor a specified number of elements.size_type size () const noexceptโ returns the size of theunordered_multiset.void swap (unordered_multiset &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))โ swaps data with anotherunordered_multiset, with that exactnoexceptexpression. ๐ฅ
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 theunordered_multiset.iterator insert (value_type &&__x)โ inserts an element into theunordered_multiset.iterator insert (const_iterator __hint, const value_type &__x)โ inserts an element into theunordered_multisetwith a hint.iterator insert (const_iterator __hint, value_type &&__x)โ inserts an element into theunordered_multisetwith a hint.iterator erase (const_iterator __position)โ erases an element from anunordered_multiset.iterator erase (iterator __position)โ erases an element from anunordered_multiset.iterator find (const key_type &__x)โ tries to locate an element in anunordered_multiset.const_iterator find (const key_type &__x) constโ tries to locate an element in anunordered_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 tohash<_Value>._Predโ predicate function object type, defaults toequal_to<_Value>._Allocโ allocator type, defaults toallocator<_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โ astd::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โ aninitializer_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