#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". | |
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()); } }
|
inline |
Get the next object in the list. Check against GetTerminator() before deferencing the object.
|
inline |
Get the previous object in the list. Check against GetTerminator() before deferencing the object.
|
inline |
Get the terminator of the list. This should not be dereferenced as it is a pointer to b2TypedIntrusiveListNode<T> not T.