ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccscs20/DoublyLinkedList.hpp
Revision: 7
Committed: 2004-05-14T00:13:01-07:00 (21 years, 1 month ago) by Douglas Thrift
File size: 950 byte(s)
Log Message:
Eraser!

File Contents

# Content
1 // Doubly Linked List
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _DoublyLinkedList_hpp_
8 #define _DoublyLinkedList_hpp_
9
10 #include "NullNode.hpp"
11 #include "Iterator.hpp"
12
13 template<typename Type>
14 class DoublyLinkedList
15 {
16 private:
17 NullNode<Type> front;
18 NullNode<Type> back;
19 public:
20 DoublyLinkedList() { front.setNext(&back); back.setPrevious(&front); }
21 ~DoublyLinkedList();
22 void addFront(const Type& value) { front.addNext(value); }
23 void addBack(const Type& value) { back.addPrevious(value); }
24 bool contains(const Type& value) { return front.contains(value, &back); }
25 void removeFirst(const Type& value) { front.remove(value, &back); }
26 void removeLast(const Type& value) { back.remove(value, &front, false); }
27 Iterator<Type> iterator(void) { return Iterator<Type>(&front, &back); }
28 };
29
30 template<typename Type>
31 DoublyLinkedList<Type>::~DoublyLinkedList()
32 {
33 while (front.getNext() != &back) front.removeNext();
34 }
35
36 #endif // _DoublyLinkedList_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id