source: rtems/cpukit/score/src/rbtreefind.c @ 64939bc

4.115
Last change on this file since 64939bc was 64939bc, checked in by Sebastian Huber <sebastian.huber@…>, on 07/12/14 at 19:22:22

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

  • Property mode set to 100644
File size: 1023 bytes
Line 
1/**
2 * @file
3 *
4 * @brief Find the control structure of the tree containing the given node
5 * @ingroup ScoreRBTree
6 */
7
8/*
9 *  Copyright (c) 2010 Gedare Bloom.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <rtems/score/rbtreeimpl.h>
21
22RBTree_Node *_RBTree_Find(
23  const RBTree_Control *the_rbtree,
24  const RBTree_Node    *the_node,
25  RBTree_Compare        compare,
26  bool                  is_unique
27)
28{
29  RBTree_Node* iter_node = the_rbtree->root;
30  RBTree_Node* found = NULL;
31
32  while ( iter_node != NULL ) {
33    int compare_result = ( *compare )( the_node, iter_node );
34    RBTree_Direction dir;
35
36    if ( _RBTree_Is_equal( compare_result ) ) {
37      found = iter_node;
38      if ( is_unique )
39        break;
40    }
41
42    dir = (RBTree_Direction) _RBTree_Is_greater( compare_result );
43    iter_node = iter_node->child[ dir ];
44  }
45
46  return found;
47}
Note: See TracBrowser for help on using the repository browser.