src/rbtree.c
static void
rbtree_rotate(struct rbtree *tree, struct rbtree_node *node, int direction)
{
    struct rbtree_node *parent, *rnode;
    int left, right;

    left = direction;
    right = 1 - left;
    parent = rbtree_node_parent(node);
    rnode = node->children[right];

    node->children[right] = rnode->children[left];

    if (rnode->children[left] != NULL) {
        rbtree_node_set_parent(rnode->children[left], node);
    }

    rnode->children[left] = node;
    rbtree_node_set_parent(rnode, parent);

    if (unlikely(parent == NULL)) {
        tree->root = rnode;
    } else {
        parent->children[rbtree_node_index(node, parent)] = rnode;
    }

    rbtree_node_set_parent(node, rnode);
}
/*
 * Perform a tree rotation, rooted at the given node.
 *
 * The direction parameter defines the rotation direction and is either
 * RBTREE_LEFT or RBTREE_RIGHT.
 */
Perform a tree rotation, rooted at the given node.
The direction parameter defines the rotation direction and is either
RBTREE_LEFT or RBTREE_RIGHT.
Perform a tree rotation rooted at the given node . The direction parameter defines the rotation direction and is either RBTREE_LEFT or RBTREE_RIGHT .
static void
rbtree_rotate(struct rbtree *tree, struct rbtree_node *node, int direction)
{
    struct rbtree_node *parent, *rnode;
    int left, right;
    left = direction;
    right = 1 - left;
    parent = rbtree_node_parent(node);
    rnode = node->children[right];
    node->children[right] = rnode->children[left];
    if (rnode->children[left] != NULL) {
        rbtree_node_set_parent(rnode->children[left], node);
    }
    rnode->children[left] = node;
    rbtree_node_set_parent(rnode, parent);
    if (unlikely(parent == NULL)) {
        tree->root = rnode;
    } else {
        parent->children[rbtree_node_index(node, parent)] = rnode;
    }
    rbtree_node_set_parent(node, rnode);
}
static void rbtree_rotate ( struct rbtree * tree , struct rbtree_node * node , int direction ) { struct rbtree_node * parent , * rnode ; int left , right ; left = direction ; right = 1 - left ; parent = rbtree_node_parent ( node ) ; rnode = node -> children [ right ] ; node -> children [ right ] = rnode -> children [ left ] ; if ( rnode -> children [ left ] != NULL ) { rbtree_node_set_parent ( rnode -> children [ left ] , node ) ; } rnode -> children [ left ] = node ; rbtree_node_set_parent ( rnode , parent ) ; if ( unlikely ( parent == NULL ) ) { tree -> root = rnode ; } else { parent -> children [ rbtree_node_index ( node , parent ) ] = rnode ; } rbtree_node_set_parent ( node , rnode ) ; }
Perform a tree rotation, rooted at the given node.
Perform a tree rotation rooted at the given node .