source: rtems/cpukit/sapi/src/rbtreefind.c @ 65f868c

5
Last change on this file since 65f868c was 69a6802b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/17/16 at 05:50:01

score: Move _RBTree_Find()

The _RBTree_Find() is no longer used in the score. Move it to sapi and
make it rtems_rbtree_find(). Move corresponding types and support
functions to sapi.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Find the control structure of the tree containing the given node
5 * @ingroup Scorertems_rbtree
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/rbtree.h>
21
22rtems_rbtree_node *rtems_rbtree_find(
23  const rtems_rbtree_control *the_rbtree,
24  const rtems_rbtree_node    *the_node,
25  rtems_rbtree_compare        compare,
26  bool                  is_unique
27)
28{
29  rtems_rbtree_node *iter_node = rtems_rbtree_root( the_rbtree );
30  rtems_rbtree_node *found = NULL;
31
32  while ( iter_node != NULL ) {
33    rtems_rbtree_compare_result compare_result =
34      ( *compare )( the_node, iter_node );
35
36    if ( rtems_rbtree_is_equal( compare_result ) ) {
37      found = iter_node;
38
39      if ( is_unique )
40        break;
41    }
42
43    if ( rtems_rbtree_is_greater( compare_result ) ) {
44      iter_node = rtems_rbtree_right( iter_node );
45    } else {
46      iter_node = rtems_rbtree_left( iter_node );
47    }
48  }
49
50  return found;
51}
Note: See TracBrowser for help on using the repository browser.