130 the_last->next() = elem;
141 elem->next() = the_first;
153 if(after == the_last)
157 elem->next() = after->next();
158 after->next() = elem;
207 list.
the_last->next() = after->next();
208 after->next() = list.
first();
211 the_last = list.
last();
226 if(after->next() == last())
229 after->next() = after->next()->next();
234 void remove(
const T* elem)
238 if(elem == the_first)
240 the_first =
next(elem);
247 T* after = the_first;
249 for(; after != the_last; after = after->next())
250 if(after->next() == elem)
267 if(the_first != 0 && list.the_first != 0)
269 assert(find(list.first()));
270 assert(find(list.last()));
272 if(the_first == list.the_first)
274 if(the_last == list.the_last)
275 the_first = the_last = 0;
277 the_first = list.the_last->next();
281 T* after = the_first;
283 for(; after->next() != list.the_first; after = after->next())
286 if(the_last == list.the_last)
289 after->next() = list.the_last->next();
295 void clear(
bool pDestroyElements =
false)
301 for(T* it = the_first; it; it = nextElement)
303 nextElement =
next(it);
309 the_first = the_last = 0;
339 return (elem == the_last) ? 0 : elem->
next();
351 for(num = 1; test != the_last; test = test->next())
367 for(test = the_first; test != 0; test =
next(test))
392 assert(part.
find(end));
393 part.
the_last =
const_cast<T*
>(end);
417 the_last =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_last) + delta);
418 the_first =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_first) + delta);
420 for(elem = first(); elem; elem =
next(elem))
422 elem->next() =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(elem->next()) + delta);
429 #ifdef ENABLE_CONSISTENCY_CHECKS 431 if(first() != 0 && last() == 0)
434 if(first() == 0 && last() != 0)
437 if(first() && find(last()) == 0)
455 IsList(T* pfirst = 0, T* plast = 0,
bool pDestroyElements =
false)
458 , destroyElements(pDestroyElements)
466 assert(isConsistent());
472 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...