#ifndef OU_LINKED_LIST #define OU_LINKED_LIST #include "OULink.h" #include "Comparator.h" #include "OULinkedListEnumerator.h" // OULinkedList stands for Ordered, Unique Linked List. It is a linked list that is always maintained in // order (based on the comparator provided to it when the list is created) and that only contains unique // items (that is, duplicates are not allowed) template class OULinkedList { // template // not necessary // friend class OULinkedListEnumerator; // not necessary private: Comparator* comparator = NULL; // used to determine list order and item equality unsigned long size = 0; // actual number of items currently in list OULink* first = NULL; // pointer to first link in list OULink* last = NULL; // pointer to last link in list public: OULinkedList(Comparator* comparator); // creates empty linked list with comparator virtual ~OULinkedList(); // deletes all links and their data items // if an equivalent item is not already present, insert item in order and return true // if an equivalent item is already present, leave list unchanged and return false bool insert(const T* item); // if item is greater than item at last, append item at end and return true // if item is less than or equal to item at last, leave list unchanged and return false bool append(const T* item); // now const // if an equivalent item is already present, replace item and return true // if an equivalent item is not already present, leave list unchanged and return false bool replace(const T* item); // now const // if an equivalent item is already present, remove item and return true // if an equivalent item is not already present, leave list unchanged and return false bool remove(const T* item); // now const // if any items are present, return a copy of the first item // if no items are present, throw new ExceptionLinkedListAccess T get() const; // if an equivalent item is present, return a copy of the first such item // if an equivalent item is not present, throw a new ExceptionLinkedListAccess T find(const T* item) const; unsigned long getSize() const; // returns the current number of items in the list OULinkedListEnumerator enumerator() const; // create an enumerator for this linked list }; // Implementation goes here #endif // !OU_LINKED_LIST