class representing the list element in a linked list system More...
#include <list2d.h>
Public Member Functions | |
List2De () | |
constructor; creates a simple, hanging element | |
List2De (List2Dh *p_father) | |
constructor; appends this item to the chain managed by p_father | |
List2De * | next (void) const |
return next item | |
List2De * | prev (void) const |
return previous item | |
int | index (const List2Dh *p_father) const |
gets the index of a particular item inside the father | |
void | insAfter (List2Dh *p_father, class List2De *pNew) |
insert an item after this item | |
void | insBefore (List2Dh *p_father, class List2De *pNew) |
insert an item before this item | |
void | extract (List2Dh *p_father) |
extract this item from the chain | |
void | dbgDump (void) const |
print the content of this object to debug output | |
Protected Member Functions | |
void | setNext (class List2De *p_new) |
change internal next behind its back | |
void | setPrev (class List2De *p_new) |
change internal previous behind its back | |
Protected Attributes | |
class List2De * | it_N |
pointer to next element in list | |
class List2De * | it_P |
pointer to previous element in list | |
Friends | |
class | List2Dh |
class representing the list element in a linked list system
These lists are simple chains of objects. Each list must have:
The items that inherit from this class are assumed to ne allocated using new() c++ operator as they will be delete-d by some functions in List2Dh.
The constructor for this class either initialises the internal values to a default, non-valid state or it appends this item to the chain indicated by the header. As the item stores no dynamic content, the destructor does nothing. Especially, as there is no pointer to the father stored, it does NOT extract the item from the chain. To extract() an item from it's chain, the caller needs to know the pointer to List2Dh that hosts this item.
The item only stores pointers to prev()-ious and to next() items. Both of these functions return NULL if the item is first / last in the chain. One may also find the index() of this item inside the chain that hosts it presuming that it knows the pointer to List2Dh.
Insertion of an item just before or after current one is very fast and is supported by insBefore() and insAfter(). The caller must provide, along with the pointer to the item to insert, a pointer to parent List2Dh instance.