()
| 852 | } |
| 853 | |
| 854 | private AvlNode<E> rebalance() { |
| 855 | switch (balanceFactor()) { |
| 856 | case -2: |
| 857 | if (right.balanceFactor() > 0) { |
| 858 | right = right.rotateRight(); |
| 859 | } |
| 860 | return rotateLeft(); |
| 861 | case 2: |
| 862 | if (left.balanceFactor() < 0) { |
| 863 | left = left.rotateLeft(); |
| 864 | } |
| 865 | return rotateRight(); |
| 866 | default: |
| 867 | recomputeHeight(); |
| 868 | return this; |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | private int balanceFactor() { |
| 873 | return height(left) - height(right); |
no test coverage detected