(int i, int goal)
| 80 | } |
| 81 | |
| 82 | public static void splay(int i, int goal) { |
| 83 | int f = father[i], g = father[f]; |
| 84 | while (f != goal) { |
| 85 | if (g != goal) { |
| 86 | if (lr(i) == lr(f)) { |
| 87 | rotate(f); |
| 88 | } else { |
| 89 | rotate(i); |
| 90 | } |
| 91 | } |
| 92 | rotate(i); |
| 93 | f = father[i]; |
| 94 | g = father[f]; |
| 95 | } |
| 96 | if (goal == 0) { |
| 97 | head = i; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // 返回中序排名为rank的节点编号 |
| 102 | public static int find(int rank) { |