[#bsl-unordered_map-0bf]
= xref:bsl.adoc[bsl]::xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map]&lt;xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char&gt;], xref:BloombergLP/bdljsn/Json.adoc[Json], xref:BloombergLP/bdlb/TransparentHash.adoc[TransparentHash], xref:BloombergLP/bdlb/TransparentEqualTo.adoc[TransparentEqualTo]&gt;
:relfileprefix: ../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an unordered set of `KEY&hyphen;VALUE` pairs having unique keys that provide a mapping from keys (of template parameter type `KEY`) to their associated mapped values (of template parameter type `VALUE`)&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
class xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map]&lt;xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char&gt;], xref:BloombergLP/bdljsn/Json.adoc[Json], xref:BloombergLP/bdlb/TransparentHash.adoc[TransparentHash], xref:BloombergLP/bdlb/TransparentEqualTo.adoc[TransparentEqualTo]&gt;;
----

== Description

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations &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_map-0bf/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/unordered_map-0bf/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias to `HashTableIterator&lt;const value&lowbar;type&gt;`&period;
| xref:bsl/unordered_map-0bf/const_local_iterator.adoc[`const&lowbar;local&lowbar;iterator`] 
| This `typedef` is an alias to `HashTableBucketIterator&lt;const value&lowbar;type&gt;`&period;
| xref:bsl/unordered_map-0bf/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;const&lowbar;pointer`&period;
| xref:bsl/unordered_map-0bf/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to `const value&lowbar;type&amp;`&period;
| xref:bsl/unordered_map-0bf/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;difference&lowbar;type`&period;
| xref:bsl/unordered_map-0bf/hasher.adoc[`hasher`] 
| This `typedef` is an alias to the (template parameter) `HASH`&period;
| xref:bsl/unordered_map-0bf/iterator.adoc[`iterator`] 
| This `typedef` is an alias to `HashTableIterator&lt;value&lowbar;type&gt;`&period;
| xref:bsl/unordered_map-0bf/key_equal.adoc[`key&lowbar;equal`] 
| This `typedef` is an alias to the (template parameter) `EQUAL`&period;
| xref:bsl/unordered_map-0bf/key_type.adoc[`key&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `KEY`&period;
| xref:bsl/unordered_map-0bf/local_iterator.adoc[`local&lowbar;iterator`] 
| This `typedef` is an alias to `HashTableBucketIterator&lt;value&lowbar;type&gt;`&period;
| xref:bsl/unordered_map-0bf/mapped_type.adoc[`mapped&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `VALUE`&period;
| xref:bsl/unordered_map-0bf/pointer.adoc[`pointer`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;pointer`&period;
| xref:bsl/unordered_map-0bf/reference.adoc[`reference`] 
| This `typedef` is an alias to `value&lowbar;type&amp;`&period;
| xref:bsl/unordered_map-0bf/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;size&lowbar;type`&period;
| xref:bsl/unordered_map-0bf/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to `bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/unordered_map-0bf/2constructor-0b0.adoc[`unordered&lowbar;map`]         [.small]#[constructor]#
| Constructors
| xref:bsl/unordered_map-0bf/2destructor.adoc[`&#126;unordered&lowbar;map`] [.small]#[destructor]#
| Destroy this object and each of its elements&period;
| xref:bsl/unordered_map-0bf/operator_assign-0b.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/unordered_map-0bf/at-06.adoc[`at`] 
| `at` overloads
| xref:bsl/unordered_map-0bf/begin-0ff.adoc[`begin`] 
| `begin` overloads
| xref:bsl/unordered_map-0bf/bucket-04.adoc[`bucket`] 
| `bucket` overloads
| xref:bsl/unordered_map-0bf/bucket_count.adoc[`bucket&lowbar;count`] 
| Return the number of buckets in the array of buckets maintained by this unordered map&period;
| xref:bsl/unordered_map-0bf/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 unordered map&period; The behavior is undefined unless `index &lt; bucket&lowbar;count()`&period;
| xref:bsl/unordered_map-0bf/cbegin-0f.adoc[`cbegin`] 
| `cbegin` overloads
| xref:bsl/unordered_map-0bf/cend-07.adoc[`cend`] 
| `cend` overloads
| xref:bsl/unordered_map-0bf/clear.adoc[`clear`] 
| Remove all entries from this unordered map&period; Note that this unordered map will be empty after calling this method, but allocated memory may be retained for future use&period;
| xref:bsl/unordered_map-0bf/contains-0d.adoc[`contains`] 
| Return `true` if this unordered map contains an element whose key is equivalent to the specified `key`&period;
| xref:bsl/unordered_map-0bf/count-03.adoc[`count`] 
| `count` overloads
| xref:bsl/unordered_map-0bf/emplace.adoc[`emplace`] 
| Insert into this unordered map a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type`, if a key equivalent to such a value does not already exist in this map&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 map whose key is equivalent to that of an object constructed from `args`, 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) types `KEY` and `VALUE` both be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period;
| xref:bsl/unordered_map-0bf/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Insert into this unordered map a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type`, if a key equivalent to such a value does not already exist in this map&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 map whose key is equivalent to that of an object constructed from `args`&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) types `KEY` and `VALUE` both be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `value&lowbar;type`&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_map-0bf/empty.adoc[`empty`] 
| Return `true` if this unordered map contains no elements, and `false` otherwise&period;
| xref:bsl/unordered_map-0bf/end-06.adoc[`end`] 
| `end` overloads
| xref:bsl/unordered_map-0bf/equal_range-06.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:bsl/unordered_map-0bf/erase-06.adoc[`erase`] 
| `erase` overloads
| xref:bsl/unordered_map-0bf/find-07.adoc[`find`] 
| `find` overloads
| xref:bsl/unordered_map-0bf/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this unordered map&period;
| xref:bsl/unordered_map-0bf/hash_function.adoc[`hash&lowbar;function`] 
| Return (a copy of) the unary hash functor used by this unordered map to generate a hash value (of type `size&lowbar;type`) for a `key&lowbar;type` object&period;
| xref:bsl/unordered_map-0bf/insert-0a.adoc[`insert`] 
| `insert` overloads
| xref:bsl/unordered_map-0bf/insert_or_assign-01.adoc[`insert&lowbar;or&lowbar;assign`] 
| `insert&lowbar;or&lowbar;assign` overloads
| xref:bsl/unordered_map-0bf/insert_range.adoc[`insert&lowbar;range`] 
| Insert into this map 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 map&period;
| xref:bsl/unordered_map-0bf/key_eq.adoc[`key&lowbar;eq`] 
| Return (a copy of) binary the key&hyphen;equality functor used by this unordered map that returns `true` if two `key&lowbar;type` objects are equivalent, and `false` otherwise&period;
| xref:bsl/unordered_map-0bf/load_factor.adoc[`load&lowbar;factor`] 
| Return the current ratio between the `size` of this unordered map and the number of buckets&period; The load factor is a measure of how full the container is, and a higher load factor typically leads to an increased number of collisions, thus resulting in a loss of performance&period;
| xref:bsl/unordered_map-0bf/max_bucket_count.adoc[`max&lowbar;bucket&lowbar;count`] 
| Return a theoretical upper bound on the largest number of buckets that this unordered map could possibly manage&period; Note that there is no guarantee that the unordered map can successfully grow to the returned size, or even close to that size, without running out of resources&period;
| xref:bsl/unordered_map-0bf/max_load_factor-099a1.adoc[`max&lowbar;load&lowbar;factor`] 
| `max&lowbar;load&lowbar;factor` overloads
| xref:bsl/unordered_map-0bf/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on the largest number of elements that this unordered map could possibly hold&period; Note that there is no guarantee that the unordered map can successfully grow to the returned size, or even close to that size, without running out of resources&period;
| xref:bsl/unordered_map-0bf/operator_subs-0a.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:bsl/unordered_map-0bf/rehash.adoc[`rehash`] 
| Change the size of the array of buckets maintained by this unordered map to at least the specified `numBuckets`, and redistribute all the contained elements into the new sequence of buckets, according to their hash values&period; After this call, `load&lowbar;factor` will be less than or equal to `max&lowbar;load&lowbar;factor`&period; This operation has no effect if rehashing the elements into `numBuckets` would cause this map to exceed its `max&lowbar;load&lowbar;factor`&period;
| xref:bsl/unordered_map-0bf/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 &grave;size() &equals;&equals; numElements&grave;&period; Also note that this operation has no effect if `numElements &lt;&equals; size()`&period;
| xref:bsl/unordered_map-0bf/size.adoc[`size`] 
| Return the number of elements in this unordered map&period;
| xref:bsl/unordered_map-0bf/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_map-0bf/try_emplace-092.adoc[`try&lowbar;emplace`] 
| `try&lowbar;emplace` overloads
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/operator_eq-024.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;map` objects have the same value if they have the same number of key&hyphen;value pairs, and for each key&hyphen;value pair that is contained in `lhs` there is a key&hyphen;value pair contained in `rhs` having the same value, and vice versa&period; Note that this method requires that the (template parameter) types `KEY` and `VALUE` both be `equality&hyphen;comparable` (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period;
|===


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