Value‐semantic unordered container of keyed elements.
Synopsis
Declared in <bslstl_hashtable.h>
template<
class KEY_CONFIG,
class HASHER,
class COMPARATOR,
class ALLOCATOR = bsl::allocator<KEY_CONFIG::ValueType>>
class HashTable;
Description
This class template implements a value‐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. The value type and key type of the elements maintained by a HashTable are determined by aliases provided through the (template parameter) type KEY_CONFIG. Elements in a HashTable are stored in "nodes" 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++11 standard under the allocator‐aware container requirements in ([container.requirements.general], C++11 23.2.1). The (template parameter) types HASHER and COMPARATOR shall be copy‐constructible function‐objects. HASHER shall support a function call operator compatible with the following statements: ` HASHER hash; KEY_CONFIG::KeyType key; std::size_t result = hash(key); ` where the definition of the called function meets the requirements of a hash function, as specified in {`bslstl_hash`}. COMPARATOR shall support the a function call operator compatible with the following statements: ` COMPARATOR compare; KEY_CONFIG::KeyType key1, key2; bool result = compare(key1, key2); ` where the definition of the called function defines an equivalence relationship on keys that is both reflexive and transitive. 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.
This class: * supports a complete set of value‐semantic operations
-
except for
bdexserialization * is exception‐neutral (agnostic except for theatmethod) * is alias‐safe * isconstthread‐safe For terminology see {`bsldoc_glossary`}.
Type Aliases
Name |
Description |
This |
|
This |
|
This |
|
Node type stored in the hash table. |
|
This |
|
This |
|
Alias to the |
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this object. |
Assignment operators |
|
Return a copy of the allocator used to construct this hash table. |
|
Return a reference to the bucket at the specified |
|
|
|
Return a reference providing non‐modifiable access to the key‐equality comparison functor used by this hash table. |
|
Return the number of elements in the bucket at |
|
Return the address of the first element in this hash table, or a null pointer value if this hash table is empty. |
|
Emplace a newly constructed value into this hash table. |
|
Emplace a value if no equivalent key is present. |
|
Emplace a value, optionally inserted near |
|
|
|
Return the address of the first node after the key‐equivalent range. |
|
|
|
Return |
|
Return a reference providing non‐modifiable access to the hash functor used by this hash‐table. |
|
|
|
|
|
Insert a value from |
|
Insert or assign a mapped value for |
|
Insert or assign a mapped value for a transparent |
|
Return the current load factor for this table. The load factor is the statistical mean number of elements per bucket. |
|
Return the maximum load factor permitted by this hash table. |
|
Return a theoretical upper bound on the number of buckets. |
|
Return a theoretical upper bound on the number of elements. |
|
Return the number of buckets contained in this hash table. |
|
Re‐organize to have at least |
|
Return the number of elements this hash table can hold without requiring a rehash operation in order to respect the |
|
Remove |
|
Remove all elements from this hash table. |
|
Reserve capacity for at least |
|
Set the maximum load factor permitted by this hash table. |
|
Return the number of elements in this hash table. |
|
Exchange this object's value and policies with those of |
|
|
Non-Member Functions
Name |
Description |
Return |
|
Return |
|
Exchange the value and policies of |
Created with MrDocs