template class List; template ostream &operator<<( ostream &, const List & ); template class List { friend ostream &operator<< <>( ostream &, const List & ); public: List(); List( const List & ); /* throws bad_alloc */ ~List(); void add( unsigned, const T & ); /* throws bad_alloc and out_of_range */ void addAll( const List & ); /* throws bad_alloc */ void addAll( unsigned, const List & ); /* throws bad_alloc, out_of_range */ void addFirst( const T & ); /* throws bad_alloc */ void addLast( const T & ); /* throws bad_alloc */ void clear(); bool contains( const T & ) const; bool empty() const; int indexOf( const T & ) const; T &get( unsigned ) const; /* throws out_of_range */ T &getFirst() const; /* throws NoSuchObject */ T &getLast() const; /* throws NoSuchObject */ ListIterator listIterator(); ListIterator listIterator( unsigned ); /* throws out_of_range */ T remove( unsigned ); /* throws out_of_range */ T removeFirst(); /* throws NoSuchObject */ T removeFirstOccurrence( const T & ); /* throws NoSuchObject */ T removeLast(); /* throws NoSuchObject */ T removeLastOccurrence( const T & ); /* throws NoSuchObject */ T set( unsigned, const T & ); /* throws out_of_range */ unsigned size() const; T *toArray() const; /* throws bad_alloc */ const List &operator=( const List & ); /* throws bad_alloc */ void printInternal( ostream & = cout ) const; private: Node *frontPtr, *backPtr; unsigned sz; void add( Node *, const T & ); /* throws bad_alloc */ void initialize(); Node *getIthNode( unsigned ) const; /* throws out_of_range */ T remove( Node * ); }; // List class