std::unordered_set (3) - Linux Manuals
std::unordered_set: std::unordered_set
NAME
std::unordered_set - std::unordered_set
Synopsis
Defined in header <unordered_set>
template<
class Key,
class Hash = std::hash<Key>, (1) (since C++11)
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<Key>
> class unordered_set;
namespace pmr {
template <class Key,
class Hash = std::hash<Key>,
class Pred = std::equal_to<Key>> (2) (since C++17)
using unordered_set = std::unordered_set<Key, Hash, Pred,
std::pmr::polymorphic_allocator<Key>>;
}
Unordered set is an associative container that contains a set of unique objects of type Key. Search, insertion, and removal have average constant-time complexity.
Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its value. This allows fast access to individual elements, since once a hash is computed, it refers to the exact bucket the element is placed into.
Container elements may not be modified (even by non const iterators) since modification could change an element's hash and corrupt the container.
std::unordered_set meets the requirements of Container, AllocatorAwareContainer, UnorderedAssociativeContainer.
Member types
Member type Definition
key_type Key
value_type Key
size_type Unsigned integer type (usually std::size_t)
difference_type Signed integer type (usually std::ptrdiff_t)
hasher Hash
key_equal KeyEqual (until C++20)
allocator_type Allocator
reference value_type&
const_reference const value_type&
pointer std::allocator_traits<Allocator>::pointer
const_pointer std::allocator_traits<Allocator>::const_pointer
iterator Constant LegacyForwardIterator
const_iterator Constant LegacyForwardIterator
local_iterator reference types are the same as iterator. This iterator
const_local_iterator reference types are the same as const_iterator. This iterator
node_type(since C++17) a specialization of node_handle representing a container node