From 71eeac08ab8cdfd64568ef21d9ce7dce8df33d93 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@dune-project.org> Date: Sat, 9 May 2009 20:54:42 +0000 Subject: [PATCH] remove deprecated class DoubleLinkedList [[Imported from SVN: r5514]] --- common/Makefile.am | 4 +- common/dlist.cc | 268 --------------------------------------- common/dlist.hh | 131 ------------------- common/test/parsetest.cc | 1 - 4 files changed, 2 insertions(+), 402 deletions(-) delete mode 100644 common/dlist.cc delete mode 100644 common/dlist.hh diff --git a/common/Makefile.am b/common/Makefile.am index 5a74f9774..660f33d8e 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -10,8 +10,8 @@ libcommon_la_SOURCES = stdstreams.cc configparser.cc AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/.. commonincludedir = $(includedir)/dune/common -commoninclude_HEADERS = dlist.cc alignment.hh \ - arraylist.hh bitsetvector.hh debugstream.hh deprecated.hh dlist.hh \ +commoninclude_HEADERS = alignment.hh \ + arraylist.hh bitsetvector.hh debugstream.hh deprecated.hh \ enumset.hh exceptions.hh fixedarray.hh fmatrix.hh \ fvector.hh genericiterator.hh \ helpertemplates.hh iteratorfacades.hh \ diff --git a/common/dlist.cc b/common/dlist.cc deleted file mode 100644 index 7903a8307..000000000 --- a/common/dlist.cc +++ /dev/null @@ -1,268 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifndef DLIST_CC -#define DLIST_CC - -#include <new> // for std::nothrow - -namespace Dune { - - // Iterator interface - template<class T> inline - typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::begin () const - { - return head; - } - - template<class T> inline - typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::end () const - { - Iterator tmp; // Iterator mit 0 Zeiger ! - return tmp; - } - - template<class T> inline - typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::rbegin () const - { - return tail; - } - - template<class T> inline - typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::rend () const - { - Iterator tmp; // Iterator mit 0 Zeiger ! - return tmp; - } - - // Konstruktor - template<class T> - inline DoubleLinkedList<T>::DoubleLinkedList () - { // ruft vorher Default_konstruktor fuer head, tail - numelements=0; - } - - // Copy-Konstruktor - template<class T> - inline DoubleLinkedList<T>::DoubleLinkedList (const DoubleLinkedList<T>& l) - { // ruft vorher Default_konstruktor fuer head, tail - numelements=0; - // kopiere alle Elemente der Argumentliste - for (typename DoubleLinkedList<T>::Iterator i=l.begin(); i!=l.end(); i++) - insert_after(rbegin(),*i); - } - - // Zuweisung - template<class T> - inline DoubleLinkedList<T>& DoubleLinkedList<T>::operator= (const DoubleLinkedList<T>& l) - { - if (this!=&l) - { - // loesche alle Elemente der Liste auf der linken Seite - while (begin()!=end()) erase(begin()); - - // kopiere alle Elemente der Liste auf der rechten Seite - for (typename DoubleLinkedList<T>::Iterator i=l.begin(); i!=l.end(); i++) - insert_after(rbegin(),*i); - } - return *this; - } - - // Destruktor - template<class T> - inline DoubleLinkedList<T>::~DoubleLinkedList() - { - while (begin()!=end()) erase(begin()); - } - - template<class T> - inline int DoubleLinkedList<T>::size () const - { - return numelements; - } - - - template<class T> - inline typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::insert_after (Iterator i, T& t) - { - // Teste Eingabe - if (i.p==0 && head.p!=0) - DUNE_THROW(DoubleLinkedListError, - "invalid iterator for insert_after"); - - // neues Listenelement erzeugen, - Element* e = new(std::nothrow) Element(t); - if (e==0) - DUNE_THROW(OutOfMemoryError, "cannot insert into DoubleLinkedList"); - - // einfuegen - if (head.p==0) - { - // einfuegen in leere Liste - head.p=e; tail.p=e; - } - else - { - // nach Element i.p einsetzen - e->prev = i.p; - e->next = i.p->next; - i.p->next = e; - if (e->next!=0) e->next->prev = e; - // tail neu ? - if (tail==i) tail.p=e; - } - - // Groesse und Rueckgabeiterator - numelements = numelements+1; - Iterator tmp; - tmp.p = e; - return tmp; - } - - template<class T> - inline typename DoubleLinkedList<T>::Iterator DoubleLinkedList<T>::insert_before (Iterator i, T& t) - { - // Teste Eingabe - if (i.p==0 && head.p!=0) - DUNE_THROW(DoubleLinkedListError, - "invalid iterator for insert_before"); - - // neues Listenelement erzeugen, - Element* e = new(std::nothrow) Element(t); - if (e==0) - DUNE_THROW(OutOfMemoryError, "cannot insert into DoubleLinkedList"); - - // einfuegen - if (head.p==0) - { - // einfuegen in leere Liste - head.p=e; tail.p=e; - } - else - { - // vor Element i.p einsetzen - e->next = i.p; - e->prev = i.p->prev; - i.p->prev = e; - if (e->prev!=0) e->prev->next = e; - // head neu ? - if (head==i) head.p=e; - } - - // Groesse und Rueckgabeiterator - numelements = numelements+1; - Iterator tmp; - tmp.p = e; - return tmp; - } - - template<class T> - inline void DoubleLinkedList<T>::erase (Iterator i) - { - // Teste Eingabe - if (i.p==0) return; - - // Ausfaedeln - if (i.p->next!=0) i.p->next->prev = i.p->prev; - if (i.p->prev!=0) i.p->prev->next = i.p->next; - - // head & tail - if (head==i) head.p=i.p->next; - if (tail==i) tail.p=i.p->prev; - - // Loeschen - delete i.p; - - // Groesse - numelements = numelements-1; - - return; - } - - template <class T> - inline std::ostream& operator<< (std::ostream& s, DoubleLinkedList<T>& a) - { - T t; - s << "dlist " << a.size() << " elements = (" << std::endl; - for (typename DoubleLinkedList<T>::Iterator i=a.begin(); i!=a.end(); i++) - { - t = *i; - s << " " << t << std::endl; - } - s << ")" << std::endl; - return s; - } - - - template<class T> - inline DoubleLinkedList<T>::Element::Element (T &t) : item(t) - { - next=0; prev=0; - } - - template<class T> - inline DoubleLinkedList<T>::Iterator::Iterator () - { - p=0; - } - - template<class T> - inline bool DoubleLinkedList<T>::Iterator::operator!= - (typename DoubleLinkedList<T>::Iterator x) const - { - return p != x.p; - } - - template<class T> - inline bool DoubleLinkedList<T>::Iterator::operator== - (typename DoubleLinkedList::Iterator x) const - { - return p == x.p; - } - - template<class T> - inline typename DoubleLinkedList<T>::Iterator & - DoubleLinkedList<T>::Iterator::operator++ () // prefix - { - p = p->next; return *this; - } - - template<class T> - inline typename DoubleLinkedList<T>::Iterator - DoubleLinkedList<T>::Iterator::operator++ (int) // postfix - { - Iterator tmp = *this; - ++*this; - return tmp; - } - - template<class T> - inline typename DoubleLinkedList<T>::Iterator & - DoubleLinkedList<T>::Iterator::operator-- () // prefix - { - p = p->prev; return *this; - } - - template<class T> - inline typename DoubleLinkedList<T>::Iterator - DoubleLinkedList<T>::Iterator::operator-- (int) // postfix - { - Iterator tmp = *this; - --*this; - return tmp; - } - - template<class T> - inline T& DoubleLinkedList<T>::Iterator::operator* () const - { - return p->item; - } - - template<class T> - inline T* DoubleLinkedList<T>::Iterator::operator-> () const - { - return &(p->item); - } - -} - -#endif diff --git a/common/dlist.hh b/common/dlist.hh deleted file mode 100644 index 336a19884..000000000 --- a/common/dlist.hh +++ /dev/null @@ -1,131 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -#ifndef DUNE_DLIST_HH -#define DUNE_DLIST_HH - -#include <dune/common/exceptions.hh> -#include <dune/common/deprecated.hh> - -namespace Dune { - - /*! \addtogroup Common - @{ - */ - - /*! \file - - Declaration of a doubly linked list - */ - - - //! exception thrown on illegal element access - class DoubleLinkedListError : public RangeError {} DUNE_DEPRECATED; - - /*! \brief (DEPRECATED) A doubly-linked list - \deprecated Please use std::list - */ - template <class T> - class DoubleLinkedList { - private: - struct Element; // Vorwaertsdeklaration fuer das Listenelement - public: - - /** \brief Iterator class for the doubly-linked list - */ - class Iterator { - private: - //! Iterator is a pointer to a list element - Element* p; - public: - - //! constructor - Iterator(); - - //! comparison - bool operator!= (Iterator x) const; - - //! comparison - bool operator== (Iterator x) const; - - //! Prefix increment - Iterator& operator++ (); - - //! Postfix increment - Iterator operator++ (int); - - //! Prefix decrement - Iterator& operator-- (); - - //! Postfix decrement - Iterator operator-- (int); - - //! dereferenciation - T& operator* () const; - - //! dereferenciation (Stroustrup p. 289) - T* operator-> () const; - - friend class DoubleLinkedList<T>; - } ; - - //! iterator at the lists start - Iterator begin () const; - - //! iterator behind last element - Iterator end () const; - - //! iterator at the lists end - Iterator rbegin () const; - - //! iterator before the lists start - Iterator rend () const; - - - //! empty constructor - DoubleLinkedList() DUNE_DEPRECATED; - - //! copy constructor - DoubleLinkedList (const DoubleLinkedList<T>&); - - //! destructor - ~DoubleLinkedList(); - - //! Deep copy operator - DoubleLinkedList<T>& operator= (const DoubleLinkedList<T>&); - - //! current list size - int size () const; - - /** \brief insert after an iterators position - * \return Iterator pointing to new element - */ - Iterator insert_after (Iterator i, T& t); - - /** \brief insert before an iterators position - * \return Iterator pointing to new element - */ - Iterator insert_before (Iterator i, T& t); - - //! remove selected element - void erase (Iterator i); - - private: - struct Element { // Typ fuer das Listenelement - Element* next; // Nachfolger - Element* prev; // Vorgaenger - T item; // Datum - Element (T &t); // setze next=prev=0 - }; - - Iterator head; // erstes Element der Liste - Iterator tail; // letztes Element der Liste - int numelements; // Anzahl Elemente in der Liste - } DUNE_DEPRECATED; - -} - -//! }@ - -#include "dlist.cc" - -#endif diff --git a/common/test/parsetest.cc b/common/test/parsetest.cc index be4babd21..ae749cd52 100644 --- a/common/test/parsetest.cc +++ b/common/test/parsetest.cc @@ -21,7 +21,6 @@ #include <dune/common/bitsetvector.hh> #include <dune/common/configparser.hh> #include <dune/common/debugstream.hh> -#include <dune/common/dlist.hh> #include <dune/common/enumset.hh> #include <dune/common/exceptions.hh> #include <dune/common/finitestack.hh> -- GitLab