|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <rbtree.h>
Public Types | |
| typedef PtrRBNode | SelfType |
| typedef std::size_t | ValueType |
Public Member Functions | |
| void | init (ValueType value, SelfType *parentNode) |
| ValueType | getValue () const |
| SelfType ** | getChildren () |
| SelfType *const * | getChildren () const |
| SelfType * | getLeft () |
| const SelfType * | getLeft () const |
| void | setLeft (SelfType *left) |
| SelfType * | getRight () |
| const SelfType * | getRight () const |
| void | setRight (SelfType *right) |
| SelfType * | getParent () |
| const SelfType * | getParent () const |
| void | setParent (SelfType *parentNode) |
| void | addList (SelfType *other) |
| bool | hasList () const |
| bool | isInList () const |
| SelfType * | getNext () |
| const SelfType * | getNext () const |
| SelfType * | removeFromList () |
| void | unlinkFromList () |
| SelfType * | promoteFirstListNode () |
| bool | isRed () const |
| void | setRed (bool red) |
The node of RedBlackTree, which is stored in the memory being tracked.
The memory pool places this node at the start of a free chunk, so its layout must match the chunk header: the second word (m_size) is both the value of the node and the size field of the chunk. The memory must be at least sizeof(PtrRBNode) (7 words) large.
Nodes with the same value are kept in a doubly linked list (DLL) attached to the one node that is in the tree.
The type of this node.
| typedef std::size_t cookmem::PtrRBNode::ValueType |
The type of the value (the size of the memory).
Add a node of the same value to the DLL of this tree node.
A list node uses m_children[0] as the pointer to its previous node, which is either another list node or the tree node itself. List nodes do not use m_parent or m_children[1].
|
inline |
Get the left and right child pointers as an array.
Get the left and right child pointers as an array.
|
inline |
Get the left child, or the previous node for a list node.
Get the left child, or the previous node for a list node.
|
inline |
Get the next node in the DLL of nodes with the same value.
Get the next node in the DLL of nodes with the same value.
|
inline |
Get the parent node, or nullptr for the root.
Get the parent node, or nullptr for the root.
|
inline |
Get the right child.
|
inline |
Get the value of the node.
|
inline |
Check if this tree node has a DLL of nodes with the same value.
Initialize the node as a red leaf.
| value | the value of the node. |
| parentNode | the parent node, or nullptr for the root. |
|
inline |
Check if this node is in the DLL of a tree node, rather than being a node of the tree itself.
|
inline |
Check if the node is red.
|
inline |
Replace the tree node with the first node in its DLL. The first list node takes over the position, color and the rest of the list, so this takes constant time. The list must not be empty.
|
inline |
Remove the first node in the DLL of this tree node. The list must not be empty.
|
inline |
Unlink this list node from the DLL it is in.