FreeNOS
Public Member Functions | Private Attributes
ListIterator< T > Class Template Reference

Iterate through a List. More...

#include <ListIterator.h>

Inheritance diagram for ListIterator< T >:
Iterator< T >

Public Member Functions

 ListIterator (List< T > *list)
 Class constructor. More...
 
 ListIterator (List< T > &list)
 Class constructor. More...
 
 ListIterator (const List< T > &list)
 Constant class constructor. More...
 
virtual void reset ()
 Reset the iterator. More...
 
virtual bool hasNext () const
 Check if there is more on the List to iterate. More...
 
virtual bool hasCurrent () const
 Check if there is a current item on the List. More...
 
virtual const T & current () const
 Get current item in the List. More...
 
virtual T & current ()
 Get current item in the List. More...
 
virtual T & next ()
 Fetch the next item. More...
 
virtual bool remove ()
 Remove the current item from the List. More...
 
virtual void operator++ (int num)
 Increment operator. More...
 
- Public Member Functions inherited from Iterator< T >
virtual ~Iterator ()
 Destructor. More...
 

Private Attributes

List< T > & m_list
 Points to the List to iterate. More...
 
class List< T >::Node * m_current
 Current node. More...
 
class List< T >::Node * m_next
 Next node. More...
 

Detailed Description

template<class T>
class ListIterator< T >

Iterate through a List.

Definition at line 37 of file ListIterator.h.

Constructor & Destructor Documentation

◆ ListIterator() [1/3]

template<class T >
ListIterator< T >::ListIterator ( List< T > *  list)
inline

Class constructor.

Parameters
listReference to the List to iterate.

Definition at line 46 of file ListIterator.h.

◆ ListIterator() [2/3]

template<class T >
ListIterator< T >::ListIterator ( List< T > &  list)
inline

Class constructor.

Parameters
listReference to the List to iterate.

Definition at line 59 of file ListIterator.h.

◆ ListIterator() [3/3]

template<class T >
ListIterator< T >::ListIterator ( const List< T > &  list)
inline

Constant class constructor.

Parameters
listReference to the List to iterate.

Definition at line 72 of file ListIterator.h.

Member Function Documentation

◆ current() [1/2]

template<class T >
virtual T& ListIterator< T >::current ( )
inlinevirtual

Get current item in the List.

Returns
Current item.

Implements Iterator< T >.

Definition at line 124 of file ListIterator.h.

◆ current() [2/2]

template<class T >
virtual const T& ListIterator< T >::current ( ) const
inlinevirtual

◆ hasCurrent()

template<class T >
virtual bool ListIterator< T >::hasCurrent ( ) const
inlinevirtual

◆ hasNext()

template<class T >
virtual bool ListIterator< T >::hasNext ( ) const
inlinevirtual

Check if there is more on the List to iterate.

Returns
true if more items, false if not.

Implements Iterator< T >.

Definition at line 94 of file ListIterator.h.

Referenced by Associative< String, FileCache * >::clear(), ConstHashIterator< K, V >::hasNext(), and HashIterator< K, V >::hasNext().

◆ next()

template<class T >
virtual T& ListIterator< T >::next ( )
inlinevirtual

Fetch the next item.

8 This function first fetches the next item and then updates the current item pointer to that item. It assumes the iterator has a next item.

Returns
The next item.
See also
hasNext

Implements Iterator< T >.

Definition at line 140 of file ListIterator.h.

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

◆ operator++()

template<class T >
virtual void ListIterator< T >::operator++ ( int  num)
inlinevirtual

Increment operator.

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

Implements Iterator< T >.

Definition at line 175 of file ListIterator.h.

◆ remove()

template<class T >
virtual bool ListIterator< T >::remove ( )
inlinevirtual

Remove the current item from the List.

Returns
True if successfull, false otherwise.

Implements Iterator< T >.

Definition at line 153 of file ListIterator.h.

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

◆ reset()

template<class T >
virtual void ListIterator< T >::reset ( )
inlinevirtual

Reset the iterator.

Implements Iterator< T >.

Definition at line 83 of file ListIterator.h.

Referenced by ListIterator< K >::ListIterator(), ConstHashIterator< K, V >::reset(), and HashIterator< K, V >::reset().

Field Documentation

◆ m_current

template<class T >
class List< T >::Node* ListIterator< T >::m_current
private

◆ m_list

template<class T >
List<T>& ListIterator< T >::m_list
private

Points to the List to iterate.

Definition at line 191 of file ListIterator.h.

Referenced by ListIterator< K >::remove(), and ListIterator< K >::reset().

◆ m_next

template<class T >
class List< T >::Node* ListIterator< T >::m_next
private

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