/*internal routine that performs single or double rotation because the result is attached to the parentthere are four cases called by handlereorient item is the item in handlereorient theparent is the parent of the root of the rotated subtree return the root of the rotated subtree *redblacknode rotateconst comparable itemredblacknode *theparent ifitem element item left->element rotatewithleftchildtheparent->left /ll rotatewithrightchildtheparent->left /lr return theparent->leftelse item right->element rotatewithleftchildtheparent->right /rl rotatewithrightchildtheparent->right )/rr return theparent->rightfigure rotate method /*internal routine that is called during an insertion if node has two red children performs flip and rotations item is the item being inserted *void handlereorientconst comparable item /do the color flip current->color redcurrent->left->color blackcurrent->right->color blackifparent->color =red figure insertion procedure /have to rotate