RTEMS
rbtreeextract.c
1 /*
2  * Copyright (c) 2010 Gedare Bloom.
3  *
4  * The license and distribution terms for this file may be
5  * found in the file LICENSE in this distribution or at
6  * http://www.rtems.org/license/LICENSE.
7  */
8 
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12 
13 #include <rtems/score/rbtreeimpl.h>
14 
15 RB_GENERATE_REMOVE_COLOR( RBTree_Control, RBTree_Node, Node, static )
16 
17 RB_GENERATE_REMOVE( RBTree_Control, RBTree_Node, Node, static )
18 
19 #if defined(RTEMS_DEBUG)
20 static const RBTree_Node *_RBTree_Find_root( const RBTree_Node *the_node )
21 {
22  while ( true ) {
23  const RBTree_Node *potential_root;
24 
25  potential_root = the_node;
26  the_node = _RBTree_Parent( the_node );
27 
28  if ( the_node == NULL ) {
29  return potential_root;
30  }
31  }
32 }
33 #endif
34 
36  RBTree_Control *the_rbtree,
37  RBTree_Node *the_node
38 )
39 {
40  _Assert( _RBTree_Find_root( the_node ) == _RBTree_Root( the_rbtree ) );
41  RB_REMOVE( RBTree_Control, the_rbtree, the_node );
42  _RBTree_Initialize_node( the_node );
43 }
Red-black tree node.
Definition: rbtree.h:55
static __inline__ RBTree_Node * _RBTree_Root(const RBTree_Control *the_rbtree)
Returns a pointer to root node of the red-black tree.
Definition: rbtree.h:246
static __inline__ RBTree_Node * _RBTree_Parent(const RBTree_Node *the_node)
Returns a pointer to the parent of this node.
Definition: rbtree.h:295
Inlined Routines Associated with Red-Black Trees.
static __inline__ void _RBTree_Initialize_node(RBTree_Node *the_node)
Initializes a red-black tree node.
Definition: rbtree.h:129
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition: rbtreeextract.c:35
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100