[#BloombergLP-bslalg-HashTableImpUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::HashTableImpUtil
:relfileprefix: ../../
:mrdocs:

This `struct` provides a namespace for a suite of utility functions for creating and manipulating a hash table&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;hashtableimputil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct HashTableImpUtil;
----

== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslalg/HashTableImpUtil/bucketContainsLink.adoc[`bucketContainsLink`] 
| Return `true` if the specified `linkAddress` is the address of one of the links in the list of elements in the closed range `&lsqb;bucket&period;first(), bucket&period;last()&rsqb;`&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/computeBucketIndex.adoc[`computeBucketIndex`] 
| Return the index of the bucket referring to the elements whose adjusted hash codes are the same as the adjusted value of the specified `hashCode`, where `hashCode` (and the hash&hyphen;codes of the elements) are adjusted for the specified `numBuckets`&period; The behavior is undefined if `numBuckets` is 0&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/extractKey.adoc[`extractKey`] 
| Return a reference providing non&hyphen;modifiable access to the key (of type `KEY&lowbar;CONFIG&colon;&colon;KeyType`) held by the specified `link`&period; The behavior is undefined unless `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;`&period; `KEY&lowbar;CONFIG` shall be a namespace providing the type names `KeyType` and `ValueType`, as well as a function that can be called as if it had the following signature&colon; &grave; const KeyType&amp; extractKey(const ValueType&amp; obj)&semi; &grave;
| xref:BloombergLP/bslalg/HashTableImpUtil/extractValue.adoc[`extractValue`] 
| Return a reference providing non&hyphen;modifiable access to the value (of type `KEY&lowbar;CONFIG&colon;&colon;ValueType`) held by the specified `link`&period; The behavior is undefined unless `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;`&period; `KEY&lowbar;CONFIG` shall be a namespace providing the type name `ValueType`&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/find.adoc[`find`] 
| Return the address of the first link in the list element of the specified `anchor`, having a value matching (according to the specified `equalityFunctor`) the specified `key` in the bucket that holds elements with the specified `hashCode` if such a link exists, and return 0 otherwise&period; The behavior is undefined unless, for the provided `KEY&lowbar;CONFIG` and some hash function, `HASHER`, `anchor` is well&hyphen;formed (see `isWellFormed`) and `HASHER(key)` returns `hashCode`&period; `KEY&lowbar;CONFIG` shall be a namespace providing the type names `KeyType` and `ValueType`, as well as a function that can be called as if it had the following signature&colon; &grave; const KeyType&amp; extractKey(const ValueType&amp; obj)&semi; &grave; `KEY&lowbar;EQUAL` shall be a functor that can be called as if it had the following signature&colon; &grave; bool operator()(const KEY&lowbar;CONFIG&colon;&colon;KeyType&amp; key1, const KEY&lowbar;CONFIG&colon;&colon;KeyType&amp; key2) &grave;
| xref:BloombergLP/bslalg/HashTableImpUtil/findTransparent.adoc[`findTransparent`] 
| Return the address of the first link in the list element of the specified `anchor` having a value matching (according to the specified transparent `equalityFunctor`) the specified `key` in the bucket that holds elements with the specified `hashCode` if such a link exists, and return 0 otherwise&period; The behavior is undefined unless, for the provided `KEY&lowbar;CONFIG` and some hash function, `HASHER`, `anchor` is well&hyphen;formed (see `isWellFormed`) and `HASHER(key)` returns `hashCode`&period; `KEY&lowbar;CONFIG` shall be a namespace providing the type names `KeyType` and `ValueType`, as well as a function that can be called as if it had the following signature&colon; &grave; const KeyType&amp; extractKey(const ValueType&amp; obj)&semi; &grave; `KEY&lowbar;EQUAL` shall be a functor that can be called as if it had the following signature&colon; &grave; bool operator()(const LOOKUP&lowbar;KEY&amp; key1, const KEY&lowbar;CONFIG&colon;&colon;KeyType&amp; key2)
| xref:BloombergLP/bslalg/HashTableImpUtil/insertAtBackOfBucket.adoc[`insertAtBackOfBucket`] 
| Insert the specified `link`, having the specified (non&hyphen;adjusted) `hashCode`, into the specified `anchor`, into the bucket with index `computeBucketIndex(hashCode, anchor&hyphen;&gt;bucketArraySize())`, after the last node in the bucket&period; The behavior is undefined unless `anchor` is well&hyphen;formed (see `isWellFormed`) for some combination of `KEY&lowbar;CONFIG` and `HASHER` such that `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;` and `HASHER(extractKey&lt;KEY&lowbar;CONFIG&gt;(link))` returns `hashCode`&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/insertAtFrontOfBucket.adoc[`insertAtFrontOfBucket`] 
| Insert the specified `link`, having the specified (non&hyphen;adjusted) `hashCode`, into the specified `anchor`, at the front of the bucket with index `computeBucketIndex(hashCode, anchor&hyphen;&gt;bucketArraySize())`&period; The behavior is undefined unless `anchor` is well&hyphen;formed (see `isWellFormed`) for some combination of `KEY&lowbar;CONFIG` and `HASHER` such that `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;` and `HASHER(extractKey&lt;KEY&lowbar;CONFIG&gt;(link))` returns `hashCode`&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/insertAtPosition.adoc[`insertAtPosition`] 
| Insert the specified `link`, having the specified (non&hyphen;adjusted) `hashCode`, into the specified `anchor` immediately before the specified `position` in the bi&hyphen;directional linked list of `anchor`&period; The behavior is undefined unless position is in the bucket having index `computeBucketIndex(hashCode, anchor&hyphen;&gt;bucketArraySize())` and `anchor` is well&hyphen;formed (see `isWellFormed`) for some combination of `KEY&lowbar;CONFIG` and `HASHER` such that `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;` and `HASHER(extractKey&lt;KEY&lowbar;CONFIG&gt;(link))` returns `hashCode`&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/isWellFormed.adoc[`isWellFormed`] 
| Return `true` if the specified `anchor` is well&hyphen;formed for the specified `hasher`&period; Use the specified `allocator` for temporary memory, or the default allocator if none is specified&period; For a `HashTableAnchor` to be considered well&hyphen;formed for a particular key policy, `KEY&lowbar;CONFIG`, and hash functor, `hasher`, all of the following must be true&colon;
| xref:BloombergLP/bslalg/HashTableImpUtil/rehash.adoc[`rehash`] 
| Populate the specified `newHashTable` with all the elements in the specified `elementList`, using the specified `hasher` to determine the (non&hyphen;adjusted) hash code for each element&period; This operation provides the strong exception guarantee unless the supplied `hasher` throws, in which case it provides no exception safety guarantee&period; The buckets in the array in `newAnchor` and the list root address in `newAnchor` are assumed to be garbage and overwritten&period; The behavior is undefined unless, `newHashTable` holds no elements and has one or more (empty) buckets, and `elementList` is a well&hyphen;formed bi&hyphen;directional list (see `BidirectionalLinkListUtil&colon;&colon;isWellFormed`) whose nodes are each of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;`, the previous address of the first node and the next address of the last node are 0&period;
| xref:BloombergLP/bslalg/HashTableImpUtil/remove.adoc[`remove`] 
| Remove the specified `link`, having the specified (non&hyphen;adjusted) `hashCode`, from the specified `anchor`&period; The behavior is undefined unless `anchor` is well&hyphen;formed (see `isWellFormed`) for some combination of `KEY&lowbar;CONFIG` and `HASHER` such that `link` refers to a node of type `BidirectionalNode&lt;KEY&lowbar;CONFIG&colon;&colon;ValueType&gt;` and `HASHER(extractKey&lt;KEY&lowbar;CONFIG&gt;(link))` returns `hashCode`&period;
|===



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