예제 #1
0
static void insert_case4(L_RBTREE *t, node *n) {
    if (n == n->parent->right && n->parent == grandparent(n)->left) {
        rotate_left(t, n->parent);
        n = n->left;
    } else if (n == n->parent->left && n->parent == grandparent(n)->right) {
        rotate_right(t, n->parent);
        n = n->right;
    }
    insert_case5(t, n);
}
예제 #2
0
void insert_case4(rbtree t, node n) {
    if (n == n->parent->right && n->parent == grandparent(n)->left) {
        rotate_left(t, n->parent);
        n = n->left;
    } else if (n == n->parent->left && n->parent == grandparent(n)->right) {
        rotate_right(t, n->parent);
        n = n->right;
    }
    insert_case5(t, n);
}
예제 #3
0
파일: rb_tree.c 프로젝트: hvidgaard/AADS
void insert_case4(rb_node* n, rb_tree* tree) {
	rb_node* g = grandparent(n);
	
	if ((n == n->parent->right) && (n->parent == g->left)) {
		rotate_left(n->parent, tree);
		n = n->left;
	}
	else if ((n == n->parent->left) && (n->parent == g->right)) {
		rotate_right(n->parent, tree);
		n = n->right;
	}
	insert_case5(n, tree);
}
예제 #4
0
static void
insert_case4(struct RBTREE_TYPENAME* target, struct RBTREE_NODE* node)
{
  DEBUG_RBTREE("insert_case4\n");
  struct RBTREE_NODE* g = grandparent(node);

  if ((node == node->parent->right) && (node->parent == g->left))
  {
    rotate_left(target, node->parent);
    node = node->left;
  }
  else if ((node == node->parent->left) && (node->parent == g->right))
  {
    rotate_right(target, node->parent);
    node = node->right;
  }
  insert_case5(target, node);
}
예제 #5
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  insert_case4
 *  Description:  Covers the case where the parent is RED but the uncle is BLACK
 * =====================================================================================
 */
static void insert_case4 
    ( 
    set * n
    )
{
set * g = grandparent(n);
if((n == n->parent->right)
&& (n->parent == g->left))
    {
    rotate_left(n->parent);
    n = n->left;
    }
else if((n == n->parent->left)
     && (n->parent == g->right))
    {
    rotate_right(n->parent);
    n = n->right;
    }
insert_case5(n);
}		/* -----  end of static function insert_case4  ----- */