|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <rbtree.h>
Public Types | |
| typedef Node | NodeType |
| typedef NodeType::ValueType | ValueType |
Public Member Functions | |
| void | add (void *ptr, ValueType value) |
| NodeType * | getRoot () |
| NodeType * | remove (ValueType &size, ValueType limit=~static_cast< ValueType >(0)) |
| void | remove (void *ptr) |
| bool | contains (void *ptr) |
| bool | canGrowInPlace (void *ptr, ValueType newValue) |
| bool | isEmpty () const |
This class defines a Red-Black Tree.
| Node | Any classes similar to PtrRBNode |
| typedef Node cookmem::RedBlackTree< Node >::NodeType |
The type of the tree nodes.
| typedef NodeType::ValueType cookmem::RedBlackTree< Node >::ValueType |
The type of the node values.
|
inline |
Add a pointer to the search tree.
Note that the size of the pointer must be at least (7 * sizeof(size_t)).
| ptr | the pointer to be added to the red-black tree. |
| value | the size of the pointer |
|
inline |
Check if a node in the tree can take a larger value without changing its position in the tree. If so, the caller can update the value in place instead of removing the node and adding it back.
| ptr | the pointer stored in the tree. |
| newValue | the new value, which must be larger than the current value. |
|
inline |
Check if the pointer is stored in the tree.
| ptr | the pointer to be searched. |
|
inline |
Get the root node. This is mostly for testing.
|
inline |
Check if the tree is empty.
|
inline |
Remove a node based on the size information. The node obtained has the size that at least the size obtained.
| [in,out] | size | search key. If the node is found, the actual size of the pointer is returned. |
| limit | the node must be smaller than this value. Otherwise nothing is removed. |
|
inline |
Remove a node based on the pointer info.
| ptr | the pointer to be removed from the tree |