/*Copyright (C) 1992, 1995 by Thomas Glen Smith. All Rights Reserved.*/ /* avltsub3.h APL2 V1.0.0 ********************************************** * Included in avltree.c - tree is unbalanced - determine rotation. * ***********************************************************************/ if (d == +1) /* left imbalance? */ if (b->avlbf == +1) { /* rotation type ll */ a->left_child = b->rite_child; b->rite_child = a; a->avlbf = b->avlbf = 0; } else { /* rotation type lr */ c = b->rite_child; if (c == NULL) cl = cr = NULL; else { cl = c->left_child; cr = c->rite_child; } b->rite_child = cl; a->left_child = cr; c->left_child = b; c->rite_child = a; switch (c->avlbf) { case +1: /* lr(b) */ a->avlbf = -1; b->avlbf = 0; break; case -1: /* lr(c) */ b->avlbf = +1; a->avlbf = 0; break; default: b->avlbf = a->avlbf = 0; break; } /* end switch */ c->avlbf = 0; b = c; }