libbbb  1.2.1
Groups common code used in some applications and libraries.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
List2De Class Reference

class representing the list element in a linked list system More...

#include <list2d.h>

+ Inheritance diagram for List2De:

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
 
List2Denext (void) const
 return next item
 
List2Deprev (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 List2Deit_N
 pointer to next element in list
 
class List2Deit_P
 pointer to previous element in list
 

Friends

class List2Dh
 

Detailed Description

class representing the list element in a linked list system

Overview

These lists are simple chains of objects. Each list must have:

  • a header (List2Dh) that holds a pointer to the first item
  • a number of 0 or more items that inherit from List2De (holding only a forward and a backward pointer)

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.

Creation and destruction. Extracting from chain.

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.

Retrieveing data from it

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.

Supporting siblings

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.


The documentation for this class was generated from the following files: