/* * list.txt * Copyright (c) 2023 Mark Maloof. All Rights Reserved. See LICENSE. */ template class List; template ostream &operator<<( ostream &, const List & ); template class List { friend ostream &operator<< <>( ostream &, const List & ); public: List(); List( const List & ); ~List(); void add( size_t, const T & ); // throws out_of_range void addAll( const List & ); void addAll( size_t, const List & ); // throws out_of_range void addFirst( const T & ); void addLast( const T & ); void clear(); bool contains( const T & ) const; bool empty() const; int indexOf( const T & ) const; T &get( size_t ) const; // throws out_of_range T &getFirst() const; // throws NoSuchObject T &getLast() const; // throws NoSuchObject ListIterator listIterator(); ListIterator listIterator( size_t ); // throws out_of_range T remove( size_t ); // 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( size_t, const T & ); // throws out_of_range size_t size() const; T *toArray() const; const List &operator=( const List & ); void printInternal( ostream & = cout ) const; private: Node *frontPtr, *backPtr; size_t sz; void add( Node *, const T & ); void initialize(); Node *getIthNode( size_t ) const; // throws out_of_range T remove( Node * ); }; // List class