#include #include "list.h" // The insertion of list items is fairly standard. void emptyList::insert(emptyNode *p) { len++; p->next = head; head = p; if (!tail) tail = p; } // The precaution in appending list items is checking for the empty list // when tail is nil. void emptyList::append(emptyNode *p) { len++; if (tail) tail->next = p; else head = p; tail = p; } // The destruction operation of a list clears the nodes used in // constructing the list. emptyList::~emptyList() { while (head) { emptyNode *toDelete = head; head = head->next; delete toDelete; } } // The member function get() detaches the first item and updates the // list appropriately. Destruction of the node is left to the caller. emptyNode *emptyList::get() { emptyNode *p = head; if (head) { head = head->next; --len; if (!head) tail = 0; } return p; }