dlist.hh
Go to the documentation of this file.00001 #ifndef DUNE_DLIST_HH 00002 #define DUNE_DLIST_HH 00003 00004 #include <dune/common/exceptions.hh> 00005 00006 namespace Dune { 00007 00018 00019 class DoubleLinkedListError : public RangeError {}; 00020 00024 template <class T> 00025 class DoubleLinkedList { 00026 private: 00027 struct Element; // Vorwaertsdeklaration fuer das Listenelement 00028 public: 00029 00032 class Iterator { 00033 private: 00035 Element* p; 00036 public: 00037 00039 Iterator(); 00040 00042 bool operator!= (Iterator x) const; 00043 00045 bool operator== (Iterator x) const; 00046 00048 Iterator& operator++ (); 00049 00051 Iterator operator++ (int); 00052 00054 Iterator& operator-- (); 00055 00057 Iterator operator-- (int); 00058 00060 T& operator* () const; 00061 00063 T* operator-> () const; 00064 00065 friend class DoubleLinkedList<T>; 00066 } ; 00067 00069 Iterator begin () const; 00070 00072 Iterator end () const; 00073 00075 Iterator rbegin () const; 00076 00078 Iterator rend () const; 00079 00080 00082 DoubleLinkedList() DUNE_DEPRECATED; 00083 00085 DoubleLinkedList (const DoubleLinkedList<T>&); 00086 00088 ~DoubleLinkedList(); 00089 00091 DoubleLinkedList<T>& operator= (const DoubleLinkedList<T>&); 00092 00094 int size () const; 00095 00099 Iterator insert_after (Iterator i, T& t); 00100 00104 Iterator insert_before (Iterator i, T& t); 00105 00107 void erase (Iterator i); 00108 00109 private: 00110 struct Element { // Typ fuer das Listenelement 00111 Element* next; // Nachfolger 00112 Element* prev; // Vorgaenger 00113 T item; // Datum 00114 Element (T &t); // setze next=prev=0 00115 }; 00116 00117 Iterator head; // erstes Element der Liste 00118 Iterator tail; // letztes Element der Liste 00119 int numelements; // Anzahl Elemente in der Liste 00120 } DUNE_DEPRECATED; 00121 00122 } 00123 00125 00126 #include"dlist.cc" 00127 00128 #endif