diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-17 07:50:01 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-22 14:37:11 +0200 |
commit | 69a6802bfa8878d3e9a8296c1516ff5feac77bbc (patch) | |
tree | 13b6fa37a0858315315665621e2714b4a5d1caf2 /cpukit/sapi/src/rbtreefind.c | |
parent | score: Move _RBTree_Insert() (diff) | |
download | rtems-69a6802bfa8878d3e9a8296c1516ff5feac77bbc.tar.bz2 |
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.
Diffstat (limited to 'cpukit/sapi/src/rbtreefind.c')
-rw-r--r-- | cpukit/sapi/src/rbtreefind.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cpukit/sapi/src/rbtreefind.c b/cpukit/sapi/src/rbtreefind.c new file mode 100644 index 0000000000..d3f67a6462 --- /dev/null +++ b/cpukit/sapi/src/rbtreefind.c @@ -0,0 +1,51 @@ +/** + * @file + * + * @brief Find the control structure of the tree containing the given node + * @ingroup Scorertems_rbtree + */ + +/* + * Copyright (c) 2010 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/rbtree.h> + +rtems_rbtree_node *rtems_rbtree_find( + const rtems_rbtree_control *the_rbtree, + const rtems_rbtree_node *the_node, + rtems_rbtree_compare compare, + bool is_unique +) +{ + rtems_rbtree_node *iter_node = rtems_rbtree_root( the_rbtree ); + rtems_rbtree_node *found = NULL; + + while ( iter_node != NULL ) { + rtems_rbtree_compare_result compare_result = + ( *compare )( the_node, iter_node ); + + if ( rtems_rbtree_is_equal( compare_result ) ) { + found = iter_node; + + if ( is_unique ) + break; + } + + if ( rtems_rbtree_is_greater( compare_result ) ) { + iter_node = rtems_rbtree_right( iter_node ); + } else { + iter_node = rtems_rbtree_left( iter_node ); + } + } + + return found; +} |