FreeNOS
Public Member Functions | Private Attributes
HashIterator< K, V > Class Template Reference

Iterate through a HashTable. More...

#include <HashIterator.h>

Inheritance diagram for HashIterator< K, V >:
Iterator< V >

Public Member Functions

 HashIterator (HashTable< K, V > &hash)
 Class constructor. More...
 
virtual ~HashIterator ()
 Destructor. More...
 
virtual void reset ()
 Reset the iterator. More...
 
virtual bool hasNext () const
 Check if there is more to iterate. More...
 
virtual bool hasCurrent () const
 Check if there is a current item. More...
 
virtual const V & current () const
 Get the current value (read-only). More...
 
virtual V & current ()
 Get the current value. More...
 
virtual const K & key ()
 Get the current key. More...
 
virtual V & next ()
 Fetch the next item. More...
 
virtual bool remove ()
 Remove the current item from the underlying Container. More...
 
virtual void operator++ (int num)
 Increment operator. More...
 
- Public Member Functions inherited from Iterator< V >
virtual ~Iterator ()
 Destructor. More...
 
virtual bool hasNext () const=0
 Check if there is more to iterate. More...
 
virtual bool hasCurrent () const=0
 Check if there is a current item. More...
 

Private Attributes

HashTable< K, V > & m_hash
 Points to the HashTable to iterate. More...
 
List< K > m_keys
 List of keys to iterate. More...
 
ListIterator< K > m_iter
 Iterator of keys. More...
 

Detailed Description

template<class K, class V>
class HashIterator< K, V >

Iterate through a HashTable.

Definition at line 39 of file HashIterator.h.

Constructor & Destructor Documentation

◆ HashIterator()

template<class K , class V >
HashIterator< K, V >::HashIterator ( HashTable< K, V > &  hash)
inline

Class constructor.

Parameters
hashReference to the HashTable to iterate.

Definition at line 48 of file HashIterator.h.

◆ ~HashIterator()

template<class K , class V >
virtual HashIterator< K, V >::~HashIterator ( )
inlinevirtual

Destructor.

Definition at line 56 of file HashIterator.h.

Member Function Documentation

◆ current() [1/2]

template<class K , class V >
virtual V& HashIterator< K, V >::current ( )
inlinevirtual

Get the current value.

Returns
Reference to the current value.

Implements Iterator< V >.

Definition at line 103 of file HashIterator.h.

References ListIterator< T >::current(), HashIterator< K, V >::m_hash, and HashIterator< K, V >::m_iter.

◆ current() [2/2]

template<class K , class V >
virtual const V& HashIterator< K, V >::current ( ) const
inlinevirtual

Get the current value (read-only).

Returns
Reference to the current read-only value.

Definition at line 93 of file HashIterator.h.

References ListIterator< T >::current(), HashIterator< K, V >::m_hash, and HashIterator< K, V >::m_iter.

◆ hasCurrent()

template<class K , class V >
virtual bool HashIterator< K, V >::hasCurrent ( ) const
inlinevirtual

◆ hasNext()

template<class K , class V >
virtual bool HashIterator< K, V >::hasNext ( ) const
inlinevirtual

Check if there is more to iterate.

Returns
true if more items, false if not.

Definition at line 73 of file HashIterator.h.

References ListIterator< T >::hasNext(), and HashIterator< K, V >::m_iter.

◆ key()

template<class K , class V >
virtual const K& HashIterator< K, V >::key ( )
inlinevirtual

Get the current key.

Returns
Reference to the current key.

Definition at line 113 of file HashIterator.h.

References ListIterator< T >::current(), and HashIterator< K, V >::m_iter.

Referenced by HashIterator< K, V >::remove().

◆ next()

template<class K , class V >
virtual V& HashIterator< K, V >::next ( )
inlinevirtual

Fetch the next item.

This function first fetches the next item and then updates the current item pointer to that item.

Returns
Reference to the next item.

Implements Iterator< V >.

Definition at line 126 of file HashIterator.h.

References HashIterator< K, V >::m_hash, HashIterator< K, V >::m_iter, and ListIterator< T >::next().

◆ operator++()

template<class K , class V >
virtual void HashIterator< K, V >::operator++ ( int  num)
inlinevirtual

Increment operator.

This function first increment the current item and then updates the next item pointer.

Parameters
numIgnored

Implements Iterator< V >.

Definition at line 151 of file HashIterator.h.

References HashIterator< K, V >::m_iter.

◆ remove()

template<class K , class V >
virtual bool HashIterator< K, V >::remove ( )
inlinevirtual

Remove the current item from the underlying Container.

Returns
True if removed successfully, false otherwise.

Implements Iterator< V >.

Definition at line 136 of file HashIterator.h.

References ListIterator< T >::current(), HashIterator< K, V >::key(), HashIterator< K, V >::m_hash, HashIterator< K, V >::m_iter, and ListIterator< T >::remove().

◆ reset()

template<class K , class V >
virtual void HashIterator< K, V >::reset ( )
inlinevirtual

Reset the iterator.

Implements Iterator< V >.

Definition at line 63 of file HashIterator.h.

References HashIterator< K, V >::m_iter, and ListIterator< T >::reset().

Field Documentation

◆ m_hash

template<class K , class V >
HashTable<K, V>& HashIterator< K, V >::m_hash
private

Points to the HashTable to iterate.

Definition at line 159 of file HashIterator.h.

Referenced by HashIterator< K, V >::current(), HashIterator< K, V >::next(), and HashIterator< K, V >::remove().

◆ m_iter

template<class K , class V >
ListIterator<K> HashIterator< K, V >::m_iter
private

◆ m_keys

template<class K , class V >
List<K> HashIterator< K, V >::m_keys
private

List of keys to iterate.

Definition at line 162 of file HashIterator.h.


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