lab_hash
Hellish Hash Tables
 All Classes Namespaces Files Functions Variables Pages
HashTable< K, V >::iterator Class Reference

Iterator for iterating over a hashtable. More...

#include <htiterator.h>

Inheritance diagram for HashTable< K, V >::iterator:
[legend]
Collaboration diagram for HashTable< K, V >::iterator:
[legend]

Public Member Functions

 iterator ()
 Constructs a default iterator. More...
 
 iterator (const iterator &other)
 Copy constructor for an iterator. More...
 
const iteratoroperator= (const iterator &rhs)
 iterator assignment operator. More...
 
 ~iterator ()
 Destructor. More...
 
iteratoroperator++ ()
 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 >
 

Detailed Description

template<class K, class V>
class HashTable< K, V >::iterator

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;
Author
Chase Geigle
Date
Summer 2012

Constructor & Destructor Documentation

template<class K , class V >
HashTable< K, V >::iterator::iterator ( )

Constructs a default iterator.

template<class K , class V >
HashTable< K, V >::iterator::iterator ( const iterator other)

Copy constructor for an iterator.

Parameters
otherThe iterator to be copied.
template<class K , class V >
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.

Member Function Documentation

template<class K , class V >
bool HashTable< K, V >::iterator::operator!= ( const iterator rhs) const

Compares whether two iterators are unequal.

Parameters
rhsThe iterator to compare with.
Returns
Whether the two iterators are unequal.
template<class K , class V >
const pair< K, V > & HashTable< K, V >::iterator::operator* ( )

Dereference operator.

template<class K , class V >
HashTable< K, V >::iterator & HashTable< K, V >::iterator::operator++ ( )

Pre-increment operator.

template<class K , class V >
HashTable< K, V >::iterator HashTable< K, V >::iterator::operator++ ( int  )

Post-increment operator.

template<class K , class V >
const pair< K, V > * HashTable< K, V >::iterator::operator-> ( )

Dereference-access operator.

template<class K , class V >
const HashTable< K, V >::iterator & HashTable< K, V >::iterator::operator= ( const iterator rhs)

iterator assignment operator.

Parameters
rhsThe iterator to assign into the current iterator.
Returns
A reference to the current iterator for chaining.
template<class K , class V >
bool HashTable< K, V >::iterator::operator== ( const iterator rhs) const

Compares whether two iterators are equal.

Parameters
rhsThe iterator to compare with.
Returns
Whether the current iterator is equal to the rhs.

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