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


GNU libavl 2.0.1

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

14.5.1 Starting at the First Node

Finding the smallest node in the tree is just a matter of starting from the root and descending as far to the left as we can.

 
void *
pbst_t_first (struct pbst_traverser *trav, struct pbst_table *tree)
{ assert (tree != NULL && trav != NULL); trav-&#62;pbst_table = tree; trav-&#62;pbst_node = tree-&#62;pbst_root; if (trav-&#62;pbst_node != NULL)
{ while (trav-&#62;pbst_node-&#62;pbst_link[0] != NULL) trav-&#62;pbst_node = trav-&#62;pbst_node-&#62;pbst_link[0]; return trav-&#62;pbst_node-&#62;pbst_data; } else
return NULL; }
This code is included in @refalso{502


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