void Splay (Node * &o,int k)
{
int d=o->cmp (k); The//CMP function compares the sizes of K and o->ch[0]->s+1
if (d==1) k-=o->ch[0]->s+1;
if (d!=-1)
{
Node *p=o->ch[d];
int d2=p->cmp (k);
int k2= (D2==0?K:K-P->CH[0]->S-1);
if (d2!=-1)
{
Splay (P->CH[D2],K2);
if (d==d2) rotate (o,d^1),/* This time has extended the K-node to, P->ch[d2], when D==d2, stating three points
Collinear, you can first turn o to o d^1 direction, then O Point is P, and then let O in the same direction rotation once, this way of rotation and the book said first rotation x Father node
The effect of rotating x again is the same.
*/
else rotate (o->ch[d],d);/* When D!=d2, the three point is not collinear, then p->ch[d2] rotate to the position of P then, then in the O for the node to D rotation and the book
When the three points are not collinear, the rotation of the opposite rotation two times X is the same effect
*/
}
Rotate (o,d^1);
}
}
Great White Book Stretching tree study notes