// FILE: SlistT.h // Ed Smith // R England, Rhodes College // CS 142, Spring 2003 // // Interface: singly linked list Template // #ifndef SLISTT_H #define SLISTT_H template class SlistT { public: //// public member functions: SlistT (void); // constructor, destructor ~SlistT (void); // mutators void insert (const Type& newItem); // insert new item after current bool remove (void); // remove item void clean (void); // remove all items bool append (const SlistT& other); // append copy of another list to the end of this one bool prepend (const SlistT& other); // prepend copy of another list to the end of this one bool rotateLeft (unsigned n); // rotate nodes to the left n pos'ns bool rotateRight (unsigned n); // rotate nodes to the right n pos'ns bool move (void); // move to next item void moveToEnd (void); // move to end of list void reset (void); // return to beginning of list // accessors bool empty (void) const; // is list empty? bool get (Type& item) const; // get current item void printDEBUG (void) const; // print all items [DEBUG] unsigned length (void) const; // return the length of the list bool equal (const SlistT& other) const; // are the 2 lists equal private: //// private data struct Node { // Node constructors Node (void) { next = 0; } Node (const Type& newItem) { dataItem = newItem; next = 0; } // Node data Type dataItem; Node *next; }; Node *head, *tail, *cursor; unsigned listLength; // length of list //// private member function: void printDEBUG (const Node *thisNode) const; }; #endif