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


GNU libavl 2.0.1

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

11.6.1 Starting at the First Node

To find the first (least) item in the tree, we just descend all the way to the left, as usual. In an RTBST, as in a BST, this involves checking for null pointers.

 
void *
rtbst_t_first (struct rtbst_traverser *trav, struct rtbst_table *tree)
{ assert (tree != NULL && trav != NULL); trav-&#62;rtbst_table = tree; trav-&#62;rtbst_node = tree-&#62;rtbst_root; if (trav-&#62;rtbst_node != NULL)
{ while (trav-&#62;rtbst_node-&#62;rtbst_link[0] != NULL) trav-&#62;rtbst_node = trav-&#62;rtbst_node-&#62;rtbst_link[0]; return trav-&#62;rtbst_node-&#62;rtbst_data; } else
return NULL; }
This code is included in @refalso{395


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