For use with CMSC-341, Spring 99, Project 2 Here is the definition of the List class. Copy it to your List.H file. Remember: -- implement the inline method(s) -- guard the file -- complete the documentation ------------------------------------------------ /* Interface for List. Author: Thomas Anastasio Version: 5 February 1999 */ template class List { private: int _length; // number of elements in the list protected: inline void SetLength(int len); public: // Adds element x at position pos of this list, causing previous // elements at positions >= pos to move up. The lowest position is 1. // Param: x the element to be inserted. // Param: pos the position at which to place x // ( 0 < pos <= list_length + 1) // Return: true if insertion succeeds, false otherwise. virtual bool Insert(const T& x, int pos) = 0; // Adds element x at the end of this list. // Param: x the element to be appended. // Return: true if succeeds, false otherwise. virtual bool Append(const T& x) = 0; // Accesses the element at the specified position in this list. // Param: pos the position at which to retrieve the element. // Return: the element at pos. // Pre-condition: pos is a valid position // ( 0 < pos <= list_length) // It is an error to attempt to retrieve an element from an // invalid position. virtual T& Retrieve(int pos) = 0; // Deletes the element at the specified position in this list. // Param: pos the position at which to delete the element. // ( 0 < pos <= list_length) // Return: true if deletion succeeds, false otherwise. Deletion // from an empty list returns false. virtual bool Delete(int pos) = 0; // Accessor for the size of this list. // Return: the number of elements on this list. inline int Length() const; // Test for this list being empty. // Return: true if this list is empty, false otherwise. bool IsEmpty() const; // Makes this list be empty virtual void MakeEmpty() = 0; // A string describing this list. For example, the string // describing a LinkedList would be "LinkedList" // Return: a string description virtual char * ToString() = 0; // Accessor for a forward iterator over the list. // Traversal direction is forward (head to tail). // Return: ptr to the Iterator. // Note: allocated on the heap. User is responsible for // storage deallocation. virtual Iterator * GetIterator() = 0; // Accessor for a reverse iterator over the list. // Traversal direction is reverse (tail to head). // Return: ptr to the Iterator. // Note: allocated on the heap. User is responsible for // storage deallocation. virtual Iterator * GetReverseIterator() = 0; }; // Output stream operator that works for any List. // Writes the elements of the list in the textbook's style (a // comma-separated list of elements inside parenthesis). For // example the list containing the elements 1, 2, and 3 would // be printed as (1,2,3) template ostream& operator<< (ostream &, List &);