STD::UNORDERED_SET(3cxx)
๐ std::unordered_set< _Value, _Hash, _Pred, _Alloc > ๐
okay bestie, welcome to the group chat ๐
this is the manual page for std::unordered_set< _Value, _Hash, _Pred, _Alloc >, straight out of the C++ section (3cxx) of the manual. no cap, it's kind of a big deal.
โจ NAME โจ
std::unordered_set< _Value, _Hash, _Pred, _Alloc > โ it's a standard container made up of unique keys, and the vibe is that it holds at most one of each key value ๐
like, every element in there is its own key โ the key is the element, the element is the key, they're the same thing, it's giving main character energy ๐ the way that this container literally cannot have duplicates is so iconic of it fr fr.
so yeah โ unique keys only, one copy max per key value, and each element's key is just itself. periodt ๐ โจ
โจ SYNOPSIS โจ
#include <unordered_set>
okay bestie, this is the whole vibe of the class laid out โ types, constructors, and literally every member function. buckle up ๐ซถ
๐ธ Public Types ๐ธ
using insert_return_type = typename _Hashtable::insert_return_type
using node_type = typename _Hashtable::node_type
Those two are the node-handle glow-ups โจ โ node_type is what you get when you yank a node out, and insert_return_type is what comes back when you try to shove it back in.
Now the classic typedef wall ๐ โ first the Public typedefs squad:
typedef _Hashtable::key_type key_typeโ Public typedefs.typedef _Hashtable::value_type value_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.
and then the Iterator-related typedefs crew, no cap:
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 ๐
๐ the constructors (there are... so many) ๐
unordered_set ()=defaultโ Default constructor. the humble beginning โจtemplate<typename _InputIterator > unordered_set (_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type &__a)โ range constructor, allocator-only flavor.template<typename _InputIterator > unordered_set (_InputIterator __first, _InputIterator __last, size_type __n, const hasher &__hf, const allocator_type &__a)โ range constructor with a hasher and an allocator, but no key_equal.template<typename _InputIterator > unordered_set (_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_set from a range. the full-glow-up version, everything defaulted ๐ฆunordered_set (const allocator_type &__a)โ Creates an unordered_set with no elements. empty but make it allocator-custom ๐unordered_set (const unordered_set &)=defaultโ Copy constructor.unordered_set (const unordered_set &__uset, const allocator_type &__a)โ copy, but you're picking the allocator yourself.unordered_set (initializer_list< value_type > __l, size_type __n, const allocator_type &__a)โ braced-init-list + bucket count + allocator.unordered_set (initializer_list< value_type > __l, size_type __n, const hasher &__hf, const allocator_type &__a)โ braced-init-list + bucket count + hasher + allocator.unordered_set (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_set from an initializer_list. the{1, 2, 3}era, iconic ๐unordered_set (size_type __n, const allocator_type &__a)โ bucket count + allocator.unordered_set (size_type __n, const hasher &__hf, const allocator_type &__a)โ bucket count + hasher + allocator.unordered_set (size_type __n, const hasher &__hf=hasher(), const key_equal &__eql=key_equal(), const allocator_type &__a=allocator_type())โ Default constructor creates no elements. (yes the docs call it that, we don't ask questions ๐ญ)unordered_set (unordered_set &&)=defaultโ Move constructor. zoom zoom ๐ฅunordered_set (unordered_set &&__uset, const allocator_type &__a) noexcept(noexcept(_Hashtable(std::move(__uset._M_h), __a)))โ move + allocator, with that spicynoexceptspec attached โจ
๐ฆ the rest of the member functions ๐ฆ
size_type bucket (const key_type &__key) constโ which bucket a key lands in. no blurb in the source, but there she is.size_type bucket_count () const noexceptโ Returns the number of buckets of the unordered_set.size_type bucket_size (size_type __n) constโ how many elements are chillin' in bucket__n.const_iterator cbegin () const noexceptโ const iterator to the front. ๐const_iterator cend () const noexceptโ const iterator to the end.void clear () noexceptโ yeets every element. bye ๐template<typename... _Args> std::pair< iterator, bool > emplace (_Args &&... __args)โ Attempts to build and insert an element into the unordered_set. constructs it in place, main character energy ๐template<typename... _Args> iterator emplace_hint (const_iterator __pos, _Args &&... __args)โ Attempts to insert an element into the unordered_set. (hint's there, whether anyone listens is another story ๐)bool empty () const noexceptโ Returns true if the unordered_set is empty.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_set.node_type extract (const key_type &__key)โ Extract a node. pluck it right out ๐node_type extract (const_iterator __pos)โ Extract a node. same thing, position edition.allocator_type get_allocator () const noexceptโ Returns the allocator object used by the unordered_set.hasher hash_function () constโ Returns the hash functor object with which the unordered_set 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, node_type &&__nh)โ Re-insert an extracted node. (yep, the hint param has no name, we're not gonna pretend otherwise)void insert (initializer_list< value_type > __l)โ Attempts to insert a list of elements into the unordered_set.insert_return_type insert (node_type &&__nh)โ Re-insert an extracted node. this one tells you how it went ๐key_equal key_eq () constโ Returns the key comparison object with which the unordered_set 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_set.float max_load_factor () const noexceptโ Returns a positive number that the unordered_set tries to keep the load factor less than or equal to.void max_load_factor (float __z)โ Change the unordered_set maximum load factor.size_type max_size () const noexceptโ Returns the maximum size of the unordered_set.template<typename _H2 , typename _P2 > void merge (unordered_multiset< _Value, _H2, _P2, _Alloc > &&__source)โ merge from anunordered_multisetrvalue.template<typename _H2 , typename _P2 > void merge (unordered_multiset< _Value, _H2, _P2, _Alloc > &__source)โ merge from anunordered_multisetlvalue.template<typename _H2 , typename _P2 > void merge (unordered_set< _Value, _H2, _P2, _Alloc > &&__source)โ merge from anunordered_setrvalue.template<typename _H2 , typename _P2 > void merge (unordered_set< _Value, _H2, _P2, _Alloc > &__source)โ merge from anunordered_setlvalue.unordered_set & operator= (const unordered_set &)=defaultโ Copy assignment operator.unordered_set & operator= (initializer_list< value_type > __l)โ Unordered_set list assignment operator.unordered_set & operator= (unordered_set &&)=defaultโ Move assignment operator.void rehash (size_type __n)โ May rehash the unordered_set.void reserve (size_type __n)โ Prepare the unordered_set for a specified number of elements.size_type size () const noexceptโ Returns the size of the unordered_set.void swap (unordered_set &__x) noexcept(noexcept(_M_h.swap(__x._M_h)))โ Swaps data with another unordered_set.
๐ง the next batch (indented in the source, we see you) ๐ง
iterator begin () noexceptโ iterator to the front. โญconst_iterator begin () const noexceptโ const iterator to the front.iterator end () noexceptโ iterator to the end. ๐const_iterator end () const noexceptโ const iterator to the end.std::pair< iterator, bool > insert (const value_type &__x)โ Attempts to insert an element into the unordered_set. (copy flavor)std::pair< iterator, bool > insert (value_type &&__x)โ Attempts to insert an element into the unordered_set. (move flavor)iterator insert (const_iterator __hint, const value_type &__x)โ Attempts to insert an element into the unordered_set. hint + copy.iterator insert (const_iterator __hint, value_type &&__x)โ Attempts to insert an element into the unordered_set. hint + move.iterator erase (const_iterator __position)โ Erases an element from an unordered_set.iterator erase (iterator __position)โ Erases an element from an unordered_set.iterator find (const key_type &__x)โ Tries to locate an element in an unordered_set. ๐template<typename _Kt > auto find (const _Kt &__k) -> decltype(_M_h._M_find_tr(__k))โ Tries to locate an element in an unordered_set. (transparent-lookup edition โจ)const_iterator find (const key_type &__x) constโ Tries to locate an element in an unordered_set. const vibes.template<typename _Kt > auto find (const _Kt &__k) const -> decltype(_M_h._M_find_tr(__k))โ Tries to locate an element in an unordered_set. const + transparent.size_type count (const key_type &__x) constโ Finds the number of elements.template<typename _Kt > auto count (const _Kt &__k) const -> decltype(_M_h._M_count_tr(__k))โ Finds the number of elements. transparent flavor.bool contains (const key_type &__x) constโ Finds whether an element with the given key exists.template<typename _Kt > auto contains (const _Kt &__k) const -> decltype(_M_h._M_find_tr(__k), void(), true)โ Finds whether an element with the given key exists. that comma-operatorvoid()moment, lowkey iconic ๐std::pair< iterator, iterator > equal_range (const key_type &__x)โ Finds a subsequence matching given key.template<typename _Kt > auto equal_range (const _Kt &__k) -> decltype(_M_h._M_equal_range_tr(__k))โ Finds a subsequence matching given key. transparent.std::pair< const_iterator, const_iterator > equal_range (const key_type &__x) constโ Finds a subsequence matching given key. const.template<typename _Kt > auto equal_range (const _Kt &__k) const -> decltype(_M_h._M_equal_range_tr(__k))โ Finds a subsequence matching given key. const + transparent.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_set< _Value1, _Hash1, _Pred1, _Alloc1 > &, const unordered_set< _Value1, _Hash1, _Pred1, _Alloc1 > &)โ the equality bestie ๐ซถtemplate<typename , typename , typename > class std::_Hash_merge_helperโ the merge machinery's little helper friend. no names given, mysterious, we respect it ๐
โจ Detailed Description โจ
okay so bestie, gather round, because this is the class ๐ Here's the actual declaration, and yes it's a chonky one, but we don't gatekeep:
template<typename _Value, typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
class std::unordered_set< _Value, _Hash, _Pred, _Alloc >
"A standard container composed of unique keys (containing at most one of each key value) in which the elements' keys are the elements themselves." ๐ฆ
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>.
ngl the_Allocline really does sayallocator<_Key>in the source, we're not fixing it, we're just reporting it ๐
Meets the requirements of a container, and unordered associative container. fr fr it's certified ๐ซถ
Base is _Hashtable, dispatched at compile time via template alias __uset_hashtable. so it's giving "same brain, different outfit" energy ๐
๐ Member Typedef Documentation ๐
Every single one of these is public-facing, bestie, so let's meet the whole cast ๐ญ The template preamble is the same for all of them, but here's each one in full because we don't do "etc." in this house ๐
allocator_typeโ a Public typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::allocator_type std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::allocator_type
const_iteratorโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::const_iterator std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::const_iterator
const_local_iteratorโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::const_local_iterator std::unordered_set< _Value, _Hash,
_Pred, _Alloc >::const_local_iterator
const_pointerโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::const_pointer std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::const_pointer
const_referenceโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::const_reference std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::const_reference
difference_typeโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::difference_type std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::difference_type
hasherโ a Public typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::hasher std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::hasher
iteratorโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::iterator std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::iterator
key_equalโ a Public typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::key_equal std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::key_equal
key_typeโ a Public typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::key_type std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::key_type
local_iteratorโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::local_iterator std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::local_iterator
pointerโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::pointer std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::pointer
referenceโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::reference std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::reference
size_typeโ an Iterator-related typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::size_type std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::size_type
value_typeโ a Public typedef.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> typedef
_Hashtable::value_type std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::value_type
that's all fifteen, we ate and left no crumbs ๐
๐ Constructor & Destructor Documentation ๐
This is the "how do I even make one of these" section, and there are seven ways to summon an unordered_set ๐
unordered_set ()[default]โ Default constructor. that's it, that's the whole thing โจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set ()
[default]
unordered_set (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.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set
(size_type __n, const hasher & __hf = hasher(), const key_equal & __eql
= key_equal(), const allocator_type & __a = allocator_type()) [inline],
[explicit]
Parameters
__nโ Minimal initial number of buckets.__hfโ A hash functor.__eqlโ A key equality functor.__aโ An allocator object.
template<typename _InputIterator > unordered_set (_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_set from a range. ๐ฆ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _InputIterator > std::unordered_set< _Value, _Hash,
_Pred, _Alloc >::unordered_set (_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]
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_set consisting of copies of the elements from [__first,__last). This is linear in N (where N is distance(__first,__last)). ๐ so yeah, it scales with how much you feed it
unordered_set (const unordered_set< _Value, _Hash, _Pred, _Alloc > &)[default]โ Copy constructor. twin energy ๐ซถ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set (const
unordered_set< _Value, _Hash, _Pred, _Alloc > &) [default]
unordered_set (unordered_set< _Value, _Hash, _Pred, _Alloc > &&)[default]โ Move constructor. it just takes the whole vibe and dips ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set
(unordered_set< _Value, _Hash, _Pred, _Alloc > &&) [default]
unordered_set (const allocator_type & __a)[inline],[explicit]โ Creates an unordered_set with no elements. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set (const
allocator_type & __a) [inline], [explicit]
Parameters
__aโ An allocator object.
unordered_set (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_set from an initializer_list. the curly-braces glow-up ๐ญโจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::unordered_set
(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]
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_set consisting of copies of the elements in the list. This is linear in N (where N is __l.size()). ๐
๐ Member Function Documentation ๐
โญ begin
const_iterator begin () const[inline],[noexcept]โ Returns a read-only (constant) iterator that points to the first element in the unordered_set. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::begin () const
[inline], [noexcept]
iterator begin ()[inline],[noexcept]โ Returns a read-only (constant) iterator that points to the first element in the unordered_set. yes bestie it says read-only on the non-const one too, and it says what it says ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::begin () [inline],
[noexcept]
local_iterator begin (size_type __n)[inline]โ Returns a read-only (constant) iterator pointing to the first bucket element. bucket-level access, iykyk ๐ชฃ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> local_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::begin (size_type
__n) [inline]
Parameters
__nโ The bucket index.
Returns A read-only local iterator.
const_local_iterator begin (size_type __n) const[inline]โ Returns a read-only (constant) iterator pointing to the first bucket element.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
const_local_iterator std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::begin (size_type __n) const [inline]
Parameters
__nโ The bucket index.
Returns A read-only local iterator.
โญ bucket_count
size_type bucket_count () const[inline],[noexcept]โ Returns the number of buckets of the unordered_set. that's literally the whole thing, she's simple and she's iconic ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::bucket_count ()
const [inline], [noexcept]
โญ cbegin
const_iterator cbegin () const[inline],[noexcept]โ Returns a read-only (constant) iterator that points to the first element in the unordered_set. the "c" stands for certified const bestie ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::cbegin () const
[inline], [noexcept]
const_local_iterator cbegin (size_type __n) const[inline]โ Returns a read-only (constant) iterator pointing to the first bucket element. ๐ชฃโจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
const_local_iterator std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::cbegin (size_type __n) const [inline]
Parameters
__nโ The bucket index.
Returns A read-only local iterator.
cend</p> โ the const "that's a wrap" iterator ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::cend () const
[inline], [noexcept]
Bestie, this hands you a read-only (constant) iterator that points one past the last element in the unordered_set. Classic end-of-the-line energy, no cap. Also it's noexcept, so it will not throw at you. ๐
cend</p> (bucket edition) โ same vibe, one bucket at a time ๐ชฃ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
const_local_iterator std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::cend (size_type __n) const [inline]
Returns a read-only (constant) iterator pointing to one past the last bucket elements โ so it's the "end" but scoped to a single bucket, iykyk.
Parameters ๐ธ
__nโ the bucket index.
Returns ๐
- A read-only local iterator.
clear</p> โ the total reset, the fresh-start moment โจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::clear () [inline],
[noexcept]
Erases all elements in an unordered_set. Empty set era. ๐ซถ
โ ๏ธ Okay this part matters fr fr: 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. Not me cleaning up your allocations for you, bestie โ that's your job. ๐
It's [inline] and [noexcept] too, so it's fast and it will not throw.
contains</p> (transparent _Kt version) โ does this key even exist?? ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::contains (const _Kt & __k) const ->
decltype(_M_h._M_find_tr(__k), void(), true)
[inline]
Finds whether an element with the given key exists. Yes/no, that's the whole personality. ๐
Parameters ๐ธ
__xโ key of elements to be located.
Returns ๐
trueif there is any element with the specified key.
contains</p> (plain key_type version) โ same question, no template shenanigans ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> bool
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::contains (const
key_type & __x) const [inline]
Finds whether an element with the given key exists. Same energy, just takes a key_type and returns a plain old bool.
Parameters ๐ธ
__xโ key of elements to be located.
Returns ๐
trueif there is any element with the specified key.
count</p> (transparent _Kt version) โ how many of these we got? ๐งฎ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::count (const _Kt & __k) const ->
decltype(_M_h._M_count_tr(__k))
[inline]
Finds the number of elements. ๐
Parameters ๐ธ
__xโ element to located.
Returns ๐
- Number of elements with specified key.
๐ซถ Little heads-up straight from the source: this function only makes sense forunordered_multisets. Forunordered_setthe result will either be0(not present) or1(present). That's it. That's the range. ๐
count</p> (plain key_type version) โ the non-transparent twin ๐ฏ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::count (const
key_type & __x) const [inline]
Finds the number of elements.
Parameters ๐ธ
__xโ element to located.
Returns ๐
- Number of elements with specified key.
๐ซถ Same caveat, same truth: only makes sense forunordered_multisets; forunordered_setyou get0(not present) or1(present).
emplace</p> โ build it right there in place, icon behaviour ๐๏ธ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename... _Args> std::pair< iterator, bool >
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::emplace (_Args &&...
__args) [inline]
Attempts to build and insert an element into the unordered_set. Crafting it in place, no middleman. ๐ฅ
Parameters ๐ธ
__argsโ arguments used to generate an element.
Returns ๐
- A
pair, of which the first element is aniteratorthat points to the possibly inserted element, and the second is aboolthat istrueif the element was actually inserted.
So here's the lore: this function attempts to build and insert an element into the unordered_set. But an unordered_set relies on unique keys, and thus an element is only inserted if it is not already present in the unordered_set. Duplicate? Denied. ๐
Insertion requires amortized constant time. Slay. โญ
emplace_hint</p> โ same thing 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_set< _Value, _Hash,
_Pred, _Alloc >::emplace_hint (const_iterator __pos, _Args &&... __args)
[inline]
Attempts to insert an element into the unordered_set.
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
iteratorthat points to the element with key equivalent to the one generated from__args(may or may not be the element itself).
Key tea ๐ต: this function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument emplace() does. It's giving "I did the thing, don't ask me if the thing was already there."
Also, real talk: 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 no pressure, but like, get it right if you want the gains. ๐ญ
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</p> โ vibe check: is it empty? ๐ซง
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> bool
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::empty () const
[inline], [noexcept]
Returns true if the unordered_set is empty. Simple. Elegant. [noexcept]. ๐ฆ
end</p> (const) โ the read-only finish line ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::end () const
[inline], [noexcept]
Returns a read-only (constant) iterator that points one past the last element in the unordered_set. [noexcept] so it's chill. ๐
end</p> (non-const) โ the finish line, but mutable-adjacent ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::end () [inline],
[noexcept]
Returns a "read-only (constant) iterator" that points one past the last element in the unordered_set โ that's literally what the docs say for this overload, word for word, we're not editing the source here. ๐
๐ Fun cross-reference moment: this one is Referenced by std::unordered_set< _Value, _Hash, _Pred, _Alloc >::extract(). Main character energy, being used by other functions and everything. ๐
end</p> (bucket, local_iterator) โ bucket-local finish line ๐ชฃ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> local_iterator
std::unordered_set< _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.
end</p> (bucket, const const_local_iterator) โ bucket finish line, const flavour ๐ชฃโจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
const_local_iterator std::unordered_set< _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</p> (transparent _Kt, non-const) โ gimme the whole matching zone ๐ซ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::equal_range (const _Kt & __k) ->
decltype(_M_h._M_equal_range_tr(__k))
[inline]
Finds a subsequence matching given key. Matching set, assembled. ๐
Parameters ๐ธ
__xโ key to be located.
Returns ๐
- Pair of iterators that possibly points to the subsequence matching given key.
๐ซถ Gentle heads-up: this function probably only makes sense for multisets. Not being shady, just quoting the docs, bestie.
equal_range</p> (transparent _Kt, const) โ same zone, but read-only ๐ธ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::equal_range (const _Kt & __k) const ->
decltype(_M_h._M_equal_range_tr(__k))
[inline]
Finds a subsequence matching given key.
Parameters ๐ธ
__xโ key to be located.
Returns ๐
- Pair of iterators that possibly points to the subsequence matching given key.
๐ซถ Again: this function probably only makes sense for multisets.
equal_range</p> (plain key_type, non-const) โ pair<iterator, iterator> ๐ฏ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> std::pair<
iterator, iterator > std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::equal_range (const key_type & __x) [inline]
Finds a subsequence matching given key.
Parameters ๐ธ
__xโ key to be located.
Returns ๐
- Pair of iterators that possibly points to the subsequence matching given key.
๐ซถ Also: this function probably only makes sense for multisets.
equal_range</p> (plain key_type, const) โ pair<const_iterator, const_iterator> ๐ฏโจ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> std::pair<
const_iterator, const_iterator > std::unordered_set< _Value, _Hash,
_Pred, _Alloc >::equal_range (const key_type & __x) const [inline]
Finds a subsequence matching given key.
Parameters ๐ธ
__xโ key to be located.
Returns ๐
- Pair of iterators that possibly points to the subsequence matching given key.
๐ซถ Same note, forever and always: this function probably only makes sense for multisets.
erase</p> (by key) โ bye bye, matching element ๐๏ธ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::erase (const
key_type & __x) [inline]
Erases elements according to the provided key. โ๏ธ
Parameters ๐ธ
__xโ key of element to be erased.
Returns ๐
- The number of elements erased.
This function erases all the elements located by the given key from an unordered_set. For an unordered_set the result of this function can only be 0 (not present) or 1 (present) โ that's the whole spectrum, bestie. ๐
โ ๏ธ And the warning that always comes back around: 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</p> (range) โ erase the whole [__first, __last) stretch ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::erase
(const_iterator __first, const_iterator __last) [inline]
Erases a [__first,__last) range of elements from an unordered_set. Sweep it away. ๐ช๏ธ
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.
fr fr the range version only erases the element itself โ and if that element is a pointer, whatever it points at stays completely untouched. Not a single byte. ๐ Managing that pointer? That's on you, bestie. Not the container's problem, not the allocator's problem. Yours.
๐๏ธ erase(const_iterator __position) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::erase
(const_iterator __position) [inline]
Erases an element from an unordered_set. Bye bestie ๐
__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 โ so like, the one that slides into its spot. And if no such element exists? end() comes back to you. ๐ซถ
So this function erases an element, pointed to by the given iterator, from an unordered_set. And the classic reminder: this only erases the element itself. 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(iterator __position) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::erase (iterator
__position) [inline]
Same energy, non-const iterator flavoured. โจ
Erases an element from an unordered_set.
__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_set. 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(const key_type & __key) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> node_type
std::unordered_set< _Value , _Hash , _Pred , _Alloc >::extract (const
key_type & __key) [inline]
Extract a node. ๐ฆ
๐งฒ extract(const_iterator __pos) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> node_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::extract
(const_iterator __pos) [inline]
Extract a node. ๐ฆ
References: std::unordered_set< _Value, _Hash, _Pred, _Alloc >::end().
๐ find (the fancy _Kt templated one) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value, _Hash, _Pred,
_Alloc >::find (const _Kt & __k) -> decltype(_M_h._M_find_tr(__k))
[inline]"
Tries to locate an element in an unordered_set. ๐ต๏ธโโ๏ธ
__xโ element to be located.
Returns: iterator pointing to sought-after element, or end() if not found.
The vibe check: 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 (the _Kt one, but const) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _Kt > auto std::unordered_set< _Value , _Hash , _Pred ,
_Alloc >::find (const _Kt & __k) const -> decltype(_M_h._M_find_tr(__k))
[inline]"
Tries to locate an element in an unordered_set. Same search, const-qualified, no cap. ๐ซถ
__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.
๐ find(const key_type & __x) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::find (const key_type
& __x) [inline]
Tries to locate an element in an unordered_set. ๐
__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.
๐ find(const key_type & __x) const โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> const_iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::find (const key_type
& __x) const [inline]
Tries to locate an element in an unordered_set. This one hands you a const_iterator, so look but don't touch bestie โจ
__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.
๐ get_allocator() โ [inline], [noexcept]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> allocator_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::get_allocator ()
const [inline], [noexcept]
Returns the allocator object used by the unordered_set. The whole allocator, handed to you, and it's noexcept so it literally cannot fail. Iconic. ๐
๐งฎ hash_function() โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> hasher
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::hash_function ()
const [inline]
Returns the hash functor object with which the unordered_set was constructed. The actual one it was built with โ not a fresh default one. ๐
โ insert(_InputIterator __first, _InputIterator __last) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
template<typename _InputIterator > void std::unordered_set< _Value,
_Hash, _Pred, _Alloc >::insert (_InputIterator __first, _InputIterator
__last) [inline]
A template function that attempts to insert a range of elements. Bulk add, we love a range ๐
__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(const value_type & __x) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> std::pair<
iterator, bool > std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::insert (const value_type & __x) [inline]
Attempts to insert an element into the unordered_set. Attempts, bestie โ no promises. ๐ซถ
__xโ element to be inserted.
Returns: a pair, of which the first element is an iterator that points to the possibly inserted element, and the second is a bool that is true if the element was actually inserted.
This function attempts to insert an element into the unordered_set. An unordered_set relies on unique keys and thus an element is only inserted if it is not already present in the unordered_set. Sorry to the duplicates. ๐
Insertion requires amortized constant time. ๐ฅ
โ insert(const_iterator __hint, const value_type & __x) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::insert
(const_iterator __hint, const value_type & __x) [inline]
Attempts to insert an element into the unordered_set. Now with a hint. ๐ง
__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 element with key of __x (may or may not be the element passed in). ๐
This function is not concerned about whether the insertion took place, and thus does not return a bool like the single-argument insert() does. 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, hint responsibly.
For more on hinting, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
Insertion requires amortized constant. โฑ๏ธ
โ insert(const_iterator __hint, value_type && __x) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::insert
(const_iterator __hint, value_type && __x) [inline]
Same hinted insert, but this one moves your element in. ๐
Attempts to insert an element into the unordered_set.
__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 element with key of __x (may or may not be the element passed in).
This function is not concerned about whether the insertion took place, and thus does not return a bool like the single-argument insert() does. 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.
References: std::move().
โ insert(const_iterator, node_type && __nh) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> iterator
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::insert
(const_iterator, node_type && __nh) [inline]
Re-insert an extracted node. It went out, now it's back, main character energy. ๐
References: std::move().
โ insert(initializer_list< value_type > __l) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::insert
(initializer_list< value_type > __l) [inline]
Attempts to insert a list of elements into the unordered_set. Brace-init girlies rise ๐
__lโ astd::initializer_list<value_type>of elements to be inserted.
Complexity similar to that of the range constructor. ๐ธ
โ insert(node_type && __nh) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>>
insert_return_type std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::insert (node_type && __nh) [inline]
Re-insert an extracted node โ and this version actually tells you how it went, via insert_return_type. ๐ซถ
References: std::move().
โ insert(value_type && __x) โ [inline]
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> std::pair<
iterator, bool > std::unordered_set< _Value, _Hash, _Pred, _Alloc
>::insert (value_type && __x) [inline]
Attempts to insert an element into the unordered_set, move-style. ๐
__xโ element to be inserted.
Returns โ a pair, bestie: the first element is an iterator that points to the possibly inserted element, and the second is a bool thatโs true if the element was actually inserted. ๐
This function attempts to insert an element into the unordered_set. An unordered_set relies on unique keys, and thus an element is only inserted if it is not already present in the unordered_set.
Insertion requires amortized constant time. โก
References std::move().
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> key_equal
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::key_eq () const
[inline]
Returns the key comparison object with which the unordered_set was constructed. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> float
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::load_factor () const
[inline], [noexcept]
Returns the average number of elements per bucket. ๐ชฃ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::max_bucket_count ()
const [inline], [noexcept]
Returns the maximum number of buckets of the unordered_set. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> float
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::max_load_factor ()
const [inline], [noexcept]
Returns a positive number that the unordered_set tries to keep the load factor less than or equal to. ๐ธ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::max_load_factor
(float __z) [inline]
Change the unordered_set maximum load factor. ๐
Parameters
__zโ the new maximum load factor.
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::max_size () const
[inline], [noexcept]
Returns the maximum size of the unordered_set. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> unordered_set &
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::operator= (const
unordered_set< _Value, _Hash, _Pred, _Alloc > &) [default]
Copy assignment operator. ๐ซถ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> unordered_set &
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::operator=
(initializer_list< value_type > __l) [inline]
Unordered_set list assignment operator. โจ
Parameters
__lโ aninitializer_list.
This function fills an unordered_set with copies of the elements in the initializer list __l.
Note that the assignment completely changes theunordered_setand that the resultingunordered_setโs size is the same as the number of elements assigned. ๐ญ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> unordered_set &
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::operator=
(unordered_set< _Value, _Hash, _Pred, _Alloc > &&) [default]
Move assignment operator. ๐ฅ
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::rehash (size_type
__n) [inline]
May rehash the unordered_set. ๐
Parameters
__nโ the new number of buckets.
Rehash will occur only if the new number of buckets respect the unordered_set maximum load factor. ๐ง
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::reserve (size_type
__n) [inline]
Prepare the unordered_set for a specified number of elements. ๐ฆ
Parameters
__nโ number of elements required.
Same as rehash(ceil(n / max_load_factor())). ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> size_type
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::size () const
[inline], [noexcept]
Returns the size of the unordered_set. ๐
template<typename _Value , typename _Hash = hash<_Value>, typename _Pred =
equal_to<_Value>, typename _Alloc = allocator<_Value>> void
std::unordered_set< _Value, _Hash, _Pred, _Alloc >::swap (unordered_set<
_Value, _Hash, _Pred, _Alloc > & __x) [inline], [noexcept]
Swaps data with another unordered_set. ๐
Parameters
__xโ anunordered_setof 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. ๐
๐ AUTHOR ๐
Generated automatically by Doxygen for libstdc++ from the source code. ๐
And thatโs the whole page, bestie ๐ซถ โ source/version is the libstdc++ (3cxx) footer situation, and the date is whatever that footerโs date says (Iโm not inventing one, no cap ๐
).
๐ฆ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms