Fennel: IntrusiveList< T, DerivedListNode > Class Template Reference (original) (raw)

IntrusiveList is a singly-linked list which requires its elements to derive from IntrusiveListNode (endowing them with the required forward links). More...

#include <[IntrusiveList.h](IntrusiveList%5F8h-source.html)>

Inheritance diagram for IntrusiveList< T, DerivedListNode >:

List of all members.

Public Member Functions
void push_front (T &element)
Adds an element to the front of the list.
void push_back (T &element)
Adds an element to the back of the list.
T & front () const
**Returns:**a reference to the element at the front of the list
T & back () const
**Returns:**a reference to the element at the back of the list
bool remove (T &element)
Finds and removes a specified element by address (not equality).
uint size () const
**Returns:**length of this list
bool empty () const
**Returns:**true iff size() is zero
void clear (bool debugClear=true)
Truncates this list to zero nodes.
Protected Member Functions
void push_front (IntrusiveListNode &t)
void push_back (IntrusiveListNode &t)
bool remove (IntrusiveListNode &)
Protected Attributes
uint nNodes
Number of nodes in this list.
IntrusiveListNode * pFront
First node in this list.
IntrusiveListNode * pBack
Last node in this list.
Private Types
typedef RawIntrusiveList super

Detailed Description

template<class T, class DerivedListNode = IntrusiveListNode>

class IntrusiveList< T, DerivedListNode >

IntrusiveList is a singly-linked list which requires its elements to derive from IntrusiveListNode (endowing them with the required forward links).

This eliminates the need for dynamic allocation, which is important for some performance-critical uses. It is possible for elements to be members of multiple IntrusiveLists simultaneously; however, this requires that they derive from IntrusiveListNode multiple times (one for each link). Template parameter T is the datatype of the element stored; template parameter DerivedListNode is a class derived from IntrusiveListNode where T inherits from DerivedListNode. If T participates in only one IntrusiveList, then it can derive from IntrusiveListNode directly, and the default value for DerivedListNode can be used. Otherwise, one derivation of IntrusiveListNode per link should be defined (with an appropriate name to spell out its purpose) and specified as the DerivedListNode parameter.

Although method names have been chosen to match STL conventions, IntrusiveList is not a true STL container (likewise, IntrusiveListIter is not a true STL iterator).

Definition at line 53 of file IntrusiveList.h.


Member Typedef Documentation

template<class T, class DerivedListNode = IntrusiveListNode>


Member Function Documentation

template<class T, class DerivedListNode = IntrusiveListNode>

void IntrusiveList< T, DerivedListNode >::push_front ( T & element ) [inline]

template<class T, class DerivedListNode = IntrusiveListNode>

void IntrusiveList< T, DerivedListNode >::push_back ( T & element ) [inline]

template<class T, class DerivedListNode = IntrusiveListNode>

| T& IntrusiveList< T, DerivedListNode >::front | ( | | ) | const [inline] | | ------------------------------------------------------------------------ | - | | - | ---------------- |

template<class T, class DerivedListNode = IntrusiveListNode>

| T& IntrusiveList< T, DerivedListNode >::back | ( | | ) | const [inline] | | ----------------------------------------------------------------------- | - | | - | ---------------- |

template<class T, class DerivedListNode = IntrusiveListNode>

bool IntrusiveList< T, DerivedListNode >::remove ( T & element ) [inline]

Finds and removes a specified element by address (not equality).

Parameters:

element the element to be removed

Returns:

true if found

Definition at line 103 of file IntrusiveList.h.

References RawIntrusiveList::remove().

00104 { 00105 return super::remove( 00106 static_cast<DerivedListNode &>(element)); 00107 }

| uint RawIntrusiveList::size | ( | | ) | const [inline, inherited] | | ---------------------------------------------------------------------------------------- | - | | - | --------------------------- |

| bool RawIntrusiveList::empty | ( | | ) | const [inline, inherited] | | ---------------------------- | - | | - | --------------------------- |

void RawIntrusiveList::clear ( bool debugClear = true ) [inherited]

Member Data Documentation


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


Generated on Mon Jun 22 04:00:33 2009 for Fennel by doxygen 1.5.1