private void rotateRight ( final Node < K , V > node , final int index ) { Node < K , V > leftChild = node . getLeft ( index ) ; node . setLeft ( leftChild . getRight ( index ) , index ) ; if ( leftChild . getRight ( index ) != null ) { leftChild . getRight ( index ) . setParent ( node , index ) ; } leftChild . setParent ( node . getParent ( index ) , index ) ; if ( node . getParent ( index ) == null ) { // node was the root ... now its left child is the root rootNode [ index ] = leftChild ; } else if ( node . getParent ( index ) . getRight ( index ) == node ) { node . getParent ( index ) . setRight ( leftChild , index ) ; } else { node . getParent ( index ) . setLeft ( leftChild , index ) ; } leftChild . setRight ( node , index ) ; node . setParent ( leftChild , index ) ; }
do a rotate right . standard fare in the world of balanced trees