| | | | | |

Defining class TListIterator < T >

template <typename T>
class TListIterator
{
friend class TList<T>;

public:
  // terminology support
  typedef T value_type;

  // constructors
  TListIterator      ();
  TListIterator      (const TList<T>& L);
  TListIterator      (const TListIterator& I);

  // Initializers
  void  Initialize   (const TList<T>& L);
  void  rInitialize  (const TList<T>& L);

  // information/access
  T&        Retrieve       ();       // Return reference to current Tval 
  const T&  Retrieve       () const; // const version
  bool      Valid          () const; // cursor is valid element

  // various operators
  bool               operator == (const TListIterator& I2) const;
  bool               operator != (const TListIterator& I2) const;
  T&                 operator *  ();       // Return reference to current Tval
  const T&           operator *  () const; // const version
  TListIterator<T>&  operator =  (const TListIterator <T> & I);
  TListIterator<T>&  operator ++ ();    // prefix
  TListIterator<T>   operator ++ (int); // postfix
  TListIterator<T>&  operator -- ();    // prefix
  TListIterator<T>   operator -- (int); // postfix

protected:
  typename TList<T>::TLink  * currLink;
} ;

| | Top of Page | 8. A Generic List Class and Linked Lists - 17 of 19