www.delorie.com/gnu/docs/avl/libavl_195.html   search  
 
Buy GNU books!


GNU libavl 2.0.1

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.6.3 Starting at a Found Node

To start from an item found in the tree, we use the same algorithm as rtbst_find().

 
void *
rtbst_t_find (struct rtbst_traverser *trav, struct rtbst_table *tree,
void *item)
{ struct rtbst_node *p; assert (trav != NULL && tree != NULL && item != NULL); trav-&#62;rtbst_table = tree; trav-&#62;rtbst_node = NULL; p = tree-&#62;rtbst_root; if (p == NULL) return NULL; for (;;)
{ int cmp = tree-&#62;rtbst_compare (item, p-&#62;rtbst_data, tree-&#62;rtbst_param); if (cmp == 0)
{ trav-&#62;rtbst_node = p; return p-&#62;rtbst_data; } if (cmp < 0)
{ p = p-&#62;rtbst_link[0]; if (p == NULL) return NULL; }
else
{ if (p-&#62;rtbst_rtag == RTBST_THREAD) return NULL; p = p-&#62;rtbst_link[1]; } } }
This code is included in @refalso{395


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003