Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: list.h // definition of the class list #include #include "node.h" namespace ifmp { template class list{ public: // default constructor: // POST: *this is an empty list list(); // destructor ~list(); // copy constructor list (const list& l); // assignment operator list& operator= (const list& l); // POST: key was added before first element of *this void push_front (T key); // POST: key was added after last element of *this void push_back (T key); // POST: the first occurrence of key was removed from *this // if *this does not contain key, nothing happened void remove (T key); // POST: the first element of *this was removed // if *this is empty nothing happened void pop_front(); // PRE: p points to an element, and previous points to the // element before (= 0 if p points to the first element) // POST: the element pointed to by p was removed from *this void remove (node* previous, const node* p); // POST: returns const pointer to the first node const node* get_head() const; // POST: *this was emptied void clear(); // POST: returns true iff *this an empty list bool empty() const; private: node* head_; // PRE: *this is empty // POST: list starting at from was copied to *this void copy (const node* from); }; } // output operator template std::ostream& operator<< (std::ostream& o, const ifmp::list& l); // include the implementation of the class ifmp::list #include "list.cpp"