Beispiel #1
0
/**
 * @brief If sibling is black and its both children are black, perform recoloring, and recur for the parent.
 * @param t is the tree root.
 * @param n is the node at which deletion is taking place.
 */
void delete_case3(rbtree t, node n)
{
    if (node_color(n->parent) == BLACK && node_color(sibling(n)) == BLACK && node_color(sibling(n)->left) == BLACK && node_color(sibling(n)->right) == BLACK)
    {
        sibling(n)->color = RED;
        delete_case1(t, n->parent);
    }
    else
        delete_case4(t, n);
}
Beispiel #2
0
static void delete_case3(L_RBTREE *t, node *n) {
    if (node_color(n->parent) == L_BLACK_NODE &&
        node_color(sibling(n)) == L_BLACK_NODE &&
        node_color(sibling(n)->left) == L_BLACK_NODE &&
        node_color(sibling(n)->right) == L_BLACK_NODE) {
        sibling(n)->color = L_RED_NODE;
        delete_case1(t, n->parent);
    } else {
        delete_case4(t, n);
    }
}
Beispiel #3
0
void delete_case3(rb_node* n, rb_tree* tree) {
	rb_node* s = sibling(n);

	if ((n->parent->color == BLACK) &&
	(s->color == BLACK) &&
	(s->left->color == BLACK) &&
	(s->right->color == BLACK)) {
		s->color = RED;
		delete_case1(n->parent, tree);
	} else {
		delete_case4(n, tree);
	}
}
Beispiel #4
0
void delete_case3(struct rbtree* tree,struct rbtree_node* node)
{
    if(node->parent->color == RB_BLACK &&
            get_color(sibling(node)) == RB_BLACK &&
            get_color(sibling(node)->right) == RB_BLACK &&
            get_color(sibling(node)->left) == RB_BLACK)
    {
        sibling(node)->color = RB_RED;
        delete_case1(tree, node->parent);
    }
    else
    {
        delete_case4(tree, node);
    }

}
Beispiel #5
0
void Tree::delete_case3()
{
	if(!(parent->red) && !(sibling()->red))
	{
		//so assuming that we didn't go through the previous case
		//and have black parent and black sibling
		//we have to fix the fact that we will be removing 
		//a black node from a path
		//so we turn sibling red and repeat everything on the parent
		sibling()->red = true;
		parent->delete_case1();
	}
	else
		//if we went through delete_case2 rotations go straigth through
		delete_case4();
}
Beispiel #6
0
static void
delete_case3(struct RBTREE_TYPENAME* target,
             struct RBTREE_NODE* N)
{
  struct RBTREE_NODE* P = N->parent;
  struct RBTREE_NODE* S = sibling(P, N);

  if ((P->color == BLACK) &&
      (S->color == BLACK) &&
      (S->left  == NULL || S->left->color  == BLACK) &&
      (S->right == NULL || S->right->color == BLACK))
  {
    S->color = RED;
    delete_case1(target, P->parent, P);
  }
  else
    delete_case4(target, P, N, S);
}