38#ifndef _RTEMS_SCORE_RBTREE_H
39#define _RTEMS_SCORE_RBTREE_H
88#define RBTREE_INITIALIZER_EMPTY( name ) \
89 RB_INITIALIZER( name )
94#define RBTREE_DEFINE_EMPTY( name ) \
95 RBTree_Control name = RBTREE_INITIALIZER_EMPTY( name )
106static inline void _RBTree_Set_off_tree(
RBTree_Node *the_node )
108 RB_COLOR( the_node, Node ) = -1;
121static inline bool _RBTree_Is_node_off_tree(
125 return RB_COLOR( the_node, Node ) == -1;
135 RBTree_Control *the_rbtree,
147static inline void _RBTree_Initialize_node(
RBTree_Node *the_node )
149#if defined(RTEMS_DEBUG)
150 _RBTree_Set_off_tree( the_node );
163static inline void _RBTree_Add_child(
169 _Assert( _RBTree_Is_node_off_tree( child ) );
170 RB_SET( child, parent, Node );
224static inline void _RBTree_Insert_with_parent(
225 RBTree_Control *the_rbtree,
231 _RBTree_Add_child( the_node, parent,
link );
248 RBTree_Control *the_rbtree,
265 const RBTree_Control *the_rbtree
268 return RB_ROOT( the_rbtree );
280 RBTree_Control *the_rbtree
283 return &RB_ROOT( the_rbtree );
294static inline RBTree_Node *
const *_RBTree_Root_const_reference(
295 const RBTree_Control *the_rbtree
298 return &RB_ROOT( the_rbtree );
317 return RB_PARENT( the_node, Node );
333 return RB_LEFT( the_node, Node );
348 return &RB_LEFT( the_node, Node );
364 return RB_RIGHT( the_node, Node );
375static inline RBTree_Node **_RBTree_Right_reference(
379 return &RB_RIGHT( the_node, Node );
393static inline bool _RBTree_Is_empty(
394 const RBTree_Control *the_rbtree
397 return RB_EMPTY( the_rbtree );
414static inline bool _RBTree_Is_root(
418 return _RBTree_Parent( the_node ) ==
NULL;
428static inline void _RBTree_Initialize_empty(
429 RBTree_Control *the_rbtree
432 RB_INIT( the_rbtree );
442static inline void _RBTree_Initialize_one(
443 RBTree_Control *the_rbtree,
447 _Assert( _RBTree_Is_node_off_tree( the_node ) );
448 RB_ROOT( the_rbtree ) = the_node;
449 RB_PARENT( the_node, Node ) =
NULL;
450 RB_LEFT( the_node, Node ) =
NULL;
451 RB_RIGHT( the_node, Node ) =
NULL;
452 RB_COLOR( the_node, Node ) = RB_BLACK;
503 RBTree_Control *the_rbtree,
526static inline bool _RBTree_Insert_inline(
527 RBTree_Control *the_rbtree,
530 bool ( *less )(
const void *,
const RBTree_Node * )
537 link = _RBTree_Root_reference( the_rbtree );
539 is_new_minimum =
true;
544 if ( ( *less )( key, parent ) ) {
545 link = _RBTree_Left_reference( parent );
547 link = _RBTree_Right_reference( parent );
548 is_new_minimum =
false;
552 _RBTree_Add_child( the_node, parent,
link );
554 return is_new_minimum;
575static inline void *_RBTree_Find_inline(
576 const RBTree_Control *the_rbtree,
578 bool ( *equal )(
const void *,
const RBTree_Node * ),
579 bool ( *less )(
const void *,
const RBTree_Node * ),
586 link = _RBTree_Root_const_reference( the_rbtree );
592 if ( ( *equal )( key, parent ) ) {
593 return ( *
map )( parent );
594 }
else if ( ( *less )( key, parent ) ) {
595 link = _RBTree_Left_reference( parent );
597 link = _RBTree_Right_reference( parent );
650 const RBTree_Control *the_rbtree,
This header file provides the interfaces of the Assert Handler.
This header file provides basic definitions used by the API and the implementation.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition: assert.h:96
RBTree_Node * _RBTree_Predecessor(const RBTree_Node *node)
Returns the predecessor of a node.
Definition: rbtreeprev.c:46
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:63
RBTree_Node * _RBTree_Maximum(const RBTree_Control *the_rbtree)
Returns the maximum node of the red-black tree.
Definition: rbtreemax.c:43
struct RBTree_Node RBTree_Node
Red-black tree node.
typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control
Red-black tree control.
RBTree_Node * _RBTree_Successor(const RBTree_Node *node)
Returns the successor of a node.
Definition: rbtreenext.c:47
void _RBTree_Insert_color(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Rebalances the red-black tree after insertion of the node.
Definition: rbtreeinsert.c:45
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
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.
Definition: rbtreereplace.c:43
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition: rbtreemin.c:43
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
int link(const char *path1, const char *path2)
Definition: link.c:47
Red-black tree node.
Definition: rbtree.h:73