166 elem->next() = after->next();
167 after->next() = elem;
216 list.
the_last->next() = after->next();
217 after->next() = list.
first();
235 if(after->next() ==
last())
238 after->next() = after->next()->next();
258 for(; after !=
the_last; after = after->next())
259 if(after->next() == elem)
292 for(; after->next() != list.
the_first; after = after->next())
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);
348 return (elem ==
the_last) ? nullptr : elem->next();
360 for(num = 1; test !=
the_last; test = test->next())
374 assert(elem !=
nullptr);
401 assert(part.
find(end));
402 part.
the_last =
const_cast<T*
>(end);
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() !=
nullptr &&
last() ==
nullptr)
443 if(
first() ==
nullptr &&
last() !=
nullptr)
464 IsList(T* pfirst =
nullptr, T* plast =
nullptr,
bool pDestroyElements =
false)
471 assert(plast !=
nullptr);
IsElement()
default constructor.
IsElement< T > * the_next
pointer to next element in the IsList.
IsElement(const IsElement< T > &old)
copy constructor.
IsElement< T > * next() const
returns the next element in the IsList.
Generic single linked list.
void append(IsList< T > &list)
appends all elements of list to IsList.
T * last() const
returns the IsList's last element.
IsList< T > & operator=(const IsList< T > &old)=delete
IsList(const IsList< T > &)=delete
Assignment operator and copy constructor should be deleted to avoid memory problems.
T * first() const
returns the IsList's first element.
bool isConsistent() const
consistency check.
void remove(const T *elem)
removes element elem from an IsList.
T * the_last
the last element in the IsList.
IsList< T > sublist(const T *start=nullptr, const T *end=nullptr) const
constructs sublist of an IsList.
void insert(T *elem, T *after)
inserts elem to IsList after its element after.
void append(T *elem)
appends elem to IsList.
T * the_first
the first element in the IsList.
void clear(bool pDestroyElements=false)
removes all elements from an IsList.
void prepend(IsList< T > &list)
prepends all elements of list to IsList.
int length() const
returns the number of elements in IsList.
void remove_next(T *after)
removes the successor of after from an IsList.
IsList(T *pfirst=nullptr, T *plast=nullptr, bool pDestroyElements=false)
default constructor.
void remove(IsList< T > &list)
removes all elements of list from an IsList.
void prepend(T *elem)
prepends elem to IsList.
T * next(const T *elem) const
returns successor of elem in an IsList.
int find(const T *elem) const
returns the position of element elem within IsList.
void move(ptrdiff_t delta)
adjusts list pointers to a new memory address.
bool destroyElements
should the destructor be called for each element when the list is destroyed?
void insert(IsList< T > &list, T *after)
inserts all elements of list after element after of an IsList.
Everything should be within this namespace.
void spx_free(T &p)
Release memory.
#define SPX_MSG_INCONSISTENT(name)