// ListItr.C // implements the methods of the ListItr class // used to represent position within a Linked List #include "ListItr.H" // -------------------------------- // constructor // -------------------------------- template ListItr::ListItr( ) : current( NULL ) { // no code } //--------------------------------- // Private Constructor //-------------------------------- template ListItr::ListItr (ListNode *theNode) : current (theNode) { // no code } //-------------------------------- // isPastEnd() // returns true if the iterator represents a // data node that is past the end of the List // i.e., whose position is NULL //------------------------------------- template bool ListItr::isPastEnd( ) const { return current == NULL; } //------------------------------- // advance ( ) // move to the next node in the LL // -------------------------------- template void ListItr::advance( ) { if( !isPastEnd( ) ) current = current->next; } //-------------------------------- // retrieve () // get a constant reference to the Object // stored at the current position // --------------------------------- template const Object & ListItr::retrieve( ) const { if( isPastEnd( ) ) throw BadIterator( ); return current->element; }