This group contains the Red-Black Tree Handler implementation.
More...
|
#define | RBTREE_INITIALIZER_EMPTY(name) RB_INITIALIZER( name ) |
| Initializer for an empty red-black tree with designator name.
|
|
#define | RBTREE_DEFINE_EMPTY(name) RBTree_Control name = RBTREE_INITIALIZER_EMPTY( name ) |
| Definition for an empty red-black tree with designator name.
|
|
|
typedef | RB_HEAD (RBTree_Control, RBTree_Node) RBTree_Control |
| Red-black tree control.
|
|
void | _RBTree_Insert_color (RBTree_Control *the_rbtree, RBTree_Node *the_node) |
| Rebalances the red-black tree after insertion of the node.
|
|
void | _RBTree_Extract (RBTree_Control *the_rbtree, RBTree_Node *the_node) |
| Extracts (removes) the node from the red-black tree.
|
|
RBTree_Node * | _RBTree_Minimum (const RBTree_Control *the_rbtree) |
| Returns the minimum node of the red-black tree.
|
|
RBTree_Node * | _RBTree_Maximum (const RBTree_Control *the_rbtree) |
| Returns the maximum node of the red-black tree.
|
|
RBTree_Node * | _RBTree_Predecessor (const RBTree_Node *node) |
| Returns the predecessor of a node.
|
|
RBTree_Node * | _RBTree_Successor (const RBTree_Node *node) |
| Returns the successor of a node.
|
|
void | _RBTree_Replace_node (RBTree_Control *the_rbtree, RBTree_Node *victim, RBTree_Node *replacement) |
| Replaces a node in the red-black tree without a rebalance.
|
|
void * | _RBTree_Postorder_first (const RBTree_Control *the_rbtree, size_t offset) |
| Returns the container of the first node of the specified red-black tree in postorder.
|
|
void * | _RBTree_Postorder_next (const RBTree_Node *the_node, size_t offset) |
| Returns the container of the next node in postorder.
|
|
void | _RBTree_Append (RBTree_Control *the_rbtree, RBTree_Node *the_node) |
| Appends the node to the red-black tree.
|
|
void | _RBTree_Prepend (RBTree_Control *the_rbtree, RBTree_Node *the_node) |
| Prepends the node to the red-black tree.
|
|
void | _RBTree_Iterate (const RBTree_Control *rbtree, RBTree_Visitor visitor, void *visitor_arg) |
| Red-black tree iteration.
|
|
This group contains the Red-Black Tree Handler implementation.
The Red-Black Tree Handler is used to manage sets of entities. This handler provides two data structures. The rbtree Node data structure is included as the first part of every data structure that will be placed on a RBTree. The second data structure is rbtree Control which is used to manage a set of rbtree Nodes.
◆ RBTree_Node
Red-black tree node.
This is used to manage each node (element) which is placed on a red-black tree.
◆ RBTree_Visitor
typedef bool(* RBTree_Visitor) (const RBTree_Node *node, void *visitor_arg) |
Red-black tree visitor.
- Parameters
-
[in] | node | The node. |
[in] | visitor_arg | The visitor argument. |
- Return values
-
true | Stop the iteration. |
false | Continue the iteration. |
- See also
- _RBTree_Iterate().
◆ _RBTree_Append()
void _RBTree_Append |
( |
RBTree_Control * |
the_rbtree, |
|
|
RBTree_Node * |
the_node |
|
) |
| |
Appends the node to the red-black tree.
The appended node is the new maximum node of the tree. The caller shall ensure that the appended node is indeed the maximum node with respect to the tree order.
- Parameters
-
[in,out] | the_rbtree | is the red-black tree control. |
| the_node[out] | is the node to append. |
◆ _RBTree_Extract()
void _RBTree_Extract |
( |
RBTree_Control * |
the_rbtree, |
|
|
RBTree_Node * |
the_node |
|
) |
| |
Extracts (removes) the node from the red-black tree.
This function does not set the node off-tree. In the case this is desired, then call _RBTree_Set_off_tree() after the extraction.
In the case the node to extract is not a node of the tree, then this function yields unpredictable results.
- Parameters
-
[in,out] | the_rbtree | The red-black tree control. |
[out] | the_node | The node to extract. |
◆ _RBTree_Insert_color()
void _RBTree_Insert_color |
( |
RBTree_Control * |
the_rbtree, |
|
|
RBTree_Node * |
the_node |
|
) |
| |
Rebalances the red-black tree after insertion of the node.
- Parameters
-
[in,out] | the_rbtree | The red-black tree control. |
[in,out] | the_node | The most recently inserted node. |
◆ _RBTree_Iterate()
void _RBTree_Iterate |
( |
const RBTree_Control * |
rbtree, |
|
|
RBTree_Visitor |
visitor, |
|
|
void * |
visitor_arg |
|
) |
| |
Red-black tree iteration.
- Parameters
-
rbtree | The red-black tree. |
visitor | The visitor. |
visitor_arg | The visitor argument. |
◆ _RBTree_Maximum()
RBTree_Node * _RBTree_Maximum |
( |
const RBTree_Control * |
the_rbtree | ) |
|
Returns the maximum node of the red-black tree.
- Parameters
-
the_rbtree | The red-black tree control. |
- Return values
-
node | The maximum node. |
NULL | The red-black tree is empty. |
◆ _RBTree_Minimum()
RBTree_Node * _RBTree_Minimum |
( |
const RBTree_Control * |
the_rbtree | ) |
|
Returns the minimum node of the red-black tree.
- Parameters
-
the_rbtree | The red-black tree control. |
- Return values
-
node | The minimum node. |
NULL | The red-black tree is empty. |
◆ _RBTree_Postorder_first()
void * _RBTree_Postorder_first |
( |
const RBTree_Control * |
the_rbtree, |
|
|
size_t |
offset |
|
) |
| |
Returns the container of the first node of the specified red-black tree in postorder.
Postorder traversal may be used to delete all nodes of a red-black tree.
- Parameters
-
the_rbtree | The red-black tree control. |
offset | The offset to the red-black tree node in the container structure. |
- Return values
-
container | The container of the first node of the specified red-black tree in postorder. |
NULL | The red-black tree is empty. |
- See also
- _RBTree_Postorder_next().
typedef struct {
int data;
} Container_Control;
void visit( Container_Control *the_container );
void postorder_traversal( RBTree_Control *the_rbtree )
{
Container_Control *the_container;
the_rbtree,
offsetof( Container_Control, Node )
);
while ( the_container !=
NULL ) {
visit( the_container );
&the_container->Node,
offsetof( Container_Control, Node )
);
}
}
void * _RBTree_Postorder_first(const RBTree_Control *the_rbtree, size_t offset)
Returns the container of the first node of the specified red-black tree in postorder.
Definition: rbtreepostorder.c:81
void * _RBTree_Postorder_next(const RBTree_Node *the_node, size_t offset)
Returns the container of the next node in postorder.
Definition: rbtreepostorder.c:59
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
This header file provides interfaces of the Red-Black Tree Handler which are used by the implementati...
Red-black tree node.
Definition: rbtree.h:73
◆ _RBTree_Postorder_next()
void * _RBTree_Postorder_next |
( |
const RBTree_Node * |
the_node, |
|
|
size_t |
offset |
|
) |
| |
Returns the container of the next node in postorder.
- Parameters
-
the_node | The red-black tree node. The node must not be NULL. |
offset | The offset to the red-black tree node in the container structure. |
- Return values
-
container | The container of the next node in postorder. |
NULL | The node is NULL or there is no next node in postorder. |
- See also
- _RBTree_Postorder_first().
◆ _RBTree_Predecessor()
Returns the predecessor of a node.
- Parameters
-
- Return values
-
node | The predecessor node. |
NULL | The predecessor does not exist. |
◆ _RBTree_Prepend()
void _RBTree_Prepend |
( |
RBTree_Control * |
the_rbtree, |
|
|
RBTree_Node * |
the_node |
|
) |
| |
Prepends the node to the red-black tree.
The prepended node is the new minimum node of the tree. The caller shall ensure that the prepended node is indeed the minimum node with respect to the tree order.
- Parameters
-
[in,out] | the_rbtree | is the red-black tree control. |
| the_node[out] | is the node to prepend. |
◆ _RBTree_Replace_node()
Replaces a node in the red-black tree without a rebalance.
- Parameters
-
[in,out] | the_rbtree | The red-black tree control. |
| victim | The victim node. |
[out] | replacement | The replacement node. |
◆ _RBTree_Successor()
Returns the successor of a node.
- Parameters
-
- Return values
-
node | The successor node. |
NULL | The successor does not exist. |
◆ RB_HEAD()
Red-black tree control.
This is used to manage a red-black tree. A red-black tree consists of a tree of zero or more nodes.