I want to rewrite (for educational purposes) Red-Black Tree data structure(from Sedgewick, Algorithms 4th ed.)
For example, I have an issue doing safe rotation (rotation left and right), any suggestions on how to do it properly?
My code
Sedgewick example in java, full-example
Summary
private Node rotateLeft(Node h) {
assert isRed(h.right);
Node x = h.right;
h.right = x.left;
h.color = RED;
x.left = h;
x.color = h.color;
x.size = h.size;
h.size = size(h.left) + size(h.right) + 1;
return x;
}