Code:
static void
pvt_left_rotate(struct clib_rb_t *pTree, struct clib_rb_node_t *x){
struct clib_rb_node_t *y;
y = x->right;
x->right = y->left;
if (y->left != rb_sentinel)
y->left->parent = x;
if (y != rb_sentinel)
y->parent = x->parent;
if (x->parent){
if (x == x->parent->left)
x->parent->left = y;
else
x->parent->right = y;
}
else
pTree->root = y;
y->left = x;
if (x != rb_sentinel)
x->parent = y;
}
static void
pvt_right_rotate(struct clib_rb_t *pTree, struct clib_rb_node_t *x) {
struct clib_rb_node_t *y = x->left;
x->left = y->right;
if (y->right != rb_sentinel)
y->right->parent = x;
if (y != rb_sentinel)
y->parent = x->parent;
if (x->parent) {
if (x == x->parent->right)
x->parent->right = y;
else
x->parent->left = y;
}
else
pTree->root = y;
y->right = x;
if (x != rb_sentinel)
x->parent = y;
}
More Details: SourceForge.net Repository - [clibutils] Contents of /src/c_rb.c