(int i)
| 79 | // 如果命中了某种违规情况,就进行相应调整 |
| 80 | // 返回树的头节点的空间编号 |
| 81 | public static int maintain(int i) { |
| 82 | int lh = height[left[i]]; |
| 83 | int rh = height[right[i]]; |
| 84 | if (lh - rh > 1) { |
| 85 | if (height[left[left[i]]] >= height[right[left[i]]]) { |
| 86 | i = rightRotate(i); |
| 87 | } else { |
| 88 | left[i] = leftRotate(left[i]); |
| 89 | i = rightRotate(i); |
| 90 | } |
| 91 | } else if (rh - lh > 1) { |
| 92 | if (height[right[right[i]]] >= height[left[right[i]]]) { |
| 93 | i = leftRotate(i); |
| 94 | } else { |
| 95 | right[i] = rightRotate(right[i]); |
| 96 | i = leftRotate(i); |
| 97 | } |
| 98 | } |
| 99 | return i; |
| 100 | } |
| 101 | |
| 102 | // 增加数字num,重复加入算多个词频 |
| 103 | public static void add(int num) { |
no test coverage detected