//////////////////////////////// list.h //////////////////////////////////// // Simple linked list, uses Node as linked list node #ifndef LIST_H #define LIST_H #include "nodedata.h" #include #include using namespace std; //-------------------------- class List ------------------------------------ // ADT List: finite, ordered collection of zero or more items. // The ordering is determined by operator< of NodeData class. // // Assumptions: // -- Control of <, printing, etc of NodeData information is in the // NodeData class. // -- There is no dummy head node, head points to first node. // If empty, head is NULL. // -- The insert allocates memory for a Node, ptr to the data is passed in. // // Note this definition is not a complete class and is not fully documented. //---------------------------------------------------------------------------- class List { friend ostream &operator<<(ostream&, const List&); public: List(); // default constructor // ~List(); // destructor // List(const List&); // copy constructor bool insert(NodeData*); // insert one Node into list bool isEmpty() const; // is list empty? void buildList(ifstream&); // build a list from datafile void printBackwards() const; // print the list in reverse // needs many more member functions to become a complete ADT private: struct Node { // the node in a linked list NodeData* data; // pointer to actual data, operations in NodeData Node* next; }; Node* head; // pointer to first node void printBackwardsHelper(Node*) const; // actual backwards printer }; #endif