|
Ocean
|
This class implements a hash map. More...
#include <HashMap.h>
Public Member Functions | |
| HashMap (const HashMap< TKey, T > &hashMap) | |
| Copy constructor. | |
| HashMap (HashMap< TKey, T > &&hashMap) noexcept | |
| Move constructor. | |
| HashMap (const size_t capacity, const ValueFunction &function=defaultHashFunction) | |
| Creates a new hash map object by a given capacity. | |
| bool | insert (const TKey &key, const T &element, const bool oneOnly=true, const bool extendCapacity=true) |
| Adds a new element to this hash map. | |
| bool | insert (TKey &&key, T &&element, const bool oneOnly=true, const bool extendCapacity=true) |
| Adds (moves) a new element to this hash map. | |
| bool | remove (const TKey &key) |
| Removes an element from this hash map. | |
| bool | find (const TKey &key) const |
| Returns whether this hash map holds a given element. | |
| bool | find (const TKey &key, const T *&element) const |
| Returns whether this hash map holds a given element. | |
| bool | find (const TKey &key, T *&element) |
| Returns whether this hash map holds a given element. | |
| const T & | element (const TKey &key) const |
| Returns a specific element of this map. | |
| void | clear () |
| Removes all elements from this has map. | |
| size_t | size () const |
| Returns the number of elements this hash map currently holds. | |
| size_t | capacity () const |
| Returns the capacity of this hash map. | |
| bool | isEmpty () const |
| Returns whether this hash map is empty. | |
| HashMap< TKey, T > & | operator= (const HashMap< TKey, T > &hashMap) |
| Assign operator. | |
| HashMap< TKey, T > & | operator= (HashMap< TKey, T > &&hashMap) noexcept |
| Move operator. | |
Protected Types | |
| typedef std::pair< std::pair< size_t, size_t >, std::pair< TKey, T > > | Element |
| Definition of a pair combining a counter states and an object. | |
| typedef std::vector< Element > | Elements |
| Definition of a vector holding the map objects. | |
| typedef size_t(* | ValueFunction) (const TKey &key) |
| Definition of a function pointer returning a hash map value. | |
Protected Member Functions | |
| HashMap (size_t capacity, HashMap< TKey, T > &&hashMap) | |
| Creates a new hash map by a given hash map. | |
| bool | isConsistent () const |
| Returns whether this hash map is still consistent. | |
Static Protected Member Functions | |
| static size_t | defaultHashFunction (const TKey &key) |
| Default hash function for elements supporting an cast size_t cast. | |
Protected Attributes | |
| Elements | mapElements |
| Hash map elements. | |
| size_t | mapSize |
| Number of elements this has map holds. | |
| ValueFunction | mapFunction |
| Value function. | |
This class implements a hash map.
| TKey | The data type of the key that is associated with the data element |
| T | The data type of the data elements that are stored in the hash map |
|
protected |
Definition of a pair combining a counter states and an object.
|
protected |
Definition of a vector holding the map objects.
|
protected |
Definition of a function pointer returning a hash map value.
|
inline |
Copy constructor.
| hashMap | The hash map to copy |
|
inlinenoexcept |
Move constructor.
| hashMap | The hash map to move |
|
explicit |
Creates a new hash map object by a given capacity.
| capacity | Maximal capacity the hash map will support |
| function | Hash function to be used |
|
protected |
Creates a new hash map by a given hash map.
| capacity | The capacity of the new has map, with range [hashMap.size(), infinity) |
| hashMap | The hash map which defines the initial values of this hash map, will be moved |
|
inline |
Returns the capacity of this hash map.
| void Ocean::HashMap< TKey, T >::clear | ( | ) |
Removes all elements from this has map.
|
inlinestaticprotected |
Default hash function for elements supporting an cast size_t cast.
| key | Key to return the hash value for |
| const T & Ocean::HashMap< TKey, T >::element | ( | const TKey & | key | ) | const |
Returns a specific element of this map.
Beware: The element must exist!
| key | The key which belongs to the element |
| bool Ocean::HashMap< TKey, T >::find | ( | const TKey & | key | ) | const |
Returns whether this hash map holds a given element.
| key | Key to be found |
| bool Ocean::HashMap< TKey, T >::find | ( | const TKey & | key, |
| const T *& | element | ||
| ) | const |
Returns whether this hash map holds a given element.
| key | Key to be found |
| element | Resulting element corresponding to the requested key |
| bool Ocean::HashMap< TKey, T >::find | ( | const TKey & | key, |
| T *& | element | ||
| ) |
Returns whether this hash map holds a given element.
| key | Key to be found |
| element | Resulting element corresponding to the requested key |
| bool Ocean::HashMap< TKey, T >::insert | ( | const TKey & | key, |
| const T & | element, | ||
| const bool | oneOnly = true, |
||
| const bool | extendCapacity = true |
||
| ) |
Adds a new element to this hash map.
| key | Key to be added |
| element | Element to be added |
| oneOnly | True, to add the element only if it does not exist already |
| extendCapacity | True, to extend the capacity if necessary |
| bool Ocean::HashMap< TKey, T >::insert | ( | TKey && | key, |
| T && | element, | ||
| const bool | oneOnly = true, |
||
| const bool | extendCapacity = true |
||
| ) |
Adds (moves) a new element to this hash map.
| key | Key to be moved |
| element | Element to be moved |
| oneOnly | True, to add the element only if it does not exist already |
| extendCapacity | True, to extend the capacity if necessary |
|
protected |
Returns whether this hash map is still consistent.
|
inline |
Returns whether this hash map is empty.
|
inline |
Assign operator.
| hashMap | The hash map to assign |
|
inlinenoexcept |
Move operator.
| hashMap | The hash map to move |
| bool Ocean::HashMap< TKey, T >::remove | ( | const TKey & | key | ) |
Removes an element from this hash map.
| key | Key to be removed |
|
inline |
Returns the number of elements this hash map currently holds.
|
protected |
Hash map elements.
|
protected |
Value function.
|
protected |
Number of elements this has map holds.