/////// File : List.h /////// // linked list objects #ifndef List_SEEN__ #define List_SEEN__ #include class ListCell { friend class List; private: char item; ListCell* next; ListCell(char c = '\0', ListCell* ptr = NULL) : item(c), next(ptr) { } // constructor }; class List { public: List() : head(NULL) { } // empty list constructor List(char c) // list with first cell : head (new ListCell(c,NULL)) { } ListCell* first() { return head; } // first cell ListCell* last(); // last cell ListCell* find(char c); // first item == c int substitute(char r, char s); // r for first s on list int remove(char c); // c from entire list void remove(ListCell* cell); // remove given cell int shorten(int n); // remove first n cells int put_on(char c); // insert in front int insert(char c, ListCell* cell);// insert after cell int append(char c) // insert at end { return insert(c, last()); } int is_empty() { return(head == NULL); } void display(ListCell* p); // display from p to end void display() { display(head); } // display whole list ~List(); // destructor private: ListCell* head; // first cell of list void free(); // free all cells }; #endif