fn splay(&mut self, c: usize) {
        loop {
            // Variables:
            // - `c` is the current node
            // - `p` is it's parent
            // - `g` is it's grandparent

            // Find the parent.
            let p = self.arena[c].parent;
            if p == NULL {
                // There is no parent. That means `c` is the root.
                break;
            }

            // Find the grandparent.
            let g = self.arena[p].parent;
            if g == NULL {
                // There is no grandparent. Just one more rotation is left.
                // Zig step.
                self.rotate(p, c);
                break;
            }

            if (self.arena[g].children[0] == p) == (self.arena[p].children[0] == c) {
                // Zig-zig step.
                self.rotate(g, p);
                self.rotate(p, c);
            } else {
                // Zig-zag step.
                self.rotate(p, c);
                self.rotate(g, c);
            }
        }
    }
/// Splays a node, rebalancing the tree in process.
Splays a node, rebalancing the tree in process.
Splays a node rebalancing the tree in process .
fn splay(&mut self, c: usize) {
        loop {
            // Variables:
            // - `c` is the current node
            // - `p` is it's parent
            // - `g` is it's grandparent
            // Find the parent.
            let p = self.arena[c].parent;
            if p == NULL {
                // There is no parent. That means `c` is the root.
                break;
            }
            // Find the grandparent.
            let g = self.arena[p].parent;
            if g == NULL {
                // There is no grandparent. Just one more rotation is left.
                // Zig step.
                self.rotate(p, c);
                break;
            }
            if (self.arena[g].children[0] == p) == (self.arena[p].children[0] == c) {
                // Zig-zig step.
                self.rotate(g, p);
                self.rotate(p, c);
            } else {
                // Zig-zag step.
                self.rotate(p, c);
                self.rotate(g, c);
            }
        }
    }
fn splay ( & mut self , c : usize ) { loop { // Variables: // - `c` is the current node // - `p` is it's parent // - `g` is it's grandparent // Find the parent. let p = self . arena [ c ] . parent ; if p == NULL { // There is no parent. That means `c` is the root. break ; } // Find the grandparent. let g = self . arena [ p ] . parent ; if g == NULL { // There is no grandparent. Just one more rotation is left. // Zig step. self . rotate ( p , c ) ; break ; } if ( self . arena [ g ] . children [ 0 ] == p ) == ( self . arena [ p ] . children [ 0 ] == c ) { // Zig-zig step. self . rotate ( g , p ) ; self . rotate ( p , c ) ; } else { // Zig-zag step. self . rotate ( p , c ) ; self . rotate ( g , c ) ; } } }
Splays a node, rebalancing the tree in process.
Splays a node rebalancing the tree in process .
&mut self
c
usize
&mut self
c
usize