[#bsl-unordered_set-09]
= xref:bsl.adoc[bsl]::xref:bsl/unordered_set-0d2d.adoc[unordered&lowbar;set]&lt;xref:BloombergLP/ball/Attribute.adoc[Attribute], xref:BloombergLP/ball/DefaultAttributeContainer.adoc[AttributeHash]&gt;
:relfileprefix: ../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an unordered set of unique values (of template parameter type `KEY`)&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;unorderedset&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
class xref:bsl/unordered_set-0d2d.adoc[unordered&lowbar;set]&lt;xref:BloombergLP/ball/Attribute.adoc[Attribute], xref:BloombergLP/ball/DefaultAttributeContainer.adoc[AttributeHash]&gt;;
----

== Description

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations

* except for BDEX serialization &ast; is _exception&hyphen;neutral_ (agnostic except for the `at` method) &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see &lcub;`bsldoc&lowbar;glossary`&rcub;&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/unordered_set-09/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/unordered_set-09/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias to `iterator`&period;
| xref:bsl/unordered_set-09/const_local_iterator.adoc[`const&lowbar;local&lowbar;iterator`] 
| This `typedef` is an alias to `local&lowbar;iterator`&period;
| xref:bsl/unordered_set-09/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to the allocator const&hyphen;pointer type&period;
| xref:bsl/unordered_set-09/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to `const value&lowbar;type&amp;`&period;
| xref:bsl/unordered_set-09/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to the allocator difference type&period;
| xref:bsl/unordered_set-09/hasher.adoc[`hasher`] 
| This `typedef` is an alias to the (template parameter) `HASH` type&period;
| xref:bsl/unordered_set-09/iterator.adoc[`iterator`] 
| This `typedef` is an alias to the hash&hyphen;table iterator type&period;
| xref:bsl/unordered_set-09/key_equal.adoc[`key&lowbar;equal`] 
| This `typedef` is an alias to the (template parameter) `EQUAL` type&period;
| xref:bsl/unordered_set-09/key_type.adoc[`key&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `KEY` type&period;
| xref:bsl/unordered_set-09/local_iterator.adoc[`local&lowbar;iterator`] 
| This `typedef` is an alias for `local&lowbar;iterator`&period;
| xref:bsl/unordered_set-09/pointer.adoc[`pointer`] 
| This `typedef` is an alias to the allocator pointer type&period;
| xref:bsl/unordered_set-09/reference.adoc[`reference`] 
| This `typedef` is an alias to `value&lowbar;type&amp;`&period;
| xref:bsl/unordered_set-09/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to the allocator size type&period;
| xref:bsl/unordered_set-09/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `key&lowbar;type`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/unordered_set-09/2constructor-08d.adoc[`unordered&lowbar;set`]         [.small]#[constructor]#
| Constructors
| xref:bsl/unordered_set-09/2destructor.adoc[`&#126;unordered&lowbar;set`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/unordered_set-09/operator_assign-0d.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/unordered_set-09/begin-01.adoc[`begin`] 
| `begin` overloads
| xref:bsl/unordered_set-09/bucket-00dd5.adoc[`bucket`] 
| Return the index of the bucket, in the array of buckets of this container, where a value equivalent to the specified `key` would be inserted&period;
| xref:bsl/unordered_set-09/bucket_count.adoc[`bucket&lowbar;count`] 
| Return the number of buckets in the array of buckets maintained by this set&period;
| xref:bsl/unordered_set-09/bucket_size.adoc[`bucket&lowbar;size`] 
| Return the number of elements contained in the bucket at the specified `index` in the array of buckets maintained by this container&period;
| xref:bsl/unordered_set-09/cbegin-03.adoc[`cbegin`] 
| `cbegin` overloads
| xref:bsl/unordered_set-09/cend-005.adoc[`cend`] 
| `cend` overloads
| xref:bsl/unordered_set-09/clear.adoc[`clear`] 
| Remove all entries from this unordered set&period; Note that the set is empty after this call, but allocated memory may be retained for future use&period;
| xref:bsl/unordered_set-09/contains-0b1.adoc[`contains`] 
| Return `true` if this unordered set contains an element whose key is equivalent to the specified `key`&period;
| xref:bsl/unordered_set-09/count-0d.adoc[`count`] 
| `count` overloads
| xref:bsl/unordered_set-09/emplace.adoc[`emplace`] 
| Insert into this unordered set a newly created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `arguments` to the corresponding constructor of `value&lowbar;type`, if a key equivalent to such a value does not already exist in this set&semi; otherwise, this method has no effect (other than possibly creating a temporary `value&lowbar;type` object)&period; Return a pair whose `first` member is an iterator referring to the (possibly newly created and inserted) object in this set whose value is equivalent to that of an object constructed from `arguments`, and whose `second` member is `true` if a new value was inserted, and `false` if an equivalent key was already present&period; This method requires that the (template parameter) type `KEY` be `emplace&hyphen;constructible` into this set from `arguments` (see &lcub;Requirements on `KEY`&rcub;)&period;
| xref:bsl/unordered_set-09/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Insert into this unordered set a newly created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `arguments` to the corresponding constructor of `value&lowbar;type`, if a key equivalent to such a value does not already exists in this set&semi; otherwise, this method has no effect (other than possibly creating a temporary `value&lowbar;type` object)&period; Return an iterator referring to the (possibly newly created and inserted) object in this set whose value is equivalent to that of an object constructed from `arguments`&period; The average and worst case complexity of this operation is not affected by the specified `hint`&period; This method requires that the (template parameter) type `KEY` be `emplace&hyphen;constructible` into this set from `arguments` (see &lcub;Requirements on `KEY`&rcub;)&period; The behavior is undefined unless `hint` is an iterator in the range `&lsqb;begin() &period;&period; end()&rsqb;` (both endpoints included)&period; Note that `hint` is ignored (other than possibly asserting its validity in some build modes)&period;
| xref:bsl/unordered_set-09/empty.adoc[`empty`] 
| Return `true` if this set contains no elements, and `false` otherwise&period;
| xref:bsl/unordered_set-09/end-016.adoc[`end`] 
| `end` overloads
| xref:bsl/unordered_set-09/equal_range-0d.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:bsl/unordered_set-09/erase-06.adoc[`erase`] 
| `erase` overloads
| xref:bsl/unordered_set-09/find-0ea.adoc[`find`] 
| `find` overloads
| xref:bsl/unordered_set-09/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this unordered set&period;
| xref:bsl/unordered_set-09/hash_function.adoc[`hash&lowbar;function`] 
| Return (a copy of) the hash unary functor used by this set to generate a hash value (of type `size&lowbar;t`) for a `key&lowbar;type` object&period;
| xref:bsl/unordered_set-09/insert-0b.adoc[`insert`] 
| `insert` overloads
| xref:bsl/unordered_set-09/insert_range.adoc[`insert&lowbar;range`] 
| Insert into this set the value of each `value&lowbar;type` object in the specified `range` if a key equivalent to the object is not already contained in this set&period; The (template parameter) type `RANGE` must meet the requirements the C&plus;&plus;20 standard &lsqb;ranges&rsqb;providing access to values of a type convertible to `value&lowbar;type`, and `value&lowbar;type` must be `emplace&hyphen;constructible` from `&ast;i` into this set, where `i` is a dereferenceable iterator obtained from `range` (see &lcub;Requirements on `KEY`&rcub;)&period; The behavior is undefined if `range` overlaps this set&period;
| xref:bsl/unordered_set-09/key_eq.adoc[`key&lowbar;eq`] 
| Return (a copy of) the key&hyphen;equality binary functor that returns `true` if the value of two `key&lowbar;type` objects are equivalent, and `false` otherwise&period;
| xref:bsl/unordered_set-09/load_factor.adoc[`load&lowbar;factor`] 
| Return the current ratio between the `size` of this container and the number of buckets&period; The `load&lowbar;factor` is a measure of how full the container is, and a higher load factor leads to an increased number of collisions, thus resulting in a loss performance&period;
| xref:bsl/unordered_set-09/max_bucket_count.adoc[`max&lowbar;bucket&lowbar;count`] 
| Return a theoretical upper bound on the largest number of buckets that this container could possibly manage&period; Note that there is no guarantee that the set can successfully grow to the returned size, or even close to that size without running out of resources&period;
| xref:bsl/unordered_set-09/max_load_factor-0d.adoc[`max&lowbar;load&lowbar;factor`] 
| `max&lowbar;load&lowbar;factor` overloads
| xref:bsl/unordered_set-09/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on the largest number of elements that this set could possibly hold&period; Note that there is no guarantee that the set can successfully grow to the returned size, or even close to that size without running out of resources&period;
| xref:bsl/unordered_set-09/rehash.adoc[`rehash`] 
| Change the size of the array of buckets maintained by this container to the specified `numBuckets`, and redistribute all the contained elements into the new sequence of buckets, according to their hash values&period; Note that this operation has no effect if rehashing the elements into `numBuckets` would cause this set to exceed its `max&lowbar;load&lowbar;factor`&period;
| xref:bsl/unordered_set-09/reserve.adoc[`reserve`] 
| Increase the number of buckets of this set to a quantity such that the ratio between the specified `numElements` and this quantity does not exceed `max&lowbar;load&lowbar;factor`&period; Note that this guarantees that, after the reserve, elements can be inserted to grow the container to `size() &equals;&equals; numElements` without rehashing&period; Also note that memory allocations may still occur when growing the container to `size() &equals;&equals; numElements`&period; Also note that this operation has no effect if `numElements &lt;&equals; size()`&period;
| xref:bsl/unordered_set-09/size.adoc[`size`] 
| Return the number of elements in this set&period;
| xref:bsl/unordered_set-09/swap.adoc[`swap`] 
| Exchange the value, hasher, key&hyphen;equality functor, and `max&lowbar;load&lowbar;factor` of this object with those of the specified `other` object&semi; also exchange the allocator of this object with that of `other` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if both the (template parameter) types `HASH` and `EQUAL` provide no&hyphen;throw swap operations&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation guarantees `O&lsqb;1&rsqb;` complexity&period; The behavior is undefined unless either this object was created with the same allocator as `other` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&period;
| xref:bsl/unordered_set-09/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;unordered&lowbar;set&lt;Attribute, AttributeHash&gt;, IsBitwiseMoveable, &colon;&colon;BloombergLP&colon;&colon;bslmf&colon;&colon;IsBitwiseMoveable&lt;HashTable&gt;&colon;&colon;value&gt;`] 
| 
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/operator_eq-0b3.adoc[bsl::operator&equals;&equals;]`
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `unordered&lowbar;set` objects have the same value if they have the same number of value&hyphen;elements, and for each value&hyphen;element that is contained in `lhs` there is a value&hyphen;element contained in `rhs` having the same value, and vice&hyphen;versa&period; Note that this method requires that the (template parameter) type `KEY` be `equality&hyphen;comparable` (see &lcub;Requirements on `KEY`&rcub;)&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
