#ifndef PLISTITERATOR_H #define PLISTITERATOR_H //***************************************************************************** // // PListIterator.h // //***************************************************************************** // // Copyright (C) 1996 // // Ronald A. MacCracken // Graduate Student // Computer Science Department // University of California // Davis, CA 95616 // // Permission is granted to use at your own risk and // distribute this software in source and binary forms // provided the above copyright notice and this paragraph // are preserved on all copies. This software is provided // "as is" with no express or implied warranty. // //***************************************************************************** //***************************************************************************** // // Example Usage: // // PList list ; // // ... // // for ( PListIterator i = list ; ! i.Is_Done ( ) ; ++i ) // { // int* integer = iterator.Get_Current ( ) ; // // ... // } // //***************************************************************************** #include "PList.h" #include "PListElement.h" template class PListIterator { private: PListElement* first_element ; PListElement* current_element ; private: void Copy ( const PListIterator& ) ; void Delete ( void ) ; public: // constructors PListIterator ( void ) ; // initialize the current element to be // x elements into the list l PListIterator ( const PList& l , const int x = 0 ) ; // copy constructor PListIterator ( const PListIterator& l ) ; // destructor ~PListIterator ( void ) ; // assignment operator PListIterator& operator= ( const PListIterator& l ) ; // advances current element PListIterator& operator++ ( void ) ; PListIterator& operator++ ( int ) ; // access current element TYPE* Get_Current ( void ) const ; // accesses next element TYPE* Get_Next ( void ) const ; // tells whether or not iterator is finished int Is_Done ( void ) const ; // resets current element to first element void Reset ( void ) ; // resets current element as in constructor void Reset ( const PList& l , const int x = 0 ) ; } ; #include "PListIterator.C" #endif