|
cppcore
A small, portable C++ core library
|
This class implements a hash map. More...
#include <THashMap.h>
Public Types | |
| using | Hash = THash<T> |
| The alias. | |
Public Member Functions | |
| THashMap (size_t init=InitSize) | |
| The class constructor. | |
| ~THashMap () | |
| The class destructor. | |
| size_t | size () const |
| Returns the number of stored items in the hash-map. | |
| size_t | capacity () const |
| Will return the number of possible hash items stored in the hash map. | |
| bool | isEmpty () const |
| Will return true, if hash-map is empty. | |
| void | init (size_t init) |
| Will init the hash-map with the given size. | |
| void | clear () |
| The hash-map will be cleared. | |
| void | insert (const T &key, const U &value) |
| A new key value pair will be entered. | |
| bool | remove (const T &key) |
| Will remove a given key-value pair form the hash-map. | |
| bool | hasKey (const T &key) const |
| Looks for a given key and returns true, if a key-value pair is stored in the list. | |
| bool | getValue (const T &key, U &value) const |
| Returns the assigned value for the given key. | |
| U & | operator[] (const T &key) const |
| Returns the assigned value for the given key. | |
| THashMap (const THashMap< T, U > &)=delete | |
| Avoid copying. | |
| THashMap< T, U, TAlloc > & | operator= (const THashMap< T, U > &)=delete |
Static Public Attributes | |
| static constexpr size_t | InitSize = 1024 |
| The initial hash size. | |
| static constexpr unsigned int | UnsetNode = 999999999 |
| Marker for unset node keys. | |
This class implements a hash map.
Utility class for common memory operations.
You can work with the hashmap in the following way:
Definition at line 48 of file THashMap.h.
| using cppcore::THashMap< T, U, TAlloc >::Hash = THash<T> |
The alias.
Definition at line 51 of file THashMap.h.
|
inlineexplicit |
The class constructor.
| init | [in] The initial size for the hash. |
Definition at line 133 of file THashMap.h.
References init().
Referenced by operator=(), and THashMap().
|
inline |
|
delete |
Avoid copying.
References THashMap().
|
inline |
Will return the number of possible hash items stored in the hash map.
Definition at line 148 of file THashMap.h.
|
inline |
|
inline |
Returns the assigned value for the given key.
| [in] | key | The key to look for. |
| [in] | value | The value, unset when no key-value pair was found. |
Definition at line 249 of file THashMap.h.
References cppcore::THash< T >::toHash().
|
inline |
Looks for a given key and returns true, if a key-value pair is stored in the list.
| [in] | key | The key to look for. |
Definition at line 220 of file THashMap.h.
References cppcore::THash< T >::toHash().
|
inline |
Will init the hash-map with the given size.
| [in] | init | The initial size for the hash. |
Definition at line 158 of file THashMap.h.
References init().
Referenced by init(), and THashMap().
|
inline |
A new key value pair will be entered.
| [in] | key | The key. |
| [in] | value | The value to store. |
Definition at line 180 of file THashMap.h.
References cppcore::THash< T >::toHash().
|
inline |
Will return true, if hash-map is empty.
Definition at line 153 of file THashMap.h.
|
delete |
References remove(), THashMap(), and UnsetNode.
|
inline |
Returns the assigned value for the given key.
| [in] | key | The key to look for. |
Definition at line 270 of file THashMap.h.
References cppcore::THash< T >::toHash().
|
inline |
Will remove a given key-value pair form the hash-map.
| [in] | key | The key to look for. |
Definition at line 194 of file THashMap.h.
References cppcore::THash< T >::toHash().
Referenced by operator=().
|
inline |
Returns the number of stored items in the hash-map.
Definition at line 143 of file THashMap.h.
|
staticconstexpr |
The initial hash size.
Definition at line 54 of file THashMap.h.
|
staticconstexpr |