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


GNU libavl 2.0.1

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

8.8.4 Starting at a Found Node

The code for this function is derived with few changes from &#60;@xref{\NODE\, , TBST search function.&#62;,253}.

 
void *
tbst_t_find (struct tbst_traverser *trav, struct tbst_table *tree, void *item)
{ struct tbst_node *p; assert (trav != NULL && tree != NULL && item != NULL); trav-&#62;tbst_table = tree; trav-&#62;tbst_node = NULL; p = tree-&#62;tbst_root; if (p == NULL) return NULL; for (;;)
{ int cmp, dir; cmp = tree-&#62;tbst_compare (item, p-&#62;tbst_data, tree-&#62;tbst_param); if (cmp == 0)
{ trav-&#62;tbst_node = p; return p-&#62;tbst_data; } dir = cmp > 0; if (p-&#62;tbst_tag[dir] == TBST_CHILD) p = p-&#62;tbst_link[dir]; else
return NULL; } }
This code is included in @refalso{268


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