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 #include <dune/common/deprecated.hh>
00006 
00007 namespace Dune {
00008 
00019 
00020   class DoubleLinkedListError : public RangeError {} DUNE_DEPRECATED;
00021 
00025   template <class T> 
00026   class DoubleLinkedList {
00027   private:
00028         struct Element;   // Vorwaertsdeklaration fuer das Listenelement 
00029   public:
00030 
00033         class Iterator {
00034         private:
00036           Element* p;
00037         public:
00038 
00040           Iterator();
00041 
00043           bool operator!= (Iterator x) const;
00044 
00046           bool operator== (Iterator x) const;
00047 
00049           Iterator& operator++ ();
00050 
00052           Iterator operator++ (int);
00053 
00055           Iterator& operator-- ();
00056 
00058           Iterator operator-- (int);
00059 
00061           T& operator* () const;
00062 
00064           T* operator-> () const;
00065 
00066           friend class DoubleLinkedList<T>;
00067         } ;
00068 
00070         Iterator begin () const; 
00071 
00073         Iterator end () const;
00074 
00076         Iterator rbegin () const; 
00077 
00079         Iterator rend () const;
00080         
00081 
00083         DoubleLinkedList() DUNE_DEPRECATED;
00084 
00086         DoubleLinkedList (const DoubleLinkedList<T>&);
00087 
00089         ~DoubleLinkedList();
00090 
00092         DoubleLinkedList<T>& operator= (const DoubleLinkedList<T>&);
00093 
00095         int size () const;
00096 
00100         Iterator insert_after (Iterator i, T& t);
00101 
00105         Iterator insert_before (Iterator i, T& t);
00106 
00108         void erase (Iterator i);
00109 
00110   private:
00111         struct Element {      // Typ fuer das Listenelement
00112           Element* next;    // Nachfolger
00113           Element* prev;    // Vorgaenger
00114           T item;           // Datum
00115           Element (T &t);   // setze next=prev=0
00116         };
00117 
00118         Iterator head;        // erstes Element der Liste
00119         Iterator tail;        // letztes Element der Liste
00120         int numelements;      // Anzahl Elemente in der Liste
00121   } DUNE_DEPRECATED;
00122 
00123 }
00124 
00126 
00127 #include"dlist.cc"
00128 
00129 #endif

Generated on Tue Jul 28 22:27:49 2009 for dune-common by  doxygen 1.5.6