139 the_last->next() = elem;
150 elem->next() = the_first;
162 if(after == the_last)
166 elem->next() = after->next();
167 after->next() = elem;
216 list.
the_last->next() = after->next();
217 after->next() = list.
first();
220 the_last = list.
last();
235 if(after->next() == last())
238 after->next() = after->next()->next();
243 void remove(
const T* elem)
247 if(elem == the_first)
249 the_first =
next(elem);
256 T* after = the_first;
258 for(; after != the_last; after = after->next())
259 if(after->next() == elem)
276 if(the_first != 0 && list.the_first != 0)
278 assert(
find(list.first()));
279 assert(
find(list.last()));
281 if(the_first == list.the_first)
283 if(the_last == list.the_last)
284 the_first = the_last = 0;
286 the_first = list.the_last->next();
290 T* after = the_first;
292 for(; after->next() != list.the_first; after = after->next())
295 if(the_last == list.the_last)
298 after->next() = list.the_last->next();
304 void clear(
bool pDestroyElements =
false)
310 for(T* it = the_first; it; it = nextElement)
312 nextElement =
next(it);
318 the_first = the_last = 0;
348 return (elem == the_last) ? 0 : elem->
next();
360 for(num = 1; test != the_last; test = test->next())
376 for(test = the_first; test != 0; test =
next(test))
401 assert(part.
find(end));
402 part.
the_last =
const_cast<T*
>(end);
426 the_last =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_last) + delta);
427 the_first =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(the_first) + delta);
429 for(elem = first(); elem; elem =
next(elem))
431 elem->next() =
reinterpret_cast<T*
>(
reinterpret_cast<char*
>(elem->next()) + delta);
438 #ifdef ENABLE_CONSISTENCY_CHECKS 440 if(first() != 0 && last() == 0)
443 if(first() == 0 && last() != 0)
446 if(first() &&
find(last()) == 0)
464 IsList(T* pfirst = 0, T* plast = 0,
bool pDestroyElements =
false)
467 , destroyElements(pDestroyElements)
475 assert(isConsistent());
485 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.
#define SPX_MSG_INCONSISTENT(name)
void move(ptrdiff_t delta)
adjusts list pointers to a new memory address.
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
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.
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...