#include <bdlc_hashtable.h>
List of all members.
Detailed Description
template<class KEY, class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
class bdlc::HashTable< KEY, VALUE, TRAITS, HASH1, HASH2 >
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.
See Component bdlc_hashtable
Member Typedef Documentation
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Constructor & Destructor Documentation
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Create a double-hash table using the specified capacityHint
. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The behavior is undefined unless 0 != capacityHint
. Note that capacityHint
can be either a positive integer or a negative integer. If capacityHint
is positive, then the capacity of the hash table will be the first available prime number larger than, or equal to, capacityHint
. Otherwise, the capacity of the hash table will be the first available prime number smaller than, or equal to, capacityHint
. Also note that HASH1
will be used as the first hash function, and HASH2
will be used as the second hash function.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Create a double-hash table with the specified capacityHint
. Use the specified hashFunctor1
as the first hash function; use the specified hashFunctor2
as the second hash function. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The behavior is undefined unless 0 != capacityHint
, and hashFunction1
and hashFunction2
are valid. Note that capacityHint
can be either a positive integer or a negative integer. If capacityHint
is positive, then the capacity of the hash table will be the first available prime number larger than, or equal to, capacityHint
. Otherwise, the capacity of the hash table will be the first available prime number smaller than, or equal to, capacityHint
.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Member Function Documentation
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Insert an element with the specified key
into this object; load a handle to the new element into the specified handle
. Return true if successful, and false otherwise. The behavior is undefined unless key
does not evaluate to a "null" or "removed" bucket, as defined by the parameterized TRAITS
(see the component-level documentation for more details). Note that this method will fail to compile unless the VALUE
parameter is bslmf::Nil
.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
bool bdlc::HashTable< KEY, VALUE, TRAITS, HASH1, HASH2 >::insert |
( |
Handle * |
handle, |
|
|
const KEY & |
key, |
|
|
const VALUE & |
value | |
|
) |
| | |
Insert an element with the specified key
and the specified value
into this object; load a handle to the new element into the specified handle
. Return true if successful, and false otherwise. The behavior is undefined unless key
and value
do not evaluate to a "null" or "removed" bucket, as defined by the parameterized TRAITS
(see the component-level documentation for more details). This method will fail to compile unless the VALUE
parameter is not bslmf::Nil
.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
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.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the reference to the modifiable value of the element identified by the specified handle
. The behavior is undefined unless handle
is valid. Note that this method will fail to compile unless the VALUE
parameter is not bslmf::Nil
.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
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.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the capacity hint that was used to determine the capacity of this object.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
bool bdlc::HashTable< KEY, VALUE, TRAITS, HASH1, HASH2 >::find |
( |
Handle * |
handle, |
|
|
const KEY & |
key | |
|
) |
| | const |
Find an element having the specified key
; load a handle to the element into the specified handle
. Return true if successful, and false otherwise.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the reference to the non-modifiable key of the element identified by the specified handle
. The behavior is undefined unless handle
is valid.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the maximum chain length encountered by this object.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the number of collisions encountered by this object.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the number of elements stored in this object.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the total chain length encountered by this object.
template<class KEY , class VALUE = bslmf::Nil, class TRAITS = HashTableDefaultTraits, class HASH1 = HashTableDefaultHash1, class HASH2 = HashTableDefaultHash2>
Return the reference to the non-modifiable value of the element identified by the specified handle
. The behavior is undefined unless handle
is valid. Note that this method will fail to compile unless the VALUE
parameter is not bslmf::Nil
.
The documentation for this class was generated from the following file: