SoPlex
|
Generic Real linked list. More...
#include <idlist.h>
Public Member Functions | |
Access | |
T * | first () const |
returns first element in list. | |
T * | last () const |
returns last element in list. | |
T * | next (const T *elem) const |
returns successor of elem or nullptr, if elem is the last element. | |
T * | prev (const T *elem) const |
returns predecessor of elem or nullptr, if elem is the first element. | |
Extension | |
void | append (T *elem) |
appends elem to end of list. | |
void | prepend (T *elem) |
prepends elem at beginnig of list. | |
void | insert (T *elem, T *after) |
inserts elem after after . | |
void | append (IdList< T > &list) |
appends list to end of list. | |
void | prepend (IdList< T > &list) |
prepends list at beginnig of list. | |
void | insert (IdList< T > &list, T *after) |
inserts list after after . | |
Removal | |
void | remove_next (T *after) |
removes element following after . | |
void | remove (T *elem) |
removes elem from list. | |
void | remove (IdList< T > &list) |
removes sublist list . | |
Miscellaneous | |
void | move (ptrdiff_t delta) |
adjusts list pointers to a new memory address. | |
bool | isConsistent () const |
consistency check. | |
Constructors / Destructors | |
IdList (T *pfirst=nullptr, T *plast=nullptr, bool pDestroyElements=false) | |
default constructor. | |
![]() | |
void | append (T *elem) |
appends elem to IsList. | |
void | prepend (T *elem) |
prepends elem to IsList. | |
void | insert (T *elem, T *after) |
inserts elem to IsList after its element after . | |
void | append (IsList< T > &list) |
appends all elements of list to IsList. | |
void | prepend (IsList< T > &list) |
prepends all elements of list to IsList. | |
void | insert (IsList< T > &list, T *after) |
inserts all elements of list after element after of an IsList. | |
void | remove_next (T *after) |
removes the successor of after from an IsList. | |
void | remove (const T *elem) |
removes element elem from an IsList. | |
void | remove (IsList< T > &list) |
removes all elements of list from an IsList. | |
void | clear (bool pDestroyElements=false) |
removes all elements from an IsList. | |
T * | first () const |
returns the IsList's first element. | |
T * | last () const |
returns the IsList's last element. | |
T * | next (const T *elem) const |
returns successor of elem in an IsList. | |
int | length () const |
returns the number of elements in IsList. | |
int | find (const T *elem) const |
returns the position of element elem within IsList. | |
IsList< T > | sublist (const T *start=nullptr, const T *end=nullptr) const |
constructs sublist of an IsList. | |
void | move (ptrdiff_t delta) |
adjusts list pointers to a new memory address. | |
bool | isConsistent () const |
consistency check. | |
IsList (T *pfirst=nullptr, T *plast=nullptr, bool pDestroyElements=false) | |
default constructor. | |
IsList (const IsList< T > &)=delete | |
Assignment operator and copy constructor should be deleted to avoid memory problems. | |
IsList< T > & | operator= (const IsList< T > &old)=delete |
~IsList () | |
destructor | |
Additional Inherited Members | |
![]() | |
typedef IsElement< T > | Element |
![]() | |
T * | the_first |
the first element in the IsList. | |
T * | the_last |
the last element in the IsList. | |
bool | destroyElements |
should the destructor be called for each element when the list is destroyed? | |
Generic Real linked list.
Class IdList implements an intrusive Real linked list as a template class. As such, the list elements must provide the links themselfs. For conveniance, we also provide class IdElement that adds both links to an arbitrary class as template parameter.
|
explicit |
default constructor.
The default constructor may also be used to construct a sublist, by providing a first
and a last
element. Element last
must be a successor of first
.
Definition at line 365 of file idlist.h.
References isConsistent(), and IsList< T >::IsList().
void append | ( | IdList< T > & | list | ) |
void append | ( | T * | elem | ) |
appends elem
to end of list.
Definition at line 169 of file idlist.h.
References last(), IsList< T >::the_first, and IsList< T >::the_last.
T * first | ( | ) | const |
void insert | ( | IdList< T > & | list, |
T * | after ) |
inserts list
after after
.
Definition at line 232 of file idlist.h.
References IsList< T >::find(), first(), IdList(), last(), and IsList< T >::the_last.
void insert | ( | T * | elem, |
T * | after ) |
inserts elem
after after
.
Definition at line 197 of file idlist.h.
References append(), IsList< T >::find(), and last().
bool isConsistent | ( | ) | const |
consistency check.
Definition at line 334 of file idlist.h.
References first(), IsList< T >::isConsistent(), last(), next(), and SPX_MSG_INCONSISTENT.
Referenced by IdList().
T * last | ( | ) | const |
void move | ( | ptrdiff_t | delta | ) |
adjusts list pointers to a new memory address.
When all elements have been moved in memory (e.g. because of reallocation) with a fixed offset delta
, the list will be reset to the new adresses.
Definition at line 319 of file idlist.h.
References first(), last(), IsList< T >::move(), prev(), and IsList< T >::the_first.
T * next | ( | const T * | elem | ) | const |
returns successor of elem
or nullptr, if elem
is the last element.
Definition at line 152 of file idlist.h.
References last().
Referenced by isConsistent(), remove(), and remove_next().
void prepend | ( | IdList< T > & | list | ) |
void prepend | ( | T * | elem | ) |
prepends elem
at beginnig of list.
Definition at line 183 of file idlist.h.
References first(), IsList< T >::the_first, and IsList< T >::the_last.
Referenced by prepend().
T * prev | ( | const T * | elem | ) | const |
void remove | ( | IdList< T > & | list | ) |
removes sublist list
.
Definition at line 279 of file idlist.h.
References IsList< T >::find(), first(), IdList(), last(), IsList< T >::the_first, and IsList< T >::the_last.
void remove | ( | T * | elem | ) |
removes elem
from list.
Definition at line 260 of file idlist.h.
References first(), last(), next(), IsList< T >::the_first, and IsList< T >::the_last.
Referenced by remove_next().