55 #include <forward_list>
62 using std::forward_list;
102 virtual const char*
what()
const throw(){
113 template <
typename K,
typename V>
200 string desc =
"{" +
_key +
", " +
_value +
"}";
204 return desc +
", " +
_next->toString();
211 template <
typename K,
typename V>
243 while(not here and
END != browser){
244 if(key == browser->
getKey()){
263 while(undone and
END != browser){
264 if(key == browser->
getKey()){
304 while(undone and
END != browser){
305 if(key == browser->
getKey()){
322 void remove(
const K &key){
331 while(undone and
END != cur){
365 void getPairs(forward_list<pair<string, int>> &pairs){
372 while(
END != browser){
373 pairs.push_front(pair<string, int>(browser->
getKey(), browser->
getValue()));
381 #endif // HASHTABLE_HPP
virtual const char * what() const
Definition: hashtable.hpp:102
Maps a key to a value.
Definition: hashtable.hpp:212
virtual ~HashtableException()
Definition: hashtable.hpp:95
string toString()
Definition: hashtable.hpp:352
string toString()
Definition: hashtable.hpp:199
~Alveole()
Definition: hashtable.hpp:165
Alveole(K key, V value)
Definition: hashtable.hpp:142
~Hashtable()
Definition: hashtable.hpp:229
Alveole()
Definition: hashtable.hpp:150
bool contains(const K &key)
Definition: hashtable.hpp:237
Class to define Hashtable alveoles.
Definition: hashtable.hpp:114
const char * _cause
Definition: hashtable.hpp:82
Alveole< K, V > * getNext()
Definition: hashtable.hpp:184
Alveole(K key, V value, Alveole< K, V > *next)
Definition: hashtable.hpp:157
K _key
Definition: hashtable.hpp:116
void getPairs(forward_list< pair< string, int >> &pairs)
Definition: hashtable.hpp:365
K getKey()
Definition: hashtable.hpp:174
Exception class to manage Hashtable errors.
Definition: hashtable.hpp:80
#define K
Definition: sample_hashtable.cpp:40
#define V
Definition: sample_hashtable.cpp:41
V _value
Definition: hashtable.hpp:117
#define END
macro to define end of alveole chains
Definition: hashtable.hpp:43
void setNext(Alveole< K, V > *n_next)
Definition: hashtable.hpp:194
#define ARRAYSIZE
macro to define size of hash arrays
Definition: hashtable.hpp:48
Alveole< K, V > ** _table
Definition: hashtable.hpp:215
unsigned computehash(K element)
HashtableException(const char *cause)
Definition: hashtable.hpp:88
void put(K key, V value)
Definition: hashtable.hpp:296
Hashtable()
Definition: hashtable.hpp:220
unsigned computehash< K >(K element)
Definition: sample_hashtable.cpp:46
Alveole< K, V > * _next
Definition: hashtable.hpp:118
void setValue(V n_value)
Definition: hashtable.hpp:189
bool isEmpty()
Definition: hashtable.hpp:281
Alveole(const Alveole< K, V > &other)
Definition: hashtable.hpp:125
V getValue()
Definition: hashtable.hpp:179