/***************************************************************************************** File objlist.h Description Provides a definition of class List. List is a class that defines a list that allows insertions and deletions from both the front and end the data structure is a singly-linked list with pointers to the first and last elements. Insertions at either end are easy. Deleting the element at the front of the list is also easy, but deleting the element at the end of the list requires traversing the entire list. Include File Dependencies vehicle.h mystring.h Change History 06/19/98 (distribution disk) Initial Definition from code provided with Instructor's Manual to accompany Programming Languages Paradigm and Practice, 2nd Edition by Doris Appleby and Julius J. VandeKopple McGraw Hill, 1997. *****************************************************************************************/ #ifndef OBJLIST_H_INCLUDED #define OBJLIST_H_INCLUDED #include "vehicle.h" #include "Mystring.h" typedef Vehicle *ItemType; class List { public: List() : ListFront(0), ListEnd(0) {} // initialize pointers to zero ~List(); int is_empty() const { return ListFront == 0; } void AddToFront(ItemType); void AddToEnd(ItemType); ItemType RemoveFromFront(); ItemType RemoveFromEnd(); private: struct Node { Node(ItemType i, Node *n) : item(i), next(n) {}; ItemType item; Node *next; }; Node *ListFront; // pointer to first element of the list Node *ListEnd; // pointer to the last element }; #endif