[#BloombergLP-bslstl-HashTable-06]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::HashTable
:relfileprefix: ../../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an unordered sequence of (possibly duplicate) elements, that can be rapidly accessed using their key, with the constraint on the container that elements whose keys compare equal according to the specified `COMPARATOR` will be stored in a stable, contiguous sequence within the container&period; The value type and key type of the elements maintained by a `HashTable` are determined by aliases provided through the (template parameter) type `KEY&lowbar;CONFIG`&period; Elements in a `HashTable` are stored in &quot;nodes&quot; that are allocated using an allocator of the specified `ALLOCATOR` type (rebound to the node type), and elements are constructed directly in the node using the allocator as described in the C&plus;&plus;11 standard under the allocator&hyphen;aware container requirements in (&lsqb;container&period;requirements&period;general&rsqb;, C&plus;&plus;11 23&period;2&period;1)&period; The (template parameter) types `HASHER` and `COMPARATOR` shall be `copy&hyphen;constructible` function&hyphen;objects&period; `HASHER` shall support a function call operator compatible with the following statements&colon; &grave; HASHER hash&semi; KEY&lowbar;CONFIG&colon;&colon;KeyType key&semi; std&colon;&colon;size&lowbar;t result &equals; hash(key)&semi; &grave; where the definition of the called function meets the requirements of a hash function, as specified in &lcub;`bslstl&lowbar;hash`&rcub;&period; `COMPARATOR` shall support the a function call operator compatible with the following statements&colon; &grave; COMPARATOR compare&semi; KEY&lowbar;CONFIG&colon;&colon;KeyType key1, key2&semi; bool result &equals; compare(key1, key2)&semi; &grave; where the definition of the called function defines an equivalence relationship on keys that is both reflexive and transitive&period; The `HASHER` and `COMPARATOR` attributes of this class are further constrained, such for any two objects whose keys compare equal by the comparator, shall produce the same value from the hasher&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY&lowbar;CONFIG,
    class HASHER,
    class COMPARATOR,
    class ALLOCATOR = xref:bsl/allocator-0df.adoc[bsl::allocator&lt;KEY&lowbar;CONFIG::ValueType&gt;]&gt;
class HashTable;
----

== 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:BloombergLP/bslstl/HashTable-06/AllocatorTraits.adoc[`AllocatorTraits`] 
| This `typedef` is an alias to `bsl&colon;&colon;allocator&lowbar;traits&lt;AllocatorType&gt;`&period;
| xref:BloombergLP/bslstl/HashTable-06/AllocatorType.adoc[`AllocatorType`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:BloombergLP/bslstl/HashTable-06/KeyType.adoc[`KeyType`] 
| This `typedef` is an alias to `KEY&lowbar;CONFIG&colon;&colon;KeyType`&period;
| xref:BloombergLP/bslstl/HashTable-06/NodeType.adoc[`NodeType`] 
| Node type stored in the hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/NonConstKeyType.adoc[`NonConstKeyType`] 
| This `typedef` is an alias to the non&hyphen;`const` form of `KeyType`&period;
| xref:BloombergLP/bslstl/HashTable-06/SizeType.adoc[`SizeType`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;size&lowbar;type`&period;
| xref:BloombergLP/bslstl/HashTable-06/ValueType.adoc[`ValueType`] 
| Alias to the `ValueType` defined in the (template parameter) `KEY&lowbar;CONFIG`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/HashTable-06/2constructor-03.adoc[`HashTable`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslstl/HashTable-06/2destructor.adoc[`&#126;HashTable`] [.small]#[destructor]#
| Destroy this object&period;
| xref:BloombergLP/bslstl/HashTable-06/operator_assign-02.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bslstl/HashTable-06/allocator.adoc[`allocator`] 
| Return a copy of the allocator used to construct this hash table&period; Note that this is not the allocator used to allocate elements for this hash table, which is instead a copy of that allocator rebound to allocate the nodes used by the internal data structure of this hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/bucketAtIndex.adoc[`bucketAtIndex`] 
| Return a reference offering non&hyphen;modifiable access to the `HashTableBucket` at the specified `index` position in the array of buckets of this table&period; The behavior is undefined unless &apos;index &lt; numBuckets()&apos;&period;
| xref:BloombergLP/bslstl/HashTable-06/bucketIndexForKey-0b.adoc[`bucketIndexForKey`] 
| `bucketIndexForKey` overloads
| xref:BloombergLP/bslstl/HashTable-06/comparator.adoc[`comparator`] 
| Return a reference providing non&hyphen;modifiable access to the key&hyphen;equality comparison functor used by this hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/countElementsInBucket.adoc[`countElementsInBucket`] 
| Return the number elements contained in the bucket at the specified `index`&period; Note that this operation has linear run&hyphen;time complexity with respect to the number of elements in the indexed bucket&period;
| xref:BloombergLP/bslstl/HashTable-06/elementListRoot.adoc[`elementListRoot`] 
| Return the address of the first element in this hash table, or a null pointer value if this hash table is empty&period;
| xref:BloombergLP/bslstl/HashTable-06/emplace.adoc[`emplace`] 
| Insert into this hash&hyphen;table a newly&hyphen;created `ValueType` object, constructed by forwarding the specified (variable number of) `arguments` to the corresponding constructor of `ValueType`, and return the address of the newly inserted node&period; If a key equivalent to that of the newly&hyphen;created object already exists in this hash&hyphen;table, then insert the newly&hyphen;created object immediately before the first such element&period; Additional buckets are allocated, as needed, to preserve the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash&hyphen;table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This method requires that the `ValueType` defined in the (template parameter) type `KEY&lowbar;CONFIG` be `emplace&hyphen;constructible` into this hash&hyphen;table from `arguments` (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&semi;
| xref:BloombergLP/bslstl/HashTable-06/emplaceIfMissing.adoc[`emplaceIfMissing`] 
| Insert into this hash&hyphen;table a newly&hyphen;created `ValueType` object, constructed by forwarding the specified (variable number of) `arguments` to the corresponding constructor of `ValueType`, if a key equivalent to that of the newly&hyphen;created object does not already exist in this hash&hyphen;table&period; Return the address of the (possibly newly created and inserted) element in this hash table whose key is equivalent to that of an object created from `arguments`&period; Load `true` into the specified `isInsertedFlag` if a new value was inserted, and `false` if an equivalent key was already present&period; If this hash&hyphen;table contains more than one element with an equivalent key, return the first such element (from the contiguous sequence of elements having a matching key)&period; Additional buckets are allocated, as needed, to preserve the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash&hyphen;table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This method requires that the `ValueType` defined in the (template parameter) type `KEY&lowbar;CONFIG` be `emplace&hyphen;constructible` into this hash&hyphen;table from `arguments` (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&semi;
| xref:BloombergLP/bslstl/HashTable-06/emplaceWithHint.adoc[`emplaceWithHint`] 
| Insert into this hash&hyphen;table a newly&hyphen;created `ValueType` object, constructed by forwarding the specified (variable number of) `arguments` to the corresponding constructor of `ValueType` (immediately preceding the specified `hint` if `hint` is not null and the key of the node pointed to by `hint` is equivalent to that of the newly&hyphen;created object), and return the address of the newly inserted node&period; If `hint` is null or the key of the node pointed to by `hint` is not equivalent to that of the newly created object, and a key equivalent to that of the newly&hyphen;created object already exists in this hash&hyphen;table, then insert the newly&hyphen;created object immediately before the first such element&period; Additional buckets will be allocated, as needed, to preserve the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This method requires that `ValueType` defined in the (template parameter) type `KEY&lowbar;CONFIG` be `emplace&hyphen;constructible` into this hash&hyphen;table from `arguments` (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&period; The behavior is undefined unless `hint` is either null or points to a node in this hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/find-0e.adoc[`find`] 
| `find` overloads
| xref:BloombergLP/bslstl/HashTable-06/findEndOfRange.adoc[`findEndOfRange`] 
| Return the address of the first node after any nodes holding a value having the same key as the specified `first` node (according to this hash&hyphen;table&apos;s `comparator`), and a null pointer value if all nodes following `first` hold values with the same key as `first`&period; The behavior is undefined unless `first` is a link in this hash&hyphen;table&period; Note that this hash&hyphen;table ensures all elements having the same key form a contiguous sequence&period;
| xref:BloombergLP/bslstl/HashTable-06/findRange-09.adoc[`findRange`] 
| `findRange` overloads
| xref:BloombergLP/bslstl/HashTable-06/hasSameValue.adoc[`hasSameValue`] 
| Return `true` if the specified `other` has the same value as this object, and `false` otherwise&period; Two `HashTable` objects have the same value if they have the same number of elements, and for every subset of elements in this object having keys that compare equal (according to that hash table&apos;s `comparator`), a corresponding subset of elements exists in the `other` object, having the same number of elements, where, for some permutation of the subset in this object, every element in that subset compares equal (using `operator&equals;&equals;`) to the corresponding element in the `other` subset&period; The behavior is undefined unless both the `hasher` and `comparator` of this object and the `other` return the same value for every valid input&period; Note that this method requires that the `ValueType` of the parameterized `KEY&lowbar;CONFIG` be &quot;equality&hyphen;comparable&quot; (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&period;
| xref:BloombergLP/bslstl/HashTable-06/hasher.adoc[`hasher`] 
| Return a reference providing non&hyphen;modifiable access to the hash functor used by this hash&hyphen;table&period;
| xref:BloombergLP/bslstl/HashTable-06/insert-08.adoc[`insert`] 
| `insert` overloads
| xref:BloombergLP/bslstl/HashTable-06/insertIfMissing-00d.adoc[`insertIfMissing`] 
| `insertIfMissing` overloads
| xref:BloombergLP/bslstl/HashTable-06/insertIfMissingTransparent.adoc[`insertIfMissingTransparent`] 
| Insert into this hash&hyphen;table a `ValueType` object created from the specified `value` if a key equivalent to that of such an object does not already exist in this hash&hyphen;table&period; Return the address of the (possibly newly inserted) element in this hash&hyphen;table whose key is equivalent to that of the object created from `value`&period; Load `true` into the specified `isInsertedFlag` if a new value was inserted, and `false` if an equivalent key was already present&period; If this hash&hyphen;table contains more than one element with an equivalent key, return the first such element (from the contiguous sequence of elements having a matching key)&period; Additional buckets are allocated, as needed, to preserve the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash&hyphen;table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This method requires that the `ValueType` defined in the (template parameter) type `KEY&lowbar;CONFIG` be `move&hyphen;insertable` into this hash&hyphen;table (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;) and the (template parameter) type `SOURCE&lowbar;TYPE` be implicitly convertible to `ValueType`&period;
| xref:BloombergLP/bslstl/HashTable-06/insertOrAssign.adoc[`insertOrAssign`] 
| If a key equivalent to the specified `key` already exists in this hash&hyphen;table, assign the specified `obj` to the value associated with that key, load `false` into the specified `isInsertedFlag` and return a pointer to the existing entry&period; Otherwise, insert into this hash&hyphen;table a newly&hyphen;created `value&lowbar;type` object, constructed from `key` and `obj`, load `true` into `isInsertedFlag`, and return a pointer to the newly&hyphen;created entry&period; Use the optionally specified `hint` as a starting place for the search for the existing key&period;
| xref:BloombergLP/bslstl/HashTable-06/insertOrAssignTransparent.adoc[`insertOrAssignTransparent`] 
| If a key equivalent to the specified `key` already exists in this hash&hyphen;table, assign the specified `obj` to the value associated with that key, load `false` into the specified `isInsertedFlag` and return a pointer to the existing entry&period; Otherwise, insert into this hash&hyphen;table a newly&hyphen;created `value&lowbar;type` object, constructed from `key` and `obj`, load `true` into `isInsertedFlag`, and return a pointer to the newly&hyphen;created entry&period; Use the optionally specified `hint` as a starting place for the search for the existing key&period;
| xref:BloombergLP/bslstl/HashTable-06/loadFactor.adoc[`loadFactor`] 
| Return the current load factor for this table&period; The load factor is the statistical mean number of elements per bucket&period;
| xref:BloombergLP/bslstl/HashTable-06/maxLoadFactor.adoc[`maxLoadFactor`] 
| Return the maximum load factor permitted by this hash table object, where the load factor is the statistical mean number of elements per bucket&period; Note that this hash table will enforce the maximum load factor by rehashing into a larger array of buckets on any any insertion operation where a successful insertion would exceed the maximum load factor&period; The maximum load factor may actually be less than the current load factor if the maximum load factor has been reset, but no insert operations have yet occurred&period;
| xref:BloombergLP/bslstl/HashTable-06/maxNumBuckets.adoc[`maxNumBuckets`] 
| Return a theoretical upper bound on the largest number of buckets that this hash&hyphen;table could possibly have&period; Note that there is no guarantee that the hash&hyphen;table can successfully maintain that number of buckets, or even close to that number of buckets without running out of resources&period;
| xref:BloombergLP/bslstl/HashTable-06/maxSize.adoc[`maxSize`] 
| Return a theoretical upper bound on the largest number of elements that this hash&hyphen;table could possibly hold&period; Note that there is no guarantee that the hash&hyphen;table can successfully grow to the returned size, or even close to that size without running out of resources&period;
| xref:BloombergLP/bslstl/HashTable-06/numBuckets.adoc[`numBuckets`] 
| Return the number of buckets contained in this hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/rehashForNumBuckets.adoc[`rehashForNumBuckets`] 
| Re&hyphen;organize this hash&hyphen;table to have at least the specified `newNumBuckets`, preserving the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This operation provides the strong exception guarantee (see &lcub;`bsldoc&lowbar;glossary`&rcub;) unless the `hasher` throws, in which case this operation provides the basic exception guarantee, leaving the hash&hyphen;table in a valid, but otherwise unspecified (and potentially empty), state&period; Note that more buckets than requested may be allocated in order to preserve the bucket allocation strategy of the hash table (but never fewer)&period;
| xref:BloombergLP/bslstl/HashTable-06/rehashThreshold.adoc[`rehashThreshold`] 
| Return the number of elements this hash table can hold without requiring a rehash operation in order to respect the `maxLoadFactor`&period;
| xref:BloombergLP/bslstl/HashTable-06/remove.adoc[`remove`] 
| Remove the specified `node` from this hash&hyphen;table, and return the address of the node immediately after `node` in this hash&hyphen;table (prior to its removal), or a null pointer value if `node` is the last node in the table&period; This method invalidates only iterators and references to the removed node and previously saved values of the `end()` iterator, and preserves the relative order of the nodes not removed&period; The behavior is undefined unless `node` refers to a node in this hash&hyphen;table&period;
| xref:BloombergLP/bslstl/HashTable-06/removeAll.adoc[`removeAll`] 
| Remove all the elements from this hash&hyphen;table&period; Note that this hash&hyphen;table is empty after this call, but allocated memory may be retained for future use&period; The destructor of each (non&hyphen;trivial) element that is remove shall be run&period;
| xref:BloombergLP/bslstl/HashTable-06/reserveForNumElements.adoc[`reserveForNumElements`] 
| Re&hyphen;organize this hash&hyphen;table to have a sufficient number of buckets to accommodate at least the specified `numElements` without exceeding the `maxLoadFactor`, and ensure that there are sufficient nodes pre&hyphen;allocated in this object&apos;s node pool&period; If this function tries to allocate a number of buckets larger than can be represented by this hash table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This operation provides the strong exception guarantee (see &lcub;`bsldoc&lowbar;glossary`&rcub;) unless the `hasher` throws, in which case this operation provides the basic exception guarantee, leaving the hash&hyphen;table in a valid, but otherwise unspecified (and potentially empty), state&period;
| xref:BloombergLP/bslstl/HashTable-06/setMaxLoadFactor.adoc[`setMaxLoadFactor`] 
| Set the maximum load factor permitted by this hash table to the specified `newMaxLoadFactor`, where load factor is the statistical mean number of elements per bucket&period; If &apos;newMaxLoadFactor &lt; loadFactor&apos;, allocate at least enough buckets to re&hyphen;establish the invariant `loadFactor &lt;&equals; maxLoadFactor`&period; If this function tries to allocate a number of buckets larger than can be represented by this hash table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; The behavior is undefined unless `0 &lt; maxLoadFactor`&period;
| xref:BloombergLP/bslstl/HashTable-06/size.adoc[`size`] 
| Return the number of elements in this hash table&period;
| xref:BloombergLP/bslstl/HashTable-06/swap.adoc[`swap`] 
| Exchange the value of this object, its `comparator` functor, its `hasher` functor, and its `maxLoadFactor` with those of the specified `other` object&period; Additionally, if `bslstl&colon;&colon;AllocatorTraits&lt;ALLOCATOR&gt;&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;swap` is `true`, then exchange the allocator of this object with that of the `other` object, and do not modify either allocator otherwise&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee unless any of the `comparator` or `hasher` functors throw when swapped, leaving both objects in a safely destructible, but otherwise unusable, state&period; The operation guarantees `O&lsqb;1&rsqb;` complexity&period; The behavior is undefined unless either this object has an allocator that compares equal to the allocator of `other`, or the trait `bslstl&colon;&colon;AllocatorTraits&lt;ALLOCATOR&gt;&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;swap` is `true`&period;
| xref:BloombergLP/bslstl/HashTable-06/tryEmplace-02.adoc[`tryEmplace`] 
| `tryEmplace` overloads
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/HashTable-09.adoc[`HashTable&lt;UnorderedMapKeyConfiguration&lt;basic&lowbar;string&lt;char&gt; const, pair&lt;basic&lowbar;string&lt;char&gt; const, Json&gt;&gt;, TransparentHash, TransparentEqualTo, allocator&lt;pair&lt;basic&lowbar;string&lt;char&gt; const, Json&gt;&gt;&gt;`] 
| This class template implements a value&hyphen;semantic container type holding an unordered sequence of (possibly duplicate) elements, that can be rapidly accessed using their key, with the constraint on the container that elements whose keys compare equal according to the specified `COMPARATOR` will be stored in a stable, contiguous sequence within the container&period; The value type and key type of the elements maintained by a `HashTable` are determined by aliases provided through the (template parameter) type `KEY&lowbar;CONFIG`&period; Elements in a `HashTable` are stored in &quot;nodes&quot; that are allocated using an allocator of the specified `ALLOCATOR` type (rebound to the node type), and elements are constructed directly in the node using the allocator as described in the C&plus;&plus;11 standard under the allocator&hyphen;aware container requirements in (&lsqb;container&period;requirements&period;general&rsqb;, C&plus;&plus;11 23&period;2&period;1)&period; The (template parameter) types `HASHER` and `COMPARATOR` shall be `copy&hyphen;constructible` function&hyphen;objects&period; `HASHER` shall support a function call operator compatible with the following statements&colon; &grave; HASHER hash&semi; KEY&lowbar;CONFIG&colon;&colon;KeyType key&semi; std&colon;&colon;size&lowbar;t result &equals; hash(key)&semi; &grave; where the definition of the called function meets the requirements of a hash function, as specified in &lcub;`bslstl&lowbar;hash`&rcub;&period; `COMPARATOR` shall support the a function call operator compatible with the following statements&colon; &grave; COMPARATOR compare&semi; KEY&lowbar;CONFIG&colon;&colon;KeyType key1, key2&semi; bool result &equals; compare(key1, key2)&semi; &grave; where the definition of the called function defines an equivalence relationship on keys that is both reflexive and transitive&period; The `HASHER` and `COMPARATOR` attributes of this class are further constrained, such for any two objects whose keys compare equal by the comparator, shall produce the same value from the hasher&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/operator_not_eq-065.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; Two `HashTable` objects do not have the same value if they do not have the same number of elements, or if, for any key found in `lhs`, the subset of elements having that key (according to the hash&hyphen;table&apos;s `comparator`) in `lhs` either (1) does not have the same number of elements as the subset of elements having that key in `rhs`, or (2) there exists no permutation of the `lhs` subset where each element compares equal (using `operator&equals;&equals;`) to the corresponding element in the `rhs` subset&period; The behavior is undefined unless both the `hasher` and `comparator` of `lhs` and `rhs` return the same value for every valid input&period; Note that this method requires that the `ValueType` of the parameterized `KEY&lowbar;CONFIG` be &quot;equality&hyphen;comparable&quot; (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&period;
| xref:BloombergLP/bslstl/operator_eq-0f.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `HashTable` objects have the same value if they have the same number of elements, and for every subset of elements in `lhs` having keys that compare equal (according to that hash table&apos;s `comparator`), a corresponding subset of elements exists in `rhs`, having the same number of elements, where, for some permutation of the `lhs` subset, every element in that subset compares equal (using `operator&equals;&equals;`) to the corresponding element in the `rhs` subset&period; The behavior is undefined unless both the `hasher` and `comparator` of `lhs` and `rhs` return the same value for every valid input&period; Note that this method requires that the `ValueType` of the parameterized `KEY&lowbar;CONFIG` be &quot;equality&hyphen;comparable&quot; (see &lcub;Requirements on `KEY&lowbar;CONFIG`&rcub;)&period;
| xref:BloombergLP/bslstl/swap-0e8.adoc[`swap`]
| Swap both the value, the hasher, the comparator, and the `maxLoadFactor` of the specified `x` object with the value, the hasher, the comparator, and the `maxLoadFactor` of the specified `y` object&period; Additionally, if `bslstl&colon;&colon;AllocatorTraits&lt;ALLOCATOR&gt;&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;swap` is `true`, then exchange the allocator of `x` with that of `y`, and do not modify either allocator otherwise&period; This method guarantees `O&lsqb;1&rsqb;` complexity if `x` and `y` have the same allocator or if the allocators propagate on swap, otherwise this operation will typically pay the cost of two copy constructors, which may in turn throw&period; If the allocators are the same or propagate, then this method provides the no&hyphen;throw exception&hyphen;safety guarantee unless the `swap` function of the hasher or comparator throw&period; Otherwise this method offers only the basic exception safety guarantee&period;
|===


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