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

Iterate through a constant (read-only) HashTable. More...

#include <ConstHashIterator.h>

Inheritance diagram for ConstHashIterator< K, V >:
ConstIterator< V >

Public Member Functions

 ConstHashIterator (const HashTable< K, V > &hash)
 Class constructor. More...
 
virtual ~ConstHashIterator ()
 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 const K & key () const
 Get the current key. More...
 
virtual const V & next ()
 Fetch the next item. More...
 
virtual void operator++ (int num)
 Increment operator. More...
 
- Public Member Functions inherited from ConstIterator< V >
virtual ~ConstIterator ()
 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...
 
virtual const V & current () const=0
 Get the current item read-only. More...
 

Private Attributes

const 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 ConstHashIterator< K, V >

Iterate through a constant (read-only) HashTable.

Definition at line 39 of file ConstHashIterator.h.

Constructor & Destructor Documentation

◆ ConstHashIterator()

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

Class constructor.

Parameters
hashReference to the HashTable to iterate.

Definition at line 48 of file ConstHashIterator.h.

◆ ~ConstHashIterator()

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

Destructor.

Definition at line 56 of file ConstHashIterator.h.

Member Function Documentation

◆ current()

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

Get the current value (read-only).

Returns
Reference to the current read-only value.

Definition at line 92 of file ConstHashIterator.h.

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

◆ hasCurrent()

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

Check if there is a current item.

Returns
True if the iterator has a current item, false otherwise.

Definition at line 82 of file ConstHashIterator.h.

References ListIterator< T >::hasCurrent(), and ConstHashIterator< K, V >::m_iter.

Referenced by ArgumentParser::getUsage().

◆ hasNext()

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

Check if there is more to iterate.

Returns
true if more items, false if not.

Definition at line 72 of file ConstHashIterator.h.

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

◆ key()

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

Get the current key.

Returns
Reference to the current key.

Definition at line 102 of file ConstHashIterator.h.

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

◆ next()

template<class K , class V >
virtual const V& ConstHashIterator< 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 ConstIterator< V >.

Definition at line 115 of file ConstHashIterator.h.

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

◆ operator++()

template<class K , class V >
virtual void ConstHashIterator< 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 ConstIterator< V >.

Definition at line 128 of file ConstHashIterator.h.

References ConstHashIterator< K, V >::m_iter.

◆ reset()

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

Reset the iterator.

Implements ConstIterator< V >.

Definition at line 63 of file ConstHashIterator.h.

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

Field Documentation

◆ m_hash

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

Points to the HashTable to iterate.

Definition at line 136 of file ConstHashIterator.h.

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

◆ m_iter

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

◆ m_keys

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

List of keys to iterate.

Definition at line 139 of file ConstHashIterator.h.


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