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