/usr/include/dune/grid/onedgrid/onedgridlist.hh is in libdune-grid-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | #ifndef DUNE_ONEDGRID_LIST_HH
#define DUNE_ONEDGRID_LIST_HH
#include <dune/common/deprecated.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/iteratorfacades.hh>
namespace Dune {
/** \file
\brief A simple doubly-linked list needed in OneDGrid
\todo I'd love to get rid of this and use std::list instead.
Unfortunately, there are problems. I need to store pointers/iterators
within one element which point to another element (e.g. the element father).
*/
template<class T>
class OneDGridListIterator
: public BidirectionalIteratorFacade<OneDGridListIterator<T>,T>
{
public:
bool equals(const OneDGridListIterator& other) const {
return pointer_ == other.pointer_;
}
T& dereference() {
return *pointer_;
}
void increment() {
pointer_ = pointer_->succ_;
}
void decrement() {
pointer_ = pointer_->pred_;
}
OneDGridListIterator() {}
OneDGridListIterator(T* pointer) {
pointer_ = pointer;
}
OneDGridListIterator operator=(T* pointer) {
pointer_ = pointer;
}
operator T*() {return pointer_;}
private:
T* pointer_;
};
template<class T>
class OneDGridList
{
public:
//typedef OneDGridListIterator<T> iterator;
typedef T* iterator;
typedef const T* const_iterator;
OneDGridList() : numelements(0), begin_(0), rbegin_(0) {}
#if 0
~OneDGridList() {
// Delete all elements
iterator e = begin();
while (e) {
iterator eSucc = e->succ_;
erase(e);
e = eSucc;
return;
}
}
#endif
int size() const {return numelements;}
iterator push_back (const T& value) {
T* i = rbegin();
// New list element by copy construction
T* t = new T(value);
// einfuegen
if (begin_==0) {
// einfuegen in leere Liste
begin_ = t;
rbegin_ = t;
}
else
{
// nach Element i.p einsetzen
t->pred_ = i;
t->succ_ = i->succ_;
i->succ_ = t;
if (t->succ_!=0)
t->succ_->pred_ = t;
// tail neu ?
if (rbegin_==i)
rbegin_ = t;
}
// Groesse und Rueckgabeiterator
numelements = numelements+1;
return t;
}
iterator insert (iterator i, const T& value) {
// Insert before 'one-after-the-end' --> append to the list
if (i==end())
return push_back(value);
// New list element by copy construction
T* t = new T(value);
// einfuegen
if (begin_==0)
{
// einfuegen in leere Liste
begin_=t;
rbegin_=t;
}
else
{
// vor Element i.p einsetzen
t->succ_ = i;
t->pred_ = i->pred_;
i->pred_ = t;
if (t->pred_!=0)
t->pred_->succ_ = t;
// head neu ?
if (begin_==i)
begin_ = t;
}
// Groesse und Rueckgabeiterator
numelements = numelements+1;
return t;
}
void erase (iterator& i)
{
// Teste Eingabe
if (i==0)
return;
// Ausfaedeln
if (i->succ_!=0)
i->succ_->pred_ = i->pred_;
if (i->pred_!=0)
i->pred_->succ_ = i->succ_;
// head & tail
if (begin_==i)
begin_=i->succ_;
if (rbegin_==i)
rbegin_ = i->pred_;
// Groesse
numelements = numelements-1;
// Actually delete the object
delete(i);
}
iterator begin() {
return begin_;
}
const_iterator begin() const {
return begin_;
}
iterator end() {
return NULL;
}
const_iterator end() const {
return NULL;
}
iterator rbegin() {
return rbegin_;
}
const_iterator rbegin() const {
return rbegin_;
}
private:
int numelements;
T* begin_;
T* rbegin_;
}; // end class OneDGridList
} // namespace Dune
#endif
|