void balance ( DeleteStack stack , int ntop ) { DeleteStack . HeightNote xx = stack . heightNote ( ) ; ntop -- ; GBSNode bnext = stack . node ( ntop + 1 ) ; /* Set initial "next" point */ for ( int i = ntop ; i > 0 ; i -- ) /* Work UP through the balance points */ { xx . depthDecrease = false ; reBalance ( xx , stack . node ( i - 1 ) , stack . node ( i ) , bnext ) ; bnext = xx . bnew ; if ( ! xx . depthDecrease ) /* Depth did not change */ break ; /* So we are re-balanced */ } }
Restore height balance following a fringe raveling caused by a delete .