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


GNU libavl 2.0.1

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

9.5.1 Step 1: Search

We use p to search down the tree and keep track of p's parent with q. We keep the invariant at the beginning of the loop here that q-&#62;tavl_link[dir] == p. As the final step, we record the item deleted and update the tree's item count.

 
if (tree-&#62;tavl_root == NULL)
  return NULL;
p = (struct tavl_node *) &tree-&#62;tavl_root;
for (cmp = -1; cmp != 0;
     cmp = tree-&#62;tavl_compare (item, p-&#62;tavl_data, tree-&#62;tavl_param)) 
{ dir = cmp > 0; q = p; if (p-&#62;tavl_tag[dir] == TAVL_THREAD) return NULL; p = p-&#62;tavl_link[dir]; } item = p-&#62;tavl_data;
This code is included in @refalso{311


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