LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
b2IntrusiveListNode Class Reference

#include <b2IntrusiveList.h>

Public Member Functions

 b2IntrusiveListNode ()
 Initialize the node.
 
 ~b2IntrusiveListNode ()
 If the node is in a list, remove it from the list.
 
void InsertAfter (b2IntrusiveListNode *const node)
 Insert this node after the specified node.
 
void InsertBefore (b2IntrusiveListNode *const node)
 Insert this node before the specified node.
 
const b2IntrusiveListNode * GetTerminator () const
 Get the terminator of the list.
 
b2IntrusiveListNode * Remove ()
 Remove this node from the list it's currently in.
 
bool IsEmpty () const
 Determine whether this list is empty or the node isn't in a list.
 
bool InList () const
 Determine whether this node is in a list or the list contains nodes.
 
uint32 GetLength () const
 Calculate the length of the list.
 
b2IntrusiveListNode * GetNext () const
 Get the next node in the list.
 
b2IntrusiveListNode * GetPrevious () const
 Get the previous node in the list.
 
bool ValidateList () const
 
bool FindNodeInList (b2IntrusiveListNode *const nodeToFind) const
 Determine whether the specified node is present in this list.
 

Detailed Description

b2IntrusiveListNode is used to implement an intrusive doubly-linked list.

For example:

class MyClass { public: MyClass(const char <em>msg) : m_msg(msg) {} const char GetMessage() const { return m_msg; } B2_INTRUSIVE_LIST_GET_NODE(m_node); B2_INTRUSIVE_LIST_NODE_GET_CLASS(MyClass, m_node); private: b2IntrusiveListNode m_node; const char *m_msg; };

int main(int argc, char <em>argv[]) { b2IntrusiveListNode list; // NOTE: type is NOT MyClass MyClass a("this"); MyClass b("is"); MyClass c("a"); MyClass d("test"); list.InsertBefore(a.GetListNode()); list.InsertBefore(b.GetListNode()); list.InsertBefore(c.GetListNode()); list.InsertBefore(d.GetListNode()); for (b2IntrusiveListNode node = list.GetNext(); node != list.GetTerminator(); node = node->GetNext()) { MyClass *cls = MyClass::GetInstanceFromListNode(node); printf("%s\n", cls->GetMessage()); } return 0; }

Member Function Documentation

bool b2IntrusiveListNode::ValidateList ( ) const
inline

If B2_INTRUSIVE_LIST_VALIDATE is 1 perform a very rough validation of all nodes in the list.


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