Generic single linked list.Class IsList implements an intrusive single linked list of elements of a template class T. As an intrusive list, the objects of type T must provide methods next() for setting and inquiring a pointer to the next element in a list. The user is responsible for not modifying the next() pointer of elements currently residing in a list, which may destroy the lists integrity. For this, class IsList provides enough methods for modifying a list in a save way. See the method list for a description. More...
#include <islist.h>
Public Types | |
typedef IsElement< T > | Element |
Public Member Functions | |
Extension | |
void | append (T *elem) |
appends elem to IsList. More... | |
void | prepend (T *elem) |
prepends elem to IsList. More... | |
void | insert (T *elem, T *after) |
inserts elem to IsList after its element after . More... | |
void | append (IsList< T > &list) |
appends all elements of list to IsList. More... | |
void | prepend (IsList< T > &list) |
prepends all elements of list to IsList. More... | |
void | insert (IsList< T > &list, T *after) |
inserts all elements of list after element after of an IsList. More... | |
Removal | |
void | remove_next (T *after) |
removes the successor of after from an IsList. More... | |
void | remove (const T *elem) |
removes element elem from an IsList. More... | |
void | remove (IsList< T > &list) |
removes all elements of list from an IsList. More... | |
void | clear (bool pDestroyElements=false) |
removes all elements from an IsList. More... | |
Access | |
T * | first () const |
returns the IsList's first element. More... | |
T * | last () const |
returns the IsList's last element. More... | |
T * | next (const T *elem) const |
returns successor of elem in an IsList. More... | |
int | length () const |
returns the number of elements in IsList. More... | |
int | find (const T *elem) const |
returns the position of element elem within IsList. More... | |
IsList< T > | sublist (const T *start=0, const T *end=0) const |
constructs sublist of an IsList. More... | |
Miscellaneous | |
void | move (ptrdiff_t delta) |
adjusts list pointers to a new memory address. More... | |
bool | isConsistent () const |
consistency check. More... | |
Constructors / Destructors | |
IsList (T *pfirst=0, T *plast=0, bool pDestroyElements=false) | |
default constructor. More... | |
~IsList () | |
destructor More... | |
Protected Attributes | |
T * | the_first |
the first element in the IsList. More... | |
T * | the_last |
the last element in the IsList. More... | |
bool | destroyElements |
should the destructor be called for each element when the list is destroyed? More... | |
Generic single linked list.
Class IsList implements an intrusive single linked list of elements of a template class T. As an intrusive list, the objects of type T must provide methods next() for setting and inquiring a pointer to the next element in a list. The user is responsible for not modifying the next() pointer of elements currently residing in a list, which may destroy the lists integrity. For this, class IsList provides enough methods for modifying a list in a save way. See the method list for a description.
|
explicit |
void append | ( | IsList< T > & | list | ) |
appends all elements of list
to IsList.
Appending one list to another keeps the appended list
. Instead, list
remains an own IsList which is then part of the concatenated list. This means that modifying list
will modify the concateneted list as well and vice versa. The programmer is responsible for such changes not to yield inconsistent lists.
void clear | ( | bool | pDestroyElements = false | ) |
removes all elements from an IsList.
Definition at line 295 of file islist.h.
Referenced by SVSetBase< Rational >::clear().
int find | ( | const T * | elem | ) | const |
returns the position of element elem
within IsList.
Definition at line 361 of file islist.h.
Referenced by IsList< soplex::SVSetBase::DLPSV >::sublist().
T* first | ( | ) | const |
returns the IsList's first element.
Definition at line 317 of file islist.h.
Referenced by IsList< soplex::SVSetBase::DLPSV >::insert().
void insert | ( | T * | elem, |
T * | after | ||
) |
void insert | ( | IsList< T > & | list, |
T * | after | ||
) |
inserts all elements of list
after element after
of an IsList.
Inserting one list into another keeps the appended list
. Instead, list
remains an own IsList which is then part of the concatenated list. This means that modifying list
will modify the concateneted list as well and vice versa. The programmer is responsible for such changes not to yield inconsistent lists.
bool isConsistent | ( | ) | const |
consistency check.
Definition at line 427 of file islist.h.
Referenced by IdList< soplex::SVSetBase::DLPSV >::isConsistent().
T* last | ( | ) | const |
returns the IsList's last element.
Definition at line 323 of file islist.h.
Referenced by IsList< soplex::SVSetBase::DLPSV >::insert().
int length | ( | ) | const |
void move | ( | ptrdiff_t | delta | ) |
adjusts list pointers to a new memory address.
This method is of a rather technical nature. If all list elements are taken form one array of elements, in certain circumstances the user may be forced to realloc this array. As a consequence all next() pointers of the list elements would become invalid. However, all addresses will be changed by a constant offset delta
. Then move( delta
) may be called, which adjusts the next() pointers of all elements in the list.
Definition at line 412 of file islist.h.
Referenced by IdList< soplex::SVSetBase::DLPSV >::move().
T* next | ( | const T * | elem | ) | const |
returns successor of elem
in an IsList.
The successor of elem
in a list generally corresponds to the element returned by elem->next(). However, if elem
is the last element in an IsList, this method will return 0, whereas elem->next() may yield an arbitrary value. For example, if the current list is actually a sublist of another, larger IsList, elem->next() returns the successor of elem
in this larger IsList.
void prepend | ( | IsList< T > & | list | ) |
prepends all elements of list
to IsList.
Appending one list to another keeps the appended list
. Instead, list
remains an own IsList which is then part of the concatenated list. This means that modifying list
will modify the concateneted list as well and vice versa. The programmer is responsible for such changes not to yield inconsistent lists.
void remove | ( | const T * | elem | ) |
void remove | ( | IsList< T > & | list | ) |
void remove_next | ( | T * | after | ) |
IsList<T> sublist | ( | const T * | start = 0 , |
const T * | end = 0 |
||
) | const |
|
protected |
|
protected |
the first element in the IsList.
Definition at line 115 of file islist.h.
Referenced by IsList< soplex::SVSetBase::DLPSV >::append(), IsList< soplex::SVSetBase::DLPSV >::insert(), IsList< soplex::SVSetBase::DLPSV >::prepend(), IdList< soplex::SVSetBase::DLPSV >::prepend(), and IsList< soplex::SVSetBase::DLPSV >::sublist().
|
protected |
the last element in the IsList.
Definition at line 116 of file islist.h.
Referenced by IsList< soplex::SVSetBase::DLPSV >::append(), IsList< soplex::SVSetBase::DLPSV >::insert(), IsList< soplex::SVSetBase::DLPSV >::prepend(), and IsList< soplex::SVSetBase::DLPSV >::sublist().