summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/rbtreeinsert.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-12 14:22:22 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-07-15 10:03:48 -0500
commit64939bc9efcaf945b493e9c371901de33c3868a3 (patch)
treee196959688afe714c8c334f93598cb99234970e4 /cpukit/score/src/rbtreeinsert.c
parentrbtree: Delete unused functions (diff)
downloadrtems-64939bc9efcaf945b493e9c371901de33c3868a3.tar.bz2
rbtree: Reduce RBTree_Control size
Remove compare function and is unique indicator from the control structure. Rename RBTree_Compare_function to RBTree_Compare. Rename rtems_rbtree_compare_function to rtems_rbtree_compare. Provide C++ compatible initializers. Add compare function and is unique indicator to _RBTree_Find(), _RBTree_Insert(), rtems_rbtree_find() and rtems_rbtree_insert(). Remove _RBTree_Is_unique() and rtems_rbtree_is_unique(). Remove compare function and is unique indicator from _RBTree_Initialize_empty() and rtems_rbtree_initialize_empty().
Diffstat (limited to 'cpukit/score/src/rbtreeinsert.c')
-rw-r--r--cpukit/score/src/rbtreeinsert.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/cpukit/score/src/rbtreeinsert.c b/cpukit/score/src/rbtreeinsert.c
index 39f7c2bb09..7174529ade 100644
--- a/cpukit/score/src/rbtreeinsert.c
+++ b/cpukit/score/src/rbtreeinsert.c
@@ -59,24 +59,12 @@ static void _RBTree_Validate_insert(
if(!the_node->parent->parent) the_node->color = RBT_BLACK;
}
-
-
-/** @brief Insert a Node (unprotected)
- *
- * This routine inserts @a the_node on the Red-Black Tree @a the_rbtree.
- *
- * @retval 0 Successfully inserted.
- * @retval -1 NULL @a the_node.
- * @retval RBTree_Node* if one with equal key to the key of @a the_node exists
- * in an unique @a the_rbtree.
- *
- * @note It does NOT disable interrupts to ensure the atomicity
- * of the extract operation.
- */
RBTree_Node *_RBTree_Insert(
- RBTree_Control *the_rbtree,
- RBTree_Node *the_node
- )
+ RBTree_Control *the_rbtree,
+ RBTree_Node *the_node,
+ RBTree_Compare compare,
+ bool is_unique
+)
{
if(!the_node) return (RBTree_Node*)-1;
@@ -92,8 +80,8 @@ RBTree_Node *_RBTree_Insert(
} else {
/* typical binary search tree insert, descend tree to leaf and insert */
while (iter_node) {
- compare_result = the_rbtree->compare_function(the_node, iter_node);
- if ( the_rbtree->is_unique && _RBTree_Is_equal( compare_result ) )
+ compare_result = ( *compare )( the_node, iter_node );
+ if ( is_unique && _RBTree_Is_equal( compare_result ) )
return iter_node;
RBTree_Direction dir = !_RBTree_Is_lesser( compare_result );
if (!iter_node->child[dir]) {
@@ -102,9 +90,9 @@ RBTree_Node *_RBTree_Insert(
iter_node->child[dir] = the_node;
the_node->parent = iter_node;
/* update min/max */
- compare_result = the_rbtree->compare_function(
- the_node,
- _RBTree_First(the_rbtree, dir)
+ compare_result = ( *compare )(
+ the_node,
+ _RBTree_First( the_rbtree, dir )
);
if ( (!dir && _RBTree_Is_lesser(compare_result)) ||
(dir && _RBTree_Is_greater(compare_result)) ) {