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

This class template provides a flat hash table implementation useful for implementing a flat hash set and flat hash map&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class ENTRY,
    class ENTRY&lowbar;UTIL,
    class HASH,
    class EQUAL&gt;
class FlatHashTable;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/FlatHashTable/const_iterator.adoc[`const&lowbar;iterator`] 
| Iterator over non&hyphen;modifiable entries&period;
| xref:BloombergLP/bdlc/FlatHashTable/entry_type.adoc[`entry&lowbar;type`] 
| Entry type stored by this table&period;
| xref:BloombergLP/bdlc/FlatHashTable/entry_util_type.adoc[`entry&lowbar;util&lowbar;type`] 
| Utility that extracts keys from entries&period;
| xref:BloombergLP/bdlc/FlatHashTable/hash_type.adoc[`hash&lowbar;type`] 
| Hash functor type&period;
| xref:BloombergLP/bdlc/FlatHashTable/iterator.adoc[`iterator`] 
| Iterator over modifiable entries&period;
| xref:BloombergLP/bdlc/FlatHashTable/key_equal_type.adoc[`key&lowbar;equal&lowbar;type`] 
| Key equality predicate type&period;
| xref:BloombergLP/bdlc/FlatHashTable/key_type.adoc[`key&lowbar;type`] 
| Key type of this table&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/FlatHashTable/2constructor-0f.adoc[`FlatHashTable`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlc/FlatHashTable/2destructor.adoc[`&#126;FlatHashTable`] [.small]#[destructor]#
| Destroy this object and each of its entries&period;
| xref:BloombergLP/bdlc/FlatHashTable/operator_assign-00.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bdlc/FlatHashTable/allocator.adoc[`allocator`] 
| Return the allocator used by this hash table to supply memory&period;
| xref:BloombergLP/bdlc/FlatHashTable/begin-05.adoc[`begin`] 
| `begin` overloads
| xref:BloombergLP/bdlc/FlatHashTable/capacity.adoc[`capacity`] 
| Return the number of elements this table could hold if the load factor were 1&period;
| xref:BloombergLP/bdlc/FlatHashTable/cbegin.adoc[`cbegin`] 
| Return an iterator representing the beginning of the sequence of entries held by this container&period;
| xref:BloombergLP/bdlc/FlatHashTable/cend.adoc[`cend`] 
| Return an iterator one past the last entry in this table&period;
| xref:BloombergLP/bdlc/FlatHashTable/clear.adoc[`clear`] 
| Remove all entries from this table&period; Note that this table 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/FlatHashTable/contains.adoc[`contains`] 
| Return `true` if this table contains an entry having the specified `key`, and `false` otherwise&period;
| xref:BloombergLP/bdlc/FlatHashTable/controls.adoc[`controls`] 
| Return the address of the first element of the underlying array of control values in this table, or 0 if this table is in the zero&hyphen;capacity state&period; An element of this array has the value `FlatHashTable&lowbar;GroupControl&colon;&colon;k&lowbar;EMPTY`, `FlatHashTable&lowbar;GroupControl&colon;&colon;k&lowbar;ERASED`, or a seven bit hashlet value for the in&hyphen;use position (the highest&hyphen;order bit is unset)&period;
| xref:BloombergLP/bdlc/FlatHashTable/count.adoc[`count`] 
| Return the number of objects contained within this table having the specified `key`&period; Note that since a table maintains unique keys, the returned value will be either 0 or 1&period;
| xref:BloombergLP/bdlc/FlatHashTable/emplace.adoc[`emplace`] 
| Create an `ENTRY` object from the specified `args`, and attempt to add it to this flat hash table&period; Return a `bsl&colon;&colon;pair` containing an iterator to the newly inserted object and `true` if the element was added&period; If an entry with the same key already exists in this flat hash table, return an iterator to that entry and `false`&period; This method requires that the `ENTRY` be `copy&hyphen;constructible`&period;
| xref:BloombergLP/bdlc/FlatHashTable/empty.adoc[`empty`] 
| Return `true` if this table contains no entries, and `false` otherwise&period;
| xref:BloombergLP/bdlc/FlatHashTable/end-07.adoc[`end`] 
| Return an iterator representing one past the end of the sequence of entries held by this container&period;
| xref:BloombergLP/bdlc/FlatHashTable/entries.adoc[`entries`] 
| Return the address of the first element of the underlying array of entries in this table, or 0 if this table is in the zero&hyphen;capacity state&period; The behavior is undefined unless the address is verified in&hyphen;use through use of the `controls` array before dereferencing an entry in this array&period;
| xref:BloombergLP/bdlc/FlatHashTable/equal_range-07.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:BloombergLP/bdlc/FlatHashTable/erase-03.adoc[`erase`] 
| `erase` overloads
| xref:BloombergLP/bdlc/FlatHashTable/find-082.adoc[`find`] 
| `find` overloads
| xref:BloombergLP/bdlc/FlatHashTable/hash_function.adoc[`hash&lowbar;function`] 
| Return (a copy of) the unary hash functor used by this flat hash table to generate a hash value (of type `bsl&colon;&colon;size&lowbar;t) for a `KEY&apos; object&period;
| xref:BloombergLP/bdlc/FlatHashTable/insert-0e.adoc[`insert`] 
| `insert` overloads
| xref:BloombergLP/bdlc/FlatHashTable/insertTransparent.adoc[`insertTransparent`] 
| Insert the specified `key` into this table if a key equivalent to `key` does not already exist in this table&semi; otherwise, this method has no effect&period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) object in this table whose key is the equal to that of the object to be inserted, and whose `second` member is `true` if a new entry was inserted, and `false` if a entry having an equal key was already present&period; Bitwise movable types that are not bitwise copyable will be copied (to avoid confusion with regard to calling the `entry` destructor after this call)&period;
| xref:BloombergLP/bdlc/FlatHashTable/key_eq.adoc[`key&lowbar;eq`] 
| Return (a copy of) the binary key&hyphen;equality functor used by this flat hash table that returns `true` if two `KEY` objects are equal, and `false` otherwise&period;
| xref:BloombergLP/bdlc/FlatHashTable/load_factor.adoc[`load&lowbar;factor`] 
| Return the current ratio between the number of elements in this table and its capacity&period;
| xref:BloombergLP/bdlc/FlatHashTable/max_load_factor.adoc[`max&lowbar;load&lowbar;factor`] 
| Return the maximum load factor allowed for this table&period; Note that if an insert operation would cause the load factor to exceed the `max&lowbar;load&lowbar;factor`, that same insert operation will increase the capacity and rehash the entries of the container (see `insert` and `rehash`)&period; Note that the value returned by `max&lowbar;load&lowbar;factor` is implementation dependent and cannot be changed by the user&period;
| xref:BloombergLP/bdlc/FlatHashTable/operator_subs.adoc[`operator&lsqb;&rsqb;`] 
| If an entry with the specified `key` is not already present in this table, insert an entry having the value defined by `ENTRY&lowbar;UTIL&colon;&colon;construct`&semi; otherwise, this method has no effect&period; Return an iterator referring to the (possibly newly inserted) object in this table with the `key`&period;
| xref:BloombergLP/bdlc/FlatHashTable/rehash.adoc[`rehash`] 
| Change the capacity of this table 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 table is returned to the zero&hyphen;capacity state&period; On return, `load&lowbar;factor()` is less than or equal to `max&lowbar;load&lowbar;factor()` and all iterators, pointers, and references to elements of this `FlatHashTable` are invalidated&period;
| xref:BloombergLP/bdlc/FlatHashTable/reserve.adoc[`reserve`] 
| Change the capacity of this table 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 table is returned to the zero&hyphen;capacity state&period; After this call, `load&lowbar;factor()` will be less than or equal to `max&lowbar;load&lowbar;factor()`&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/FlatHashTable/reset.adoc[`reset`] 
| Remove all entries from this table and release all memory from this table, returning the table to the zero&hyphen;capacity state&period;
| xref:BloombergLP/bdlc/FlatHashTable/size.adoc[`size`] 
| Return the number of entries in this table&period;
| xref:BloombergLP/bdlc/FlatHashTable/swap.adoc[`swap`] 
| Efficiently exchange the value of this table with the value of the specified `other` table&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee&period; The behavior is undefined unless this array was created with the same allocator as `other`&period;
| xref:BloombergLP/bdlc/FlatHashTable/try_emplace-0b.adoc[`try&lowbar;emplace`] 
| `try&lowbar;emplace` overloads
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/FlatHashTable/k_HASHLET_MASK.adoc[`k&lowbar;HASHLET&lowbar;MASK`] 
| Mask extracting the 7&hyphen;bit hashlet from a full hash value&period;
| xref:BloombergLP/bdlc/FlatHashTable/k_MAX_LOAD_FACTOR_DENOMINATOR.adoc[`k&lowbar;MAX&lowbar;LOAD&lowbar;FACTOR&lowbar;DENOMINATOR`] 
| Denominator of the maximum load&hyphen;factor fraction (7&sol;8)&period;
| xref:BloombergLP/bdlc/FlatHashTable/k_MAX_LOAD_FACTOR_NUMERATOR.adoc[`k&lowbar;MAX&lowbar;LOAD&lowbar;FACTOR&lowbar;NUMERATOR`] 
| Numerator of the maximum load&hyphen;factor fraction (7&sol;8)&period;
| xref:BloombergLP/bdlc/FlatHashTable/k_MIN_CAPACITY.adoc[`k&lowbar;MIN&lowbar;CAPACITY`] 
| Minimum non&hyphen;zero table capacity (two control groups)&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/operator_not_eq-0be.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; Two `FlatHashTable` objects do not have the same value if they do not have the same number of entries, or that for some entry contained in `lhs` there is not a entry in `rhs` having the same value&period; Note that this method requires the (template parameter) type `ENTRY` to be equality&hyphen;comparable&period;
| xref:BloombergLP/bdlc/operator_eq-0d5.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `FlatHashTable` objects have the same value if they have the same number of entries, and for each entry that is contained in `lhs` there is a entry contained in `rhs` having the same value&period; Note that this method requires the (template parameter) type `ENTRY` to be equality&hyphen;comparable&period;
| xref:BloombergLP/bdlc/swap-0b6.adoc[`swap`]
| Exchange the values 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]#
