|
libcsdbg
1.28
C++ exception (and generic) stack trace debug library
|
Lightweight, templated, doubly-linked list (using XOR linking) More...
#include <chain.hpp>
Inheritance diagram for csdbg::chain< T >:
Collaboration diagram for csdbg::chain< T >:Public Member Functions | |
| chain () | |
| Object default constructor. More... | |
| chain (const chain &) | |
| Object copy constructor. More... | |
| virtual | ~chain () |
| Object destructor. More... | |
| virtual chain * | clone () const |
| Object virtual copy constructor. More... | |
| virtual u32 | size () const |
| Get the chain size (node count) More... | |
| virtual chain & | operator= (const chain &) |
| Assignment operator. More... | |
| virtual T * | operator[] (u32) const |
| Subscript operator. More... | |
| virtual chain & | add (T *) |
| Add a node to the chain. More... | |
| virtual chain & | remove (u32) |
| Dispose the node (and its data) at a chain offset. More... | |
| virtual chain & | clear () |
| Empty the chain. More... | |
| virtual T * | at (u32) const |
| Get the node data pointer at a chain offset. More... | |
| virtual T * | detach (u32) |
| Detach the node at a chain offset. More... | |
| virtual chain & | foreach (void(*)(u32, T *)) const |
| Traverse the chain with a callback for each node. More... | |
Public Member Functions inherited from csdbg::object | |
| virtual | ~object ()=0 |
| To be implemented. More... | |
| virtual const i8 * | class_name () const |
| Query the class name of an object descending from csdbg::object. More... | |
Protected Member Functions | |
| virtual node< T > * | node_at (u32) const |
| Get the node at a chain offset. More... | |
| virtual node< T > * | node_with (const T *) const |
| Get the node with m_data == d. More... | |
| virtual node< T > * | detach_node (u32) |
| Detach the node at a chain offset. More... | |
Protected Attributes | |
| node< T > * | m_head |
| Chain head. More... | |
| node< T > * | m_tail |
| Chain tail. More... | |
| u32 | m_size |
| Node count. More... | |
Lightweight, templated, doubly-linked list (using XOR linking)
A doubly-linked list is a great optimization compared with a singly-linked one in node access times and memory references, especially in very big lists. The XOR linking implementation, although a bit more complex, uses the same ammount of memory (per node) as a singly-linked list. The chain supports shared data (multiple chains can point to the same data) but it's not thread safe, callers should synchronize thread access. This implementation does not allow a node with a NULL or a duplicate data pointer. A node can be detached (dispose the node without deleting its data) or removed (dispose both node and data). A chain can be traversed using simple callbacks and method chain::foreach