source: rtems/cpukit/score/src/rbtreefind.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.0 KB
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#include <rtems/score/isr.h>
22
23RBTree_Node *_RBTree_Find(
24  const RBTree_Control *the_rbtree,
25  const RBTree_Node *the_node
26)
27{
28  RBTree_Node* iter_node = the_rbtree->root;
29  RBTree_Node* found = NULL;
30  int compare_result;
31  while (iter_node) {
32    compare_result = the_rbtree->compare_function(the_node, iter_node);
33    if ( _RBTree_Is_equal( compare_result ) ) {
34      found = iter_node;
35      if ( the_rbtree->is_unique )
36        break;
37    }
38
39    RBTree_Direction dir =
40      (RBTree_Direction) _RBTree_Is_greater( compare_result );
41    iter_node = iter_node->child[dir];
42  } /* while(iter_node) */
43
44  return found;
45}
Note: See TracBrowser for help on using the repository browser.