lab_hash
Hellish Hash Tables
|
Iterator for iterating over a hashtable. More...
#include "htiterator.h"
Public Member Functions | |
iterator () | |
Constructs a default iterator. More... | |
iterator (const iterator &other) | |
Copy constructor for an iterator. More... | |
const iterator & | operator= (const iterator &rhs) |
iterator assignment operator. More... | |
~iterator () | |
Destructor. More... | |
iterator & | operator++ () |
Pre-increment operator. More... | |
iterator | operator++ (int) |
Post-increment operator. More... | |
bool | operator== (const iterator &rhs) const |
Compares whether two iterators are equal. More... | |
bool | operator!= (const iterator &rhs) const |
Compares whether two iterators are unequal. More... | |
const std::pair< K, V > & | operator* () |
Dereference operator. More... | |
const std::pair< K, V > * | operator-> () |
Dereference-access operator. More... | |
Friends | |
class | HashTable< K, V > |
Iterator for iterating over a hashtable.
This example will print out all of the key, value pairs in the HashTable variable ht
:
for( HashTable::iterator it = ht.begin(); it != ht.end(); ++it ) cout << "key: " << it->first << " value: " << it->second << endl;
HashTable< K, V >::iterator::iterator | ( | ) |
Constructs a default iterator.
Copy constructor for an iterator.
other | The iterator to be copied. |
HashTable< K, V >::iterator::~iterator | ( | ) |
Destructor.
Required since we are implementing polymorphic iterators and need to free our implementation class upon going out of scope.
const HashTable< K, V >::iterator & HashTable< K, V >::iterator::operator= | ( | const iterator & | rhs | ) |
iterator assignment operator.
rhs | The iterator to assign into the current iterator. |
HashTable< K, V >::iterator & HashTable< K, V >::iterator::operator++ | ( | ) |
Pre-increment operator.
HashTable< K, V >::iterator HashTable< K, V >::iterator::operator++ | ( | int | ) |
Post-increment operator.
bool HashTable< K, V >::iterator::operator== | ( | const iterator & | rhs | ) | const |
Compares whether two iterators are equal.
rhs | The iterator to compare with. |
bool HashTable< K, V >::iterator::operator!= | ( | const iterator & | rhs | ) | const |
Compares whether two iterators are unequal.
rhs | The iterator to compare with. |
Dereference operator.
Dereference-access operator.