Simple Application Framework
1
|
Unordered associative container. More...
#include <HashMap.h>
Public Types | |
typedef BaseType::ConstIterator | ConstIterator |
Bidirectional non-mutable HashTable iterator. | |
typedef BaseType::Iterator | Iterator |
Bidirectional mutable HashTable iterator. | |
Public Member Functions | |
HashMap (Size bucketHint=0) | |
Default constructor. | |
HashMap (const MyType &d) | |
Copy constructor. | |
ValType & | At (const KeyType &key) |
Get a reference to the value corresponding to a given key. | |
const ValType & | At (const KeyType &key) const |
Get a reference to the value corresponding to a given key. | |
MyType & | operator= (const MyType &d) |
Assignment operator. | |
ValType & | operator[] (const KeyType &key) |
Operator returning the reference to the value corresponding to a given key. | |
MyType & | Swap (MyType &d) |
Swap the content of two hash maps. | |
Iterator | Update (const KeyType &key, const ValType &val) |
Update the value corresponding to a given key. | |
Protected Types | |
typedef Algo::Struct::HashTable < KeyType, RecType, Algo::Selector::FirstMember < RecType >, HashFuncType, HashPolicyType, CompType > | BaseType |
typedef HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType > | MyType |
typedef Pair< const KeyType, ValType > | RecType |
Unordered associative container.
This class implements an associative container where keys map to values. Internally, the data are stored in an unordered list and a hash table is used to enable fast insert, erase and look-up of values mapped to particular keys. If a hash function is chosen appropriately, all these operations can be performed in amortized constant time.
Iterator category: Bidirectional.
KeyType | Key data type. Each key can appear only once in the map. |
ValType | Data type of the mapped values. |
HashFuncType | Unary hash functor that takes values of KeyType and returns a value of type Saf::Size. |
HashPolicyType | Hash policy object that controls which hashes map to which buckets and when and how to enlarge the bucket count. The policy should never allow zero bucket count. |
CompType | A binary equality predicate on KeyType . Keys that have the same hash must be equal according to this predicate. |
typedef Algo::Struct::HashTable<KeyType,RecType,Algo::Selector::FirstMember<RecType>,HashFuncType,HashPolicyType,CompType> Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::BaseType [protected] |
typedef BaseType::ConstIterator Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::ConstIterator |
Bidirectional non-mutable HashTable iterator.
Reimplemented from Saf::Algo::Struct::HashTable< KeyType, Pair< const KeyType, ValType >, Algo::Selector::FirstMember< Pair< const KeyType, ValType > >, HashFuncType, HashPolicyType, CompType >.
typedef BaseType::Iterator Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::Iterator |
Bidirectional mutable HashTable iterator.
Reimplemented from Saf::Algo::Struct::HashTable< KeyType, Pair< const KeyType, ValType >, Algo::Selector::FirstMember< Pair< const KeyType, ValType > >, HashFuncType, HashPolicyType, CompType >.
typedef HashMap<KeyType,ValType,HashFuncType,HashPolicyType,CompType> Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::MyType [protected] |
typedef Pair<const KeyType,ValType> Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::RecType [protected] |
Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::HashMap | ( | Size | bucketHint = 0 | ) | [inline, explicit] |
Default constructor.
[in] | bucketHint | Minimum initial number of buckets. The actual number of buckets may be higher depending on the hash policy. |
Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::HashMap | ( | const MyType & | d | ) | [inline] |
Copy constructor.
ValType& Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::At | ( | const KeyType & | key | ) | [inline] |
Get a reference to the value corresponding to a given key.
If the key does not exist in the HashMap then an IndexOutOfRangeException is thrown.
const ValType& Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::At | ( | const KeyType & | key | ) | const [inline] |
Get a reference to the value corresponding to a given key.
If the key does not exist in the HashMap then an IndexOutOfRangeException is thrown.
MyType& Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::operator= | ( | const MyType & | d | ) | [inline] |
Assignment operator.
ValType& Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::operator[] | ( | const KeyType & | key | ) | [inline] |
Operator returning the reference to the value corresponding to a given key.
If the key does not exist in the HashMap then it is created and the corresponding value is initialized using a default constructor.
MyType& Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::Swap | ( | MyType & | d | ) | [inline] |
Swap the content of two hash maps.
Properties:
Iterator Saf::Collection::HashMap< KeyType, ValType, HashFuncType, HashPolicyType, CompType >::Update | ( | const KeyType & | key, |
const ValType & | val | ||
) | [inline] |