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


GNU libavl 2.0.1

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

15.5.2 Step 3: Update Balance Factors

Step 3, updating balance factors, is taken straight from TAVL deletion (see section 9.5.3 Step 3: Update Balance Factors), with the call to find_parent() replaced by inline code that uses pavl_parent.

 
while (q != (struct pavl_node *) &tree-&#62;pavl_root) 
{ struct pavl_node *y = q; if (y-&#62;pavl_parent != NULL) q = y-&#62;pavl_parent; else
q = (struct pavl_node *) &tree-&#62;pavl_root; if (dir == 0)
{ dir = q-&#62;pavl_link[0] != y; y-&#62;pavl_balance++; if (y-&#62;pavl_balance == +1) break; else if (y-&#62;pavl_balance == +2) {
&#60;@xref{\NODE\, , Step 4: Rebalance after PAVL deletion.&#62;,540}
} } else
{
&#60;@xref{\NODE\, , Steps 3 and 4: Symmetric case in PAVL deletion.&#62;,543}
} } tree-&#62;pavl_count--; return (void *) item;
This code is included in @refalso{534


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