CMPT 212 - plist.h
David Simpson (simpson@cs.sfu.ca)
Wed, 17 Sep 1997 15:01:55 -0700 (PDT)
//
// NAME
// plist.h
//
// DESCRIPTION
// This file contains the type definitions and function prototypes
// exported by the Person-List module.
// This module maintains a list of people. The list is unsorted,
// and people are added to the end of the list. The current
// position in the list is maintained, and the functions getFirst()
// and getNext() move this current position. The function atEnd()
// determines if the current position is at the end of the list.
// The list is emptied by the function clearList().
//
#ifndef _plist_h_
#define _plist_h_
//
// Include files.
//
#include "bool.h"
#include "person.h"
//
// NAME
// addToEnd
//
// DESCRIPTION
// This function adds the given person to the end of the person list.
//
// PARAMETERS
// p (in) - the person to add to the list.
//
// RETURNS
// (none)
//
void addToEnd(person& p);
//
// NAME
// getFirst
//
// DESCRIPTION
// This function gets the first person in the person list. If
// the person was retrieved successfully, then the function
// returns true. If the person could not be retrieved (for
// example, the person list is empty), then false is returned.
// The "current position" in the list is moved to the second
// person in the list (if there is one).
//
// PARAMETERS
// p (out) - person retrieved from the list.
//
// RETURNS
// true - if the person was retrieved successfully.
// false - if the person could not be retrieved.
//
bool getFirst(person& p);
//
// NAME
// getNext
//
// DESCRIPTION
// This function gets the next person in the person list, that
// is, the person at the "current position" in the list. If
// the person was retrieved successfully, then the function
// returns true. If the person could not be retrieved (for
// example, the person list is empty), then false is returned.
// The "current position" in the list is moved to the next
// person in the list.
//
// PARAMETERS
// p (out) - person retrieved from the list.
//
// RETURNS
// true - if the person was retrieved successfully.
// false - if the person could not be retrieved.
//
bool getNext(person& p);
//
// NAME
// atEnd
//
// DESCRIPTION
// This function determines if the "current position" in the
// list is at the end of the list. If this function returns
// true, then a call to getNext() will return a person. If this
// function returns false, then a call to getNext() will not
// return a person.
//
// PARAMETERS
// (none)
//
// RETURNS
// true - if the "current position" is at the end of the list.
// false - if the "current position" is not at the end of the
// list.
//
bool atEnd();
//
// NAME
// clearList
//
// DESCRIPTION
// This function empties the list. After a call to this function,
// both getFirst() and getNext() will not return a person and
// atEnd() will return true.
//
// PARAMETERS
// (none)
//
// RETURNS
// (none)
//
void clearList();
#endif