Glossygloss  0.2
Glossygloss is set of classes to use several data structure as Tree or hash table.
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Private Attributes | List of all members
Hashtable< K, V > Class Template Reference

Maps a key to a value. More...

#include <hashtable.hpp>

Public Member Functions

 Hashtable ()
 
 ~Hashtable ()
 
bool contains (const K &key)
 
V get (const K &key)
 
bool isEmpty ()
 
void put (K key, V value)
 
void remove (const K &key)
 FIXME : remove last element of a list lead to a seg. fault. More...
 
string toString ()
 
void getPairs (forward_list< pair< string, int >> &pairs)
 

Private Attributes

Alveole< K, V > ** _table
 

Detailed Description

template<typename K, typename V>
class Hashtable< K, V >

Maps a key to a value.

Constructor & Destructor Documentation

template<typename K, typename V>
Hashtable< K, V >::Hashtable ( )

array of alveoles Simple constructor

template<typename K, typename V>
Hashtable< K, V >::~Hashtable ( )

Destructor

Member Function Documentation

template<typename K, typename V>
bool Hashtable< K, V >::contains ( const K key)

Do table contains key ?

Parameters
[in]keykey to find
[out]boolTrue if the key is here, else false
template<typename K, typename V>
V Hashtable< K, V >::get ( const K key)

Return the value maped to the specified key

Parameters
[in]keya key in the hashtable
[out]valuevalue associated with the key
Exceptions
HashtableExceptionthrew if key is not in the hashtable
template<typename K, typename V>
void Hashtable< K, V >::getPairs ( forward_list< pair< string, int >> &  pairs)

Get a list of all kay and their value in pairs

Parameters
[in]pairsVector which contains keys to find
template<typename K, typename V>
bool Hashtable< K, V >::isEmpty ( )

Tests if this hashtable maps no keys to values.

Parameters
[out]booltrue if no elements in the hashtable, else false;
template<typename K, typename V>
void Hashtable< K, V >::put ( K  key,
V  value 
)

Map the specified key to the specified value in this hashtable. or update the maped value to the key

Parameters
[in]keykey of the pair
[in]valuevalue of the pair
template<typename K, typename V>
void Hashtable< K, V >::remove ( const K key)

FIXME : remove last element of a list lead to a seg. fault.

Remove the key (and its corresponding value) from this hashtable.

Parameters
[in]keyKey of the pair to delete
Exceptions
HashtableExceptionthrew if table does not contain key
template<typename K, typename V>
string Hashtable< K, V >::toString ( )

Return a description of the hashtable, enclosed in braces as well as {key, value}.

Parameters
[out]desca string representation of this hashtable.

Member Data Documentation

template<typename K, typename V>
Alveole<K,V>** Hashtable< K, V >::_table
private

The documentation for this class was generated from the following file: