#ifndef LIST_H #define LIST_H #include #include #include #include "node.h" #include "iterator.h" #include "nosuchobject.h" using namespace std; template class List; template ostream &operator<<( ostream &, const List & ); template class List { friend ostream &operator<< <>( ostream &, const List & ); public: List(); List( const List & ) throw ( bad_alloc ); ~List(); void add( unsigned, const T & ) throw ( bad_alloc, out_of_range ); void addAll( const List & ) throw ( bad_alloc ); void addAll( unsigned, const List & ) throw ( bad_alloc, out_of_range ); void addFirst( const T & ) throw ( bad_alloc ); void addLast( const T & ) throw ( bad_alloc ); void clear(); bool contains( const T & ) const; bool empty() const; int indexOf( const T & ) const; T &get( unsigned ) const throw ( out_of_range ); T &getFirst() const throw ( NoSuchObject ); T &getLast() const throw ( NoSuchObject ); ListIterator listIterator(); ListIterator listIterator( unsigned ) throw ( out_of_range ); T remove( unsigned ) throw ( out_of_range ); T removeFirst() throw ( NoSuchObject ); T removeFirstOccurrence( const T & ) throw ( NoSuchObject ); T removeLast() throw ( NoSuchObject ); T removeLastOccurrence( const T & ) throw ( NoSuchObject ); T set( unsigned, const T & ) throw ( out_of_range ); unsigned size() const; T *toArray() const throw ( bad_alloc ); const List &operator=( const List & ) throw ( bad_alloc ); void printInternal( ostream & = cout ); private: Node *frontPtr, *backPtr; unsigned sz; void add( Node *, const T & ) throw ( bad_alloc ); void initialize(); Node *getIthNode( unsigned ) const throw ( out_of_range ); T remove( Node * ); }; // List class #endif