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


GNU libavl 2.0.1

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

11.6.2 Starting at the Last Node

To start at the last (greatest) item in the tree, we descend all the way to the right. In an RTBST, as in a TBST, this involves checking for thread links.

 
void *
rtbst_t_last (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_rtag == RTBST_CHILD) trav-&#62;rtbst_node = trav-&#62;rtbst_node-&#62;rtbst_link[1]; 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