#include <Hash.hpp>
Public Member Functions | |
Hash (int32_t _count=0) | |
~Hash () | |
void | clear () |
int64_t | getId (const std::string &_key) const |
bool | exist (const std::string &_name) const |
MY_TYPE & | get (const std::string &_key) const |
MY_TYPE & | operator[] (const std::string &_key) |
const MY_TYPE & | operator[] (const std::string &_key) const |
void | add (const std::string &_key, const MY_TYPE &_value) |
void | set (const std::string &_key, const MY_TYPE &_value) |
void | remove (const std::string &_key) |
int32_t | size () const |
MY_TYPE & | operator[] (size_t _pos) |
const MY_TYPE & | operator[] (size_t _pos) const |
const std::string & | getKey (size_t _pos) const |
std::vector< std::string > | getKeys () const |
const MY_TYPE & | getValue (size_t _pos) const |
MY_TYPE & | getValue (size_t _pos) |
Detailed Description
template<class MY_TYPE>
class etk::Hash< MY_TYPE >
Hash table tamplate is a simple classical hash interface. A hash table is a equivalent of the dictionary in python, this is a simple interfaace between a name and a value:
- "name" : 19
- "name 2" : 99
- Note
- The name is unique and the value is what you want
- Todo:
- check if something ele exist in the STD. (not the std::map and the std::unordered_map
- Note
- The index are all time availlable since they are created. The order is the the one created
A simple example of use:
Constructor & Destructor Documentation
§ Hash()
Contructor of the Hach table.
- Parameters
-
[in] _count Number ob basic elent in the vector.
§ ~Hash()
Destructor of the Hash table(clear all element in the table)
Member Function Documentation
§ add()
|
inline |
Add an element OR set an element value.
- Note
- add and set is the same function.
- Parameters
-
[in] _key Name of the value to set in the hash table. [in] _value Value to set in the hash table.
§ clear()
|
inline |
Remove all entry in the Hash table.
- Note
- It does not delete pointer if your value is a pointer type...
§ exist()
|
inline |
Check if an element exist or not.
- Parameters
-
[in] _name Name of the hash requested
- Returns
- true if the element exist
§ get()
|
inline |
Get a current element in the hash table, with his name.
- Parameters
-
[in] _key Name of the hash requested
- Returns
- Reference on the Element
§ getId()
|
inline |
Get a current element ID in the Hash table.
- Parameters
-
[in] _key Name of the hash requested
- Returns
- Id of the element in the table or -1 of it does not existed
§ getKey()
|
inline |
Get the name of the element at a specific position.
- Parameters
-
[in] _pos Position of the element in the hash table.
- Returns
- name of the element (key).
§ getKeys()
|
inline |
Get all the element name (keys).
- Returns
- a vector of all name (key).
§ getValue() [1/2]
|
inline |
Get a value of the hash table at a specific position.
- Parameters
-
[in] _pos of the element in the hash table.
- Returns
- Value availlable at this position.
§ getValue() [2/2]
|
inline |
Get a value of the hash table at a specific position. (size_t)
- Parameters
-
[in] _pos of the element in the hash table.
- Returns
- Value availlable at this position. (size_t)
§ operator[]() [1/4]
|
inline |
Get an copy Element an a special position.
- Parameters
-
[in] _key Name of the hash requested
- Returns
- An reference on the copy of selected element
§ operator[]() [2/4]
|
inline |
Get an copy Element an a special position.
- Parameters
-
[in] _key Name of the hash requested
- Returns
- An reference on the copy of selected element
§ operator[]() [3/4]
|
inline |
get an element with his id.
- Parameters
-
[in] _pos Position on the element in the hash table.
- Returns
- requested element at this position.
- Note
- this is a dangerous use of the hash table. Maybe you will use a simple vector.
§ operator[]() [4/4]
|
inline |
get an element with his id.
- Parameters
-
[in] _pos Position on the element in the hash table.
- Returns
- requested element at this position.
- Note
- this is a dangerous use of the hash table. Maybe you will use a simple vector.
§ remove()
|
inline |
Remove an element in the hash table.
- Parameters
-
[in] _key Name of the element to remove.
§ set()
|
inline |
Set an element value.
- Note
- add and set is the same function.
- Parameters
-
[in] _key Name of the value to set in the hash table. [in] _value Value to set in the hash table.
§ size()
|
inline |
Get the number of element in the hash table.
- Returns
- number of elements
The documentation for this class was generated from the following file:
- framework/atria-soft/etk/etk/Hash.hpp