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


GNU libavl 2.0.1

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

11.8 Destruction

The destruction algorithm for TBSTs makes use only of right threads, so we can easily adapt it for RTBSTs.

 
void 
rtbst_destroy (struct rtbst_table *tree, rtbst_item_func *destroy)
{ struct rtbst_node *p; /* Current node. */ struct rtbst_node *n; /* Next node. */ p = tree-&#62;rtbst_root; if (p != NULL) while (p-&#62;rtbst_link[0] != NULL) p = p-&#62;rtbst_link[0]; while (p != NULL)
{ n = p-&#62;rtbst_link[1]; if (p-&#62;rtbst_rtag == RTBST_CHILD) while (n-&#62;rtbst_link[0] != NULL) n = n-&#62;rtbst_link[0]; if (destroy != NULL && p-&#62;rtbst_data != NULL) destroy (p-&#62;rtbst_data, tree-&#62;rtbst_param); tree-&#62;rtbst_alloc-&#62;libavl_free (tree-&#62;rtbst_alloc, p); p = n; } tree-&#62;rtbst_alloc-&#62;libavl_free (tree-&#62;rtbst_alloc, tree); }
This code is included in @refalso{375


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