130 the_last->next() = elem;
140 elem->next() = the_first;
150 if (after == the_last)
154 elem->next() = after->next();
155 after->next() = elem;
203 list.
the_last->next() = after->next();
204 after->next() = list.
first();
206 the_last = list.
last();
220 if (after->next() == last())
222 after->next() = after->next()->next();
227 void remove(
const T *elem)
231 if (elem == the_first)
233 the_first =
next(elem);
239 T *after = the_first;
240 for (; after != the_last; after = after->next())
241 if (after->next() == elem)
258 if (the_first != 0 && list.the_first != 0)
260 assert(find(list.first()));
261 assert(find(list.last()));
262 if (the_first == list.the_first)
264 if (the_last == list.the_last)
265 the_first = the_last = 0;
267 the_first = list.the_last->next();
271 T *after = the_first;
272 for (; after->next() != list.the_first; after = after->next())
274 if (the_last == list.the_last)
277 after->next() = list.the_last->next();
283 void clear(
bool pDestroyElements =
false)
285 if( pDestroyElements )
288 for( T* it = the_first; it; it = nextElement )
290 nextElement =
next(it);
296 the_first = the_last = 0;
326 return (elem == the_last) ? 0 : elem->
next();
336 for (num = 1; test != the_last; test = test->next())
350 for(test = the_first; test != 0; test =
next(test))
373 assert(part.
find(end));
374 part.
the_last =
const_cast<T*
>(end);
397 the_last =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_last) + delta);
398 the_first =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_first) + delta);
399 for (elem = first(); elem; elem =
next(elem))
401 elem->next() =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(elem->next()) + delta);
408 #ifdef ENABLE_CONSISTENCY_CHECKS 409 if (first() != 0 && last() == 0)
412 if (first() == 0 && last() != 0)
415 if (first() && find(last()) == 0)
432 IsList(T* pfirst = 0, T* plast = 0,
bool pDestroyElements =
false)
435 , destroyElements(pDestroyElements)
443 assert(isConsistent());
449 clear(destroyElements);
void clear(bool pDestroyElements=false)
removes all elements from an IsList.
T * first() const
returns the IsList's first element.
T * the_last
the last element in the IsList.
void move(ptrdiff_t delta)
adjusts list pointers to a new memory address.
Generic single linked list.Class IsList implements an intrusive single linked list of elements of a t...
T * last() const
returns the IsList's last element.
IsElement()
default constructor.
IsList(T *pfirst=0, T *plast=0, bool pDestroyElements=false)
default constructor.
bool destroyElements
should the destructor be called for each element when the list is destroyed?
DLPSV *& next()
Next SVectorBase.
int find(const T *elem) const
returns the position of element elem within IsList.
void insert(IsList< T > &list, T *after)
inserts all elements of list after element after of an IsList.
void prepend(IsList< T > &list)
prepends all elements of list to IsList.
void remove_next(T *after)
removes the successor of after from an IsList.
Everything should be within this namespace.
IsElement< T > * the_next
pointer to next element in the IsList.
T * next(const T *elem) const
returns successor of elem in an IsList.
void prepend(T *elem)
prepends elem to IsList.
void insert(T *elem, T *after)
inserts elem to IsList after its element after.
IsElement(const IsElement< T > &old)
copy constructor.
void append(T *elem)
appends elem to IsList.
int length() const
returns the number of elements in IsList.
T * the_first
the first element in the IsList.
void append(IsList< T > &list)
appends all elements of list to IsList.
#define MSGinconsistent(name)
IsList< T > sublist(const T *start=0, const T *end=0) const
constructs sublist of an IsList.
IsElement< T > * next() const
returns the next element in the IsList.
bool isConsistent() const
consistency check.
void spx_free(T &p)
Release memory.
Elements for IsLists.Class IsElement allows to easily construct list elements for an intrusive single...