LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
b2TypedIntrusiveListNode< T > Class Template Reference

#include <b2IntrusiveList.h>

Public Member Functions

void InsertAfter (T *const obj)
 Insert this object after the specified object.
 
void InsertBefore (T *const obj)
 Insert this object before the specified object.
 
T * GetNext () const
 
T * GetPrevious () const
 
T * GetTerminator () const
 
T * Remove ()
 Remove this object from the list it's currently in.
 
bool InList () const
 Determine whether this object is in a list.
 
bool IsEmpty () const
 
uint32 GetLength () const
 Calculate the length of the list.
 
 B2_INTRUSIVE_LIST_GET_NODE (m_node)
 

Static Public Member Functions

static T * GetInstanceFromListNode (b2IntrusiveListNode *const node)
 Get a pointer to the instance of T that contains "node".
 

Detailed Description

template<typename T>
class b2TypedIntrusiveListNode< T >

b2TypedIntrusiveListNode which supports inserting an object into a single doubly linked list. For objects that need to be inserted in multiple doubly linked lists, use b2IntrusiveListNode.

For example:

class IntegerItem : public b2TypedIntrusiveListNode<IntegerItem> { public: IntegerItem(int32 value) : m_value(value) { } ~IntegerItem() { } int32 GetValue() const { return m_value; } private: int32 m_value; };

int main(int argc, const char <em>arvg[]) { b2TypedIntrusiveListNode<IntegerItem> list; IntegerItem a(1); IntegerItem b(2); IntegerItem c(3); list.InsertBefore(&a); list.InsertBefore(&b); list.InsertBefore(&c); for (IntegerItem item = list.GetNext(); item != list.GetTerminator(); item = item->GetNext()) { printf("%d\n", item->GetValue()); } }

Member Function Documentation

template<typename T>
T* b2TypedIntrusiveListNode< T >::GetNext ( ) const
inline

Get the next object in the list. Check against GetTerminator() before deferencing the object.

template<typename T>
T* b2TypedIntrusiveListNode< T >::GetPrevious ( ) const
inline

Get the previous object in the list. Check against GetTerminator() before deferencing the object.

template<typename T>
T* b2TypedIntrusiveListNode< T >::GetTerminator ( ) const
inline

Get the terminator of the list. This should not be dereferenced as it is a pointer to b2TypedIntrusiveListNode<T> not T.


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