[#BloombergLP-bslstl-HashTable-06-2constructor-03] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/HashTable-06.adoc[HashTable]::HashTable :relfileprefix: ../../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_hashtable.h>` Create a hash‐table having the same value (and `maxLoadFactor`) as the specified `original` object. Use a copy of `original.hasher()` and a copy of `original.comparator()` to organize elements in this hash‐table. Use the allocator returned by 'bsl::allocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.allocator())' to allocate memory. This method requires that the `ValueType` defined by the (template parameter) type `KEY_CONFIG` be `copy‐insertable` into this hash‐table (see '{Requirements on `KEY_CONFIG`}). Note that this hash‐table may have fewer buckets than `original`, and a correspondingly higher `loadFactor`, so long as `maxLoadFactor` is not exceeded. Also note that the created hash table may have a different `numBuckets` than `original`, and a correspondingly different `loadFactor`, as long as `maxLoadFactor` is not exceeded. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/HashTable-06/2constructor-00.adoc[HashTable](xref:BloombergLP/bslstl/HashTable-06.adoc[HashTable] const& original); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-00.adoc[_» more..._]# Create a hash‐table having the same value (and `maxLoadFactor`) as the specified `original` object by moving (in constant time) the contents of `original` to the new hash‐table. Use a copy of `original.hasher()` and a copy of `original.comparator()` to organize elements in this hash‐table. The allocator associated with `original` is propagated for use in the newly created hash‐table. `original` is left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/HashTable-06/2constructor-0cf.adoc[HashTable](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<HashTable>] original); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-0cf.adoc[_» more..._]# Create an empty hash‐table. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not supplied, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used to supply memory. Use 1.0 for the `maxLoadFactor`. Use a default constructed object of the (template parameter) type `HASHER` and a default constructed object of the (template parameter) type `COMPARATOR` to organize elements in the table. No memory is allocated unless the `HASHER` or `COMPARATOR` types allocate memory in their default constructor. Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:BloombergLP/bslstl/HashTable-06/2constructor-06.adoc[HashTable](ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-06.adoc[_» more..._]# Create a hash table having the same value (and `maxLoadFactor`) as the specified `original` object that uses the specified `basicAllocator` to supply memory. The contents of `original` are moved (in constant time) to the new hash‐table if `basicAllocator == original.get_allocator()`, and are move‐inserted (in linear time) using `basicAllocator` otherwise. `original` is left in a valid but unspecified state. Use a copy of `original.hasher()` and a copy of `original.comparator()` to organize elements in this hash‐table. This method requires that the `ValueType` defined by the (template parameter) type `KEY_CONFIG` be `move‐insertable` into this hash‐table. Note that this hash‐table may have a different `numBuckets` than `original`, and a correspondingly different `loadFactor`, as long as `maxLoadFactor` is not exceeded. Also note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the (template parameter) `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/HashTable-06/2constructor-0c9b.adoc[HashTable]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<HashTable>] original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-0c9b.adoc[_» more..._]# Create a hash‐table having the same value (and `maxLoadFactor`) as the specified `original` object that uses the specified `basicAllocator` to supply memory. Use a copy of `original.hasher()` and a copy of `original.comparator()` to organize elements in this hash‐table. This method requires that the `ValueType` defined by the (template parameter) type `KEY_CONFIG` be `move‐insertable` into this hash‐table. Note that this hash‐table may have a different `numBuckets` than `original`, and a correspondingly different `loadFactor`, as long as `maxLoadFactor` is not exceeded. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/HashTable-06/2constructor-0c9e.adoc[HashTable]( xref:BloombergLP/bslstl/HashTable-06.adoc[HashTable] const& original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-0c9e.adoc[_» more..._]# Create an empty hash‐table using the specified `hash` and `compare` functors to organize elements in the table, which will initially have at least the specified `initialNumBuckets` and a `maxLoadFactor` of the specified `initialMaxLoadFactor`. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not supplied, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used to supply memory. If this constructor tries to allocate a number of buckets larger than can be represented by this hash‐table's `SizeType`, a `std::length_error` exception is thrown. The behavior is undefined unless `0 < initialMaxLoadFactor`. Note that more than `initialNumBuckets` buckets may be created in order to preserve the bucket allocation strategy of the hash‐table (but never fewer). Also note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bslstl/HashTable-06/2constructor-09.adoc[HashTable]( HASHER const& hash, COMPARATOR const& compare, xref:BloombergLP/bslstl/HashTable-06/SizeType.adoc[SizeType] initialNumBuckets, float initialMaxLoadFactor, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:BloombergLP/bslstl/HashTable-06/2constructor-09.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#