Home --> Documentations --> PJLIB Reference
Red/Black tree is the variant of balanced tree, where the search, insert, and delete operation is guaranteed to take at most O( lg(n) ).
More...
Red/Black tree is the variant of balanced tree, where the search, insert, and delete operation is guaranteed to take at most O( lg(n) ).
◆ PJ_RBTREE_NODE_SIZE
Guidance on how much memory required for each of the node.
◆ PJ_RBTREE_SIZE
Guidance on memory required for the tree.
◆ pj_rbtree_comp
typedef int pj_rbtree_comp(const void *key1, const void *key2) |
The type of function use to compare key value of tree node. - Returns
- 0 if the keys are equal <0 if key1 is lower than key2 >0 if key1 is greater than key2.
◆ pj_rbcolor_t
Color type for Red-Black tree.
◆ pj_rbtree_erase()
Erase a node from the tree. - Parameters
-
tree | the tree. |
node | the node to be erased. |
- Returns
- the tree node itself.
◆ pj_rbtree_find()
Find a node which has the specified key. - Parameters
-
tree | the tree. |
key | the key to search. |
- Returns
- the tree node with the specified key, or NULL if the key can not be found.
◆ pj_rbtree_first()
Get the first element in the tree. The first element always has the least value for the key, according to the comparison function. - Parameters
-
- Returns
- the tree node, or NULL if the tree has no element.
◆ pj_rbtree_init()
Initialize the tree. - Parameters
-
tree | the tree to be initialized. |
comp | key comparison function to be used for this tree. |
◆ pj_rbtree_insert()
Insert a new node. The node will be inserted at sorted location. The key of the node must be UNIQUE, i.e. it hasn't existed in the tree. - Parameters
-
tree | the tree. |
node | the node to be inserted. |
- Returns
- zero on success, or -1 if the key already exist.
◆ pj_rbtree_last()
Get the last element in the tree. The last element always has the greatest key value, according to the comparison function defined for the tree. - Parameters
-
- Returns
- the tree node, or NULL if the tree has no element.
◆ pj_rbtree_max_height()
Get the maximum tree height from the specified node. - Parameters
-
tree | the tree. |
node | the node, or NULL to get the root of the tree. |
- Returns
- the maximum height, which should be at most lg(N)
◆ pj_rbtree_min_height()
Get the minumum tree height from the specified node. - Parameters
-
tree | the tree. |
node | the node, or NULL to get the root of the tree. |
- Returns
- the height
◆ pj_rbtree_next()
Get the successive element for the specified node. The successive element is an element with greater key value. - Parameters
-
tree | the tree. |
node | the node. |
- Returns
- the successive node, or NULL if the node has no successor.
◆ pj_rbtree_prev()
The the previous node for the specified node. The previous node is an element with less key value. - Parameters
-
tree | the tree. |
node | the node. |
- Returns
- the previous node, or NULL if the node has no previous node.
PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.
|