#ifndef __TLL_H #define __TLL_H // tll.h /* this implements a template class linklist, descended from tlist.h one can create an assoc array out of this by creating an elem class in which the comparison operator depends on the key alone. Then search will return the full elem and one can check the associated vaule to the key */ #include #include "tlist.h" template class LLNode; template class LinkedList : public List { LLNode *root; public: LinkedList(void); ~LinkedList(void); LinkedList(const LinkedList &llist); // the copy constructor LinkedList &operator = (const LinkedList &llist); Elem *Insert(const Elem &elem); // this does not insert if val already exists // returns ptr to elem in list if it could insert void Clear(void); int DeleteNext(Elem &elem); // deletes first elem in list and returns it int GetNext(Elem &elem, int start); // returns the next element in the list, if start is set then returns // the first one, returns 0 if the list is now empty Elem *Search(const Elem &elem); // assumes the == operator defined on elem void Write(ostream &s); friend ostream &operator<<(ostream &s, LinkedList &ll); int Empty(void) {return (root ? 0 : 1);} int Size(void) {return length;} private: int length; LLNode *get_next_ptr; // because the next one is ongoing }; #endif