/* * CircleDoubleList.h * * Created on: Feb 3, 2009 * Author: adrienne * * CircleDoubleLists should only be instantiated with templatized types * that overload < > == != and <<. All of the C++ built-in types are fine. */ #ifndef CIRCLEDOUBLELIST_H_ #define CIRCLEDOUBLELIST_H_ #include #include using namespace std; template class CircleDoubleList { private: /** * This line inserts the definition of Node as part of this class' private * members, making it like an inner-class of this class, but Node is a struct, * so it's like an inner-struct, accessible within this class, but not outside it. */ #include "Node.h" Node* head; //Pointer to the head of the list Node* tail; //Pointer to the tail of the list int num_items; //Number of items in the list /** Add any additional private data members or functions needed here */ public: /** * Creates an empty list. */ CircleDoubleList() { } /** * Copy constructor for the list */ CircleDoubleList(const CircleDoubleList& otherList) { } /** * Destructor for the list */ ~CircleDoubleList() { } /** * Insert the element into the list. Must pay attention to whether or not * the list is sorted. If it is sorted, then insert in the appropriate order. * If the list is not sorted, insert at front of list. */ void insert(Element_Type element) { } /** * Returns the ordered status of the list, true is a sorted list, false is * an unsorted list. Lists should be sorted in ascending order (low to high). */ bool isOrdered() const { } /** * Sets the ordered status of the list. If an un-sorted list is set to be * sorted, then it must become a sorted list. If a sorted list becomes * unsorted, nothing needs to happen. * * TIP: You are not being graded on efficiency for this function, so look * to see if there is a place in C++ that has already implemented a sorting * function on some structure. Can you dump your data into that structure and * use that function, and then copy your data back? What are the drawbacks to * using this idea in terms of efficiency? */ void setOrdered(bool ordered) { } /** * Remove the element from the list. If successful, return true. Return * false if element not present in the list. */ bool remove(Element_Type element) { } /** * Clear out the contents of the list (and deallocate appropriately). */ void clear() { } /** * Returns true if the list is empty, false otherwise. */ bool isEmpty() const { } /** * Overload the output stream operator so that the list can be outputted * to the screen. This overloading assumes that the elements inside the list * have also overloaded this operator. */ friend ostream& operator<< (ostream& osObject, const CircleDoubleList& listObject) { } /** * Compares two CircleDoubleLists for equality. Returns true if the lists * contain the same elements in the same locations, false otherwise. Assumes * that the objects stored in the lists override the == and != operators. */ bool operator== (const CircleDoubleList& otherList) const { } /** * Adds two lists together. If both lists are ordered, then the ordered * property is maintained. If only one of the lists is ordered, then the * new list created by adding the two together is unordered, with the contents * of one of the lists being added to the contents of the other. */ const CircleDoubleList operator+(const CircleDoubleList& otherList) const { } }; #endif