BloombergLP::bdlc::HashTable

This class is a double-hashed table. The VALUE template parameter is optional. The capacityHint specified at construction time will be used to compute the number of buckets (capacity) in this object. Also, two hash functions may optionally be specified at construction time. Elements can be inserted using the insert method. If the VALUE parameter is not bslmf::Nil, then both key and value must be supplied to the insert method. Otherwise, only the key should be supplied. The find method can be used to lookup elements by a specified key. The optional TRAITS parameter can be used to classify "null" and "removed" values. See the component-level documentation for more details.

Synopsis

Declared in <bdlc_hashtable.h>

template<
    class KEY,
    class VALUE = bslmf::Nil,
    class TRAITS = HashTableDefaultTraits,
    class HASH1 = HashTableDefaultHash1,
    class HASH2 = HashTableDefaultHash2>
class HashTable;

Type Aliases

NameDescription
Handle Data type to handle elements in the double-hashed table. This value is guaranteed to be between 0 and the capacity of the hash table.

Member Functions

NameDescription
HashTable [constructor]Constructors
~HashTable [destructor]Destroy this object.
capacity Return the maximum number of elements that can be stored in this object. Note that this value is computed based on the capacity hint used upon construction.
capacityHint Return the capacity hint that was used to determine the capacity of this object.
find Find an element having the specified key; load a handle to the element into the specified handle. Return true if successful, and false otherwise.
insert insert overloads
key Return the reference to the non-modifiable key of the element identified by the specified handle. The behavior is undefined unless handle is valid.
maxChain Return the maximum chain length encountered by this object.
numCollisions Return the number of collisions encountered by this object.
remove Remove the element identified by the specified handle from this object. The behavior is undefined unless handle is valid. Note that handle will become invalid when this method returns.
size Return the number of elements stored in this object.
totalChain Return the total chain length encountered by this object.
value value overloads
operator BloombergLP::bslmf::NestedTraitDeclaration<HashTable, UsesBslmaAllocator> Declare that this type uses a bslma allocator.