do a rotate left. standard fare in the world of balanced trees @param node the node to be rotated @param index _KEY or _VALUE
(Node node, int index)
| 741 | * @param index _KEY or _VALUE |
| 742 | */ |
| 743 | private void rotateLeft(Node node, int index) |
| 744 | { |
| 745 | Node right_child = node.getRight(index); |
| 746 | |
| 747 | node.setRight(right_child.getLeft(index), index); |
| 748 | if (right_child.getLeft(index) != null) |
| 749 | { |
| 750 | right_child.getLeft(index).setParent(node, index); |
| 751 | } |
| 752 | right_child.setParent(node.getParent(index), index); |
| 753 | if (node.getParent(index) == null) |
| 754 | { |
| 755 | |
| 756 | // node was the root ... now its right child is the root |
| 757 | _root[ index ] = right_child; |
| 758 | } |
| 759 | else if (node.getParent(index).getLeft(index) == node) |
| 760 | { |
| 761 | node.getParent(index).setLeft(right_child, index); |
| 762 | } |
| 763 | else |
| 764 | { |
| 765 | node.getParent(index).setRight(right_child, index); |
| 766 | } |
| 767 | right_child.setLeft(node, index); |
| 768 | node.setParent(right_child, index); |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * do a rotate right. standard fare in the world of balanced trees |