Changeset 64939bc in rtems for cpukit/score/src/rbtreeinsert.c


Ignore:
Timestamp:
Jul 12, 2014, 7:22:22 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
ed7a028
Parents:
7e119990
git-author:
Sebastian Huber <sebastian.huber@…> (07/12/14 19:22:22)
git-committer:
Joel Sherrill <joel.sherrill@…> (07/15/14 15:03:48)
Message:

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().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/rbtreeinsert.c

    r7e119990 r64939bc  
    6060}
    6161
    62 
    63 
    64 /** @brief Insert a Node (unprotected)
    65  *
    66  *  This routine inserts @a the_node on the Red-Black Tree @a the_rbtree.
    67  *
    68  *  @retval 0 Successfully inserted.
    69  *  @retval -1 NULL @a the_node.
    70  *  @retval RBTree_Node* if one with equal key to the key of @a the_node exists
    71  *          in an unique @a the_rbtree.
    72  *
    73  *  @note It does NOT disable interrupts to ensure the atomicity
    74  *        of the extract operation.
    75  */
    7662RBTree_Node *_RBTree_Insert(
    77     RBTree_Control *the_rbtree,
    78     RBTree_Node *the_node
    79     )
     63  RBTree_Control *the_rbtree,
     64  RBTree_Node    *the_node,
     65  RBTree_Compare  compare,
     66  bool            is_unique
     67)
    8068{
    8169  if(!the_node) return (RBTree_Node*)-1;
     
    9381    /* typical binary search tree insert, descend tree to leaf and insert */
    9482    while (iter_node) {
    95       compare_result = the_rbtree->compare_function(the_node, iter_node);
    96       if ( the_rbtree->is_unique && _RBTree_Is_equal( compare_result ) )
     83      compare_result = ( *compare )( the_node, iter_node );
     84      if ( is_unique && _RBTree_Is_equal( compare_result ) )
    9785        return iter_node;
    9886      RBTree_Direction dir = !_RBTree_Is_lesser( compare_result );
     
    10391        the_node->parent = iter_node;
    10492        /* update min/max */
    105         compare_result = the_rbtree->compare_function(
    106             the_node,
    107             _RBTree_First(the_rbtree, dir)
     93        compare_result = ( *compare )(
     94          the_node,
     95          _RBTree_First( the_rbtree, dir )
    10896        );
    10997        if ( (!dir && _RBTree_Is_lesser(compare_result)) ||
Note: See TracChangeset for help on using the changeset viewer.