next up previous contents
Next: Delete an Element From Up: The CHAR_SLLIST Implementation Details: Previous: Building a List:

How Many Elements Are in the List?

    // *************************************** //
    // get the number of elements in the list  //
    // *************************************** //
int CHAR_SLLIST::get_number_elements()
{
  if(head==NULL) return(0);
  else{
    int i = 1;
    CHAR_SL_CELL *again;
    again = head->next;
    while(!(again==NULL)){
      ++i;
      again = again->next;
      }
    return(i);
    }
}



Jim Peterson
1999-04-22