[#BloombergLP-bdlc-FlatHashMap]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlc.adoc[bdlc]::FlatHashMap
:relfileprefix: ../../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an unordered map of `KEY&hyphen;VALUE` pairs having unique keys that provides a mapping from keys of (template parameter) type `KEY` to their associated mapped values of (template parameter) type `VALUE`&period; The (template parameter) type `HASH` is a functor providing the hash value for `KEY`&period; The (template parameter) type `EQUAL` is a functor providing the equality function for two `KEY` values&period; See &lcub;Requirements on `KEY`, `HASH`, and `EQUAL`&rcub; for more information&period;

== Synopsis

Declared in `&lt;bdlc&lowbar;flathashmap&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class HASH = xref:BloombergLP/bslh/FibonacciBadHashWrapper.adoc[bslh::FibonacciBadHashWrapper&lt;bsl::hash&lt;KEY&gt;&gt;],
    class EQUAL = xref:bsl/equal_to-0d.adoc[bsl::equal&lowbar;to&lt;KEY&gt;]&gt;
class FlatHashMap;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/FlatHashMap/const_iterator.adoc[`const&lowbar;iterator`] 
| Iterator over non&hyphen;modifiable elements&period;
| xref:BloombergLP/bdlc/FlatHashMap/const_pointer.adoc[`const&lowbar;pointer`] 
| Pointer to a non&hyphen;modifiable value&period;
| xref:BloombergLP/bdlc/FlatHashMap/const_reference.adoc[`const&lowbar;reference`] 
| Reference to a non&hyphen;modifiable value&period;
| xref:BloombergLP/bdlc/FlatHashMap/difference_type.adoc[`difference&lowbar;type`] 
| Signed type used for iterator distances&period;
| xref:BloombergLP/bdlc/FlatHashMap/hasher.adoc[`hasher`] 
| Hash functor type&period;
| xref:BloombergLP/bdlc/FlatHashMap/iterator.adoc[`iterator`] 
| Iterator over modifiable elements&period;
| xref:BloombergLP/bdlc/FlatHashMap/key_compare.adoc[`key&lowbar;compare`] 
| Key equality predicate type&period;
| xref:BloombergLP/bdlc/FlatHashMap/key_type.adoc[`key&lowbar;type`] 
| Key type of this map&period;
| xref:BloombergLP/bdlc/FlatHashMap/mapped_type.adoc[`mapped&lowbar;type`] 
| Mapped value type of this map&period;
| xref:BloombergLP/bdlc/FlatHashMap/pointer.adoc[`pointer`] 
| Pointer to a modifiable value&period;
| xref:BloombergLP/bdlc/FlatHashMap/reference.adoc[`reference`] 
| Reference to a modifiable value&period;
| xref:BloombergLP/bdlc/FlatHashMap/size_type.adoc[`size&lowbar;type`] 
| Unsigned type used for sizes and capacities&period;
| xref:BloombergLP/bdlc/FlatHashMap/value_type.adoc[`value&lowbar;type`] 
| Key&sol;value pair type stored by this map&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/FlatHashMap/2constructor-056.adoc[`FlatHashMap`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlc/FlatHashMap/2destructor.adoc[`&#126;FlatHashMap`] [.small]#[destructor]#
| Destroy this object and each of its elements&period;
| xref:BloombergLP/bdlc/FlatHashMap/operator_assign-04.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bdlc/FlatHashMap/allocator.adoc[`allocator`] 
| Return the allocator used by this flat hash map to supply memory&period;
| xref:BloombergLP/bdlc/FlatHashMap/at-09.adoc[`at`] 
| `at` overloads
| xref:BloombergLP/bdlc/FlatHashMap/begin-06.adoc[`begin`] 
| `begin` overloads
| xref:BloombergLP/bdlc/FlatHashMap/capacity.adoc[`capacity`] 
| Return the number of elements this map could hold if the load factor were 1&period;
| xref:BloombergLP/bdlc/FlatHashMap/cbegin.adoc[`cbegin`] 
| Return a `const&lowbar;iterator` to the first element in the sequence of elements maintained by this map, or the `end` iterator if this map is empty&period;
| xref:BloombergLP/bdlc/FlatHashMap/cend.adoc[`cend`] 
| Return a `const&lowbar;iterator` to the past&hyphen;the&hyphen;end element in the sequence of elements maintained by this map&period;
| xref:BloombergLP/bdlc/FlatHashMap/clear.adoc[`clear`] 
| Remove all elements from this map&period; Note that this map will be empty after calling this method, but allocated memory may be retained for future use&period; See the `capacity` method&period;
| xref:BloombergLP/bdlc/FlatHashMap/contains-09.adoc[`contains`] 
| `contains` overloads
| xref:BloombergLP/bdlc/FlatHashMap/count-0d.adoc[`count`] 
| `count` overloads
| xref:BloombergLP/bdlc/FlatHashMap/emplace.adoc[`emplace`] 
| Insert into this 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:BloombergLP/bdlc/FlatHashMap/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Insert into this 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:BloombergLP/bdlc/FlatHashMap/empty.adoc[`empty`] 
| Return `true` if this map contains no elements, and `false` otherwise&period;
| xref:BloombergLP/bdlc/FlatHashMap/end-03.adoc[`end`] 
| `end` overloads
| xref:BloombergLP/bdlc/FlatHashMap/equal_range-02.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:BloombergLP/bdlc/FlatHashMap/erase-04b.adoc[`erase`] 
| `erase` overloads
| xref:BloombergLP/bdlc/FlatHashMap/find-04.adoc[`find`] 
| `find` overloads
| xref:BloombergLP/bdlc/FlatHashMap/hash_function.adoc[`hash&lowbar;function`] 
| Return (a copy of) the unary hash functor used by this map to generate a hash value (of type `bsl&colon;&colon;size&lowbar;t`) for a `KEY` object&period;
| xref:BloombergLP/bdlc/FlatHashMap/insert-08.adoc[`insert`] 
| `insert` overloads
| xref:BloombergLP/bdlc/FlatHashMap/insert_or_assign-0f.adoc[`insert&lowbar;or&lowbar;assign`] 
| `insert&lowbar;or&lowbar;assign` overloads
| xref:BloombergLP/bdlc/FlatHashMap/key_eq.adoc[`key&lowbar;eq`] 
| Return (a copy of) the binary key&hyphen;equality functor that returns `true` if the value of two `KEY` objects are equivalent, and `false` otherwise&period;
| xref:BloombergLP/bdlc/FlatHashMap/load_factor.adoc[`load&lowbar;factor`] 
| Return the current ratio between the number of elements in this container and its capacity&period;
| xref:BloombergLP/bdlc/FlatHashMap/max_load_factor.adoc[`max&lowbar;load&lowbar;factor`] 
| Return the maximum load factor allowed for this map&period; Note that if an insert operation would cause the load factor to exceed `max&lowbar;load&lowbar;factor()`, that same insert operation will increase the capacity and rehash the entries of the container (see &lcub;Load Factor and Resizing&rcub;)&period; Also note that the value returned by `max&lowbar;load&lowbar;factor` is implementation defined and cannot be changed by the user&period;
| xref:BloombergLP/bdlc/FlatHashMap/operator_subs-03.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:BloombergLP/bdlc/FlatHashMap/print.adoc[`print`] 
| Format this object to the specified output `stream` at the (absolute value of) the optionally specified indentation `level`, and return a reference to the modifiable `stream`&period; If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period;
| xref:BloombergLP/bdlc/FlatHashMap/rehash.adoc[`rehash`] 
| Change the capacity of this map to at least the specified `minimumCapacity`, and redistribute all the contained elements into a new sequence of entries according to their hash values&period; If `0 &equals;&equals; minimumCapacity` and `0 &equals;&equals; size()`, the map is returned to the default constructed state&period; After this call, `load&lowbar;factor()` will be less than or equal to `max&lowbar;load&lowbar;factor()` and all iterators, pointers, and references to elements of this map are invalidated&period;
| xref:BloombergLP/bdlc/FlatHashMap/reserve.adoc[`reserve`] 
| Change the capacity of this map to at least a capacity that can accommodate the specified `numEntries` (accounting for the load factor invariant), and redistribute all the contained elements into a new sequence of entries according to their hash values&period; If `0 &equals;&equals; numEntries` and `0 &equals;&equals; size()`, the map is returned to the default constructed state&period; After this call, `load&lowbar;factor()` will be less than or equal to `max&lowbar;load&lowbar;factor()` and all iterators, pointers, and references to elements of this map are invalidated&period; Note that this method is effectively equivalent to&colon; &grave; rehash(bsl&colon;&colon;ceil(numEntries &sol; max&lowbar;load&lowbar;factor())) &grave;
| xref:BloombergLP/bdlc/FlatHashMap/reset.adoc[`reset`] 
| Remove all elements from this map and release all memory from this map, returning the map to the default constructed state&period;
| xref:BloombergLP/bdlc/FlatHashMap/size.adoc[`size`] 
| Return the number of elements in this map&period;
| xref:BloombergLP/bdlc/FlatHashMap/swap.adoc[`swap`] 
| Exchange the value of this object as well as its hasher and equality functors with those of the specified `other` object&period; The behavior is undefined unless this object was created with the same allocator as `other`&period;
| xref:BloombergLP/bdlc/FlatHashMap/try_emplace-03.adoc[`try&lowbar;emplace`] 
| `try&lowbar;emplace` overloads
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlc/swap-05.adoc[BloombergLP::bdlc::swap]`
| Exchange the contents of the two maps&period;
| `xref:BloombergLP/bdlc/operator_not_eq-06.adoc[BloombergLP::bdlc::operator!&equals;]`
| Return whether the maps differ in key&sol;value contents&period;
| `xref:BloombergLP/bdlc/operator_eq-04c.adoc[BloombergLP::bdlc::operator&equals;&equals;]`
| Return whether the maps have the same key&sol;value contents&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/operator_not_eq-0b1.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; Two `FlatHashMap` objects do not have the same value if their sizes are different or one contains an element equal to no element of the other&period; The hash and equality functors are not involved in the comparison&period;
| xref:BloombergLP/bdlc/operator_eq-0d9.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `FlatHashMap` objects have the same value if their sizes are the same and each element contained in one is equal to an element of the other&period; The hash and equality functors are not involved in the comparison&period;
| xref:BloombergLP/bdlc/swap-061.adoc[`swap`]
| Exchange the value, the hasher, and the key&hyphen;equality functor of the specified `a` and `b` objects&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if the two objects were created with the same allocator and the basic guarantee otherwise&period;
|===


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