lab_hash
Hellish Hash Tables
HashTable< K, V >::iterator Class Reference

Iterator for iterating over a hashtable. More...

#include "htiterator.h"

+ Inheritance diagram for HashTable< K, V >::iterator:
+ Collaboration diagram for HashTable< K, V >::iterator:

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

◆ iterator() [1/2]

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

Constructs a default iterator.

◆ iterator() [2/2]

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

Copy constructor for an iterator.

Parameters
otherThe iterator to be copied.

◆ ~iterator()

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

◆ 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.

◆ operator++() [1/2]

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

Pre-increment operator.

◆ operator++() [2/2]

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

Post-increment operator.

◆ operator==()

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.

◆ operator!=()

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.

◆ operator*()

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

Dereference operator.

◆ operator->()

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

Dereference-access operator.


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