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 spicy noexcept spec 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 an unordered_multiset rvalue.
  • template<typename _H2 , typename _P2 > void merge (unordered_multiset< _Value, _H2, _P2, _Alloc > &__source) โ€” merge from an unordered_multiset lvalue.
  • template<typename _H2 , typename _P2 > void merge (unordered_set< _Value, _H2, _P2, _Alloc > &&__source) โ€” merge from an unordered_set rvalue.
  • template<typename _H2 , typename _P2 > void merge (unordered_set< _Value, _H2, _P2, _Alloc > &__source) โ€” merge from an unordered_set lvalue.
  • 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-operator void() 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 to hash<_Value>.
  • _Pred โ€” Predicate function object type, defaults to equal_to<_Value>.
  • _Alloc โ€” Allocator type, defaults to allocator<_Key>.
ngl the _Alloc line really does say allocator<_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 ๐Ÿ’–

  • true if 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 ๐Ÿ’–

  • true if 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 for unordered_multisets. For unordered_set the result will either be 0 (not present) or 1 (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 for unordered_multisets; for unordered_set you get 0 (not present) or 1 (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 an iterator that points to the possibly inserted element, and the second is a bool that is true if 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 iterator that 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 โ€” a std::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 โ€” an initializer_list.

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

Note that the assignment completely changes the unordered_set and that the resulting unordered_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 โ€” an unordered_set 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. ๐ŸŒ€


๐Ÿ‘‘ 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