(Node h)
| 238 | } |
| 239 | |
| 240 | private Node balance(Node h) { |
| 241 | // assert (h != null); |
| 242 | |
| 243 | if (isRed(h.right) && !isRed(h.left)) h = rotateLeft(h); |
| 244 | if (isRed(h.left) && isRed(h.left.left)) h = rotateRight(h); |
| 245 | if (isRed(h.left) && isRed(h.right)) flipColors(h); |
| 246 | |
| 247 | h.size = size(h.left) + size(h.right) + 1; |
| 248 | return h; |
| 249 | } |
| 250 | |
| 251 | public int height() { |
| 252 | return height(root); |
no test coverage detected