// Doubly Linked List // // Douglas Thrift // // $Id$ #ifndef _DoublyLinkedList_hpp_ #define _DoublyLinkedList_hpp_ #include "NullNode.hpp" #include "Iterator.hpp" template class DoublyLinkedList { private: NullNode front; NullNode back; public: DoublyLinkedList() { front.setNext(&back); back.setPrevious(&front); } ~DoublyLinkedList() { while (front.getNext() != &back) front.removeNext(); } void addFront(const Type& value) { front.addNext(value); } void addBack(const Type& value) { back.addPrevious(value); } bool contains(const Type& value) { return front.contains(value, &back); } void removeFirst(const Type& value) { front.remove(value, &back); } void removeLast(const Type& value) { back.remove(value, &front, false); } Iterator iterator(void) { return Iterator(&front, &back); } void accept(Visitor* visitor) { front.accept(visitor, &back); } }; #endif // _DoublyLinkedList_hpp_