Home Segments Index Top Previous Next

780: Mainline

Next, you need member functions to access the elements, advance current_link_pointer to the next link object, test if current_link_pointer is the null pointer, and reset the current_link_pointer. Conveniently, you can borrow all these member functions from the definition of the header template class:

template  
class iterator { 
  public:  ... 
    iterator_parameter* access ( ) { 
      return current_link_pointer -> element_pointer; 
    } 
    void advance ( ) { 
      current_link_pointer = current_link_pointer -> next_link_pointer; 
    } 
    int endp ( ) { 
      return ! current_link_pointer; 
    } 
    void reset ( ) { 
      current_link_pointer = first_link_pointer; 
    } 
  private: link* current_link_pointer; 
           link* first_link_pointer; 
};