Esempio n. 1
0
void delete_case6(rb_node* n, rb_tree* tree) {
	rb_node* s = sibling(n);

	s->color = n->parent->color;
	n->parent->color = BLACK;

	if (n == n->parent->left) {
		s->right->color = BLACK;
		rotate_left(n->parent, tree);
	} else {
		s->left->color = BLACK;
		rotate_right(n->parent, tree);
	}
}
Esempio n. 2
0
/**
 * Returns the child node of v so that edge leading to the child node starts with the symbol c.
  */
ulong SSTree::child(ulong v, uchar c)
{
    if (isleaf(v))
        return 0;

    v++;   // First child of v
    while (v != 0)
    {
        if (c == edge(v,1))
            return v;
        v = sibling(v);
    }
    return 0;
}
Esempio n. 3
0
void RBTree::delete_fix2(RBNode* n){
     RBNode* s = sibling(n);
          
     if(s->getColor() == ROJO){
          n->father->setColor(ROJO);
          s->setColor(NEGRO);
          //ROtamos respecto al padre.
          if (n->father->left->getKey() == n->getKey() )
              left_rotate(n->father);
          else
              right_rotate(n->father);
     }
     delete_fix3(n);
}
Esempio n. 4
0
bin64_t bin64_t::next_dfsio (uint8_t floor) {
    /*while (ret.is_right())
        ret = ret.parent();
    ret = ret.sibling();
    while (ret.layer()>floor)
        ret = ret.left();*/
    if (is_right()) {
        return parent();
    } else {
        bin64_t ret = sibling();
        while (ret.layer()>floor)
            ret = ret.left();
        return ret;
    }
}
Esempio n. 5
0
void RBTree::delete_fix6(RBNode *n)
{
        RBNode* s = sibling(n);
 
        s->setColor( n->father->getColor() );
        n->father->setColor( NEGRO );
 
        if (n->father->left->getKey() == n->getKey()) {
                s->right->setColor( NEGRO );
                left_rotate(n->father);
        }else {
                s->left->setColor( NEGRO );
                right_rotate(n->father);
        }
}
Esempio n. 6
0
	void AccountsListWidget::on_Profile__released ()
	{
		auto index = Ui_.Accounts_->selectionModel ()->currentIndex ();
		index = index.sibling (index.row (), Columns::Name);
		if (!index.isValid ())
			return;

		QStandardItem *item = AccountsModel_->itemFromIndex (index);
		if (item &&
				Item2Account_.contains (item))
		{
			ProfileDialog *pd = new ProfileDialog (Item2Account_ [item], this);
			pd->setAttribute (Qt::WA_DeleteOnClose);
			pd->show ();
		}
	}
Esempio n. 7
0
static void recolor(JRB n)
{
    JRB p, gp, s;
    int done = 0;

    while (!done) {
        if (isroot(n)) {
            setblack(n);
            return;
        }

        p = n->parent;

        if (isblack(p))
            return;

        if (isroot(p)) {
            setblack(p);
            return;
        }

        gp = p->parent;
        s = sibling(p);
        if (isred(s)) {
            setblack(p);
            setred(gp);
            setblack(s);
            n = gp;
        }
        else {
            done = 1;
        }
    }
    /* p's sibling is black, p is red, gp is black */

    if ((isleft(n) == 0) == (isleft(p) == 0)) {
        single_rotate(gp, isleft(n));
        setblack(p);
        setred(gp);
    }
    else {
        single_rotate(p, isleft(n));
        single_rotate(gp, isleft(n));
        setblack(n);
        setred(gp);
    }
}
Esempio n. 8
0
static inline void
delete_case2(struct RBTREE_TYPENAME* target, struct RBTREE_NODE* P,
             struct RBTREE_NODE* N)
{
  struct RBTREE_NODE* S = sibling(P, N);

  if (S->color == RED)
  {
    P->color = RED;
    S->color = BLACK;
    if (N == P->left)
      rotate_left(target, P);
    else
      rotate_right(target, P);
  }
  delete_case3(target, N);
}
Esempio n. 9
0
/**
 * Prints edge labels of the Suffix tree
 */
void SSTree::PrintTree(ulong v, int depth)
{
    for (int i=0;i< depth;i++)
      printf(" ");

    if (v != 0)
    {
         PrintEdge(v);
    }
    if(!(isleaf(v)))
    {
        PrintTree(v + 1, depth+1);
    }
    v = sibling(v);
    if (v != 0)
        PrintTree(v, depth);
}
Esempio n. 10
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);
}
Esempio n. 11
0
void RBTree::delete_fix5(RBNode* n)
{
     RBNode *s = sibling(n);
 
     if  (s->getColor() == NEGRO) {
         if ((n->father->left->getKey() == n->getKey()) &&
             (s->right->getColor() == NEGRO) &&
             (s->left->getColor() == ROJO)) {
                  s->setColor( ROJO ); 
                  s->left->setColor( NEGRO );
                  right_rotate(s);
         } else if ((n->father->right->getKey() == n->getKey()) &&
                    (s->left->getColor() == NEGRO) &&
                    (s->right->getColor() == ROJO)) {
                        s->setColor( ROJO );
                        s->right->setColor( NEGRO );
                        left_rotate(s);
                }
        }
        delete_fix6(n);
}
Esempio n. 12
0
File: spr.c Progetto: pcordes/allspr
/* A wrapper around dospr():
 * return the tree to its original topology if needed.
 * rejects some useless SPRs (e.g. that don't change the topology)
 * save info so unspr can get back to original topology.
 * returns TRUE if dospr() succeeds and the tree is modified.
 *
 * It's probably easy to make a mess if you call this directly while root
 * moving is going on. e.g. tree->lastspr is checked for some things.
 * Root moving was hacked in as an afterthought.
 */
int spr( struct spr_tree *tree, struct spr_node *src, struct spr_node *dest )
{
	int tmp, unspr_success=FALSE;

	if (tree->unspr_dest){	// back to starting tree
		unspr_success = dospr(tree->unspr_src, tree->unspr_dest);
		tree->root = spr_findroot(tree->unspr_dest);
		if (spr_debug>=2){
			fputs("  unspr back to: ", stderr);
			newickprint(tree->root, stderr);
		}
		assert( unspr_success );
		tree->unspr_dest = NULL;
	}
	if (!src && !dest) return unspr_success;

	// We used to exclude dest==root, but it doesn't break unspr or anything.
	// It always has the same (unrooted) topology as two other trees that spr_next_spr finds.
	// (the root node is the "extra" node, for unrooted vs. rooted tree) */
	if ( !src || !dest ||	// protect against silly callers
	     spr_isancestor(src, dest) || // does this really always catch !(src->parent)?
	     src->parent == dest->parent)  // don't switch siblings
		return FALSE;

	tree->unspr_src = src;
	tree->unspr_dest = sibling(src);

	tmp = dospr(src, dest);
	if (tmp){
		if (!isroot(tree->root)){
			tree->root = spr_findroot(dest);
			if (spr_debug>=2) fputs("allspr: tree has new root!\n", stderr);
		}
		if (spr_debug>=1)
			printf("  did spr %s -> %s\n", src->data->name, dest->data->name);
	}else
		tree->unspr_dest = NULL;

	return tmp;
}
Esempio n. 13
0
void str2node2 (const std::string& str, nodes_t& node)
{
    //assert the node-id of a new node's parent is less than it
    std::vector < std::string > tokens;
    tokenize<std::string>(str, std::back_inserter(tokens));
    unsigned int len = tokens.size() / 2;
    node.resize (len);
    std::vector <int> sibling (len);
    for (unsigned int i=0; i<len; ++i){
        node[i].val = SingleString::get()->getPointer(tokens[2*i]);
        node[i].sibling = -1;
        node[i].child = -1;
        const int parent = atoi(tokens[2*i + 1].c_str()) -1;
        node[i].parent = parent;
        sibling[i] = -1;
        const unsigned int here = i;
        if (parent!=-1){
            if (node[parent].child == -1) node[parent].child = here;
            if (sibling[parent] != -1) node[sibling[parent]].sibling = here;
            sibling[parent] = here;
        };
    };
}
Esempio n. 14
0
static inline void
delete_case6(struct RBTREE_TYPENAME* target,
             struct RBTREE_NODE* N)
{
  struct RBTREE_NODE* P = N->parent;
  struct RBTREE_NODE* S = sibling(P, N);
  S->color = P->color;
  P->color = BLACK;

  tree_side s = which_side(P, N);
  if (s == LEFT)
  {
    S->right->color = BLACK;
    rotate_left(target, P);
  }
  else if (s == RIGHT)
  {
    S->left->color = BLACK;
    rotate_right(target, P);
  }
  else
    valgrind_fail("X");
}
Esempio n. 15
0
void treeDelFixUp(Tree *RBT, Node *node)
{
	Node *p = node->parent;
	Node *s = sibling(node);

	// case 1 : s->red (sibling 기준 회전 -> sibling이 BLACK인 상태로 FixUp)
	if (s->color == RED)
	{
		p->color = RED;
		s->color = BLACK;
		if (node == p->left)
		{
			rotateLeft(RBT, s);
		}
		else
		{
			rotateRight(RBT, s);
		}
		treeDelFixUp(RBT, node);
	}
	else
	{
		// case 2 : left->black, right->black
		if (s->left->color == BLACK && s->right->color == BLACK)
		{
			s->color = RED;
			if (p->color == RED)
			{
				p->color = BLACK;
			}
			else
			{
				treeDelFixUp(RBT,p);
			}
		}
		else
		{
			if (node == p->left)
			{
				// case 3 : left->red, right->black
				if (s->right->color == BLACK)
				{
					s->left->color = BLACK;
					s->color = RED;
					rotateRight(RBT, s->left);
					s = sibling(node);
				}

				// case 4 : left->black/red, right->red
				s->color = p->color;
				p->color = BLACK;
				s->right->color = BLACK;
				rotateLeft(RBT, s);
			}
			else
			{
				// case 3-2 : left->black, right->red
				if (s->left->color == BLACK)
				{
					s->right->color = BLACK;
					s->color = RED;
					rotateLeft(RBT, s->right);
					s = sibling(node);
				}

				// case 4-2 : left->red, right->black/red
				s->color = p->color;
				p->color = BLACK;
				s->left->color = BLACK;
				rotateRight(RBT, s);
			}
		}
	}

	return;
}
Esempio n. 16
0
::DosQModelIndex *dos_qmodelindex_sibling(const ::DosQModelIndex *vptr, int row, int column)
{
    auto index = static_cast<const QModelIndex *>(vptr);
    auto result = new QModelIndex(index->sibling(row, column));
    return static_cast<QModelIndex *>(result);
}
Esempio n. 17
0
File: bt.c Progetto: RobertDash/pspp
/* Inserts the given NODE into BT.
   Returns a null pointer if successful.
   Returns the existing node already in BT equal to NODE, on
   failure. */
struct bt_node *
bt_insert (struct bt *bt, struct bt_node *node)
{
  int depth = 0;

  node->down[0] = NULL;
  node->down[1] = NULL;

  if (bt->root == NULL)
    {
      bt->root = node;
      node->up = NULL;
    }
  else
    {
      struct bt_node *p = bt->root;
      for (;;)
        {
          int cmp, dir;

          cmp = bt->compare (node, p, bt->aux);
          if (cmp == 0)
            return p;
          depth++;

          dir = cmp > 0;
          if (p->down[dir] == NULL)
            {
              p->down[dir] = node;
              node->up = p;
              break;
            }
          p = p->down[dir];
        }
    }

  bt->size++;
  if (bt->size > bt->max_size)
    bt->max_size = bt->size;

  if (depth > calculate_h_alpha (bt->size))
    {
      /* We use the "alternative" method of finding a scapegoat
         node described by Galperin and Rivest. */
      struct bt_node *s = node;
      size_t size = 1;
      int i;

      for (i = 1; ; i++)
        if (i < depth)
          {
            size += 1 + count_nodes_in_subtree (sibling (s));
            s = s->up;
            if (i > calculate_h_alpha (size))
              {
                rebalance_subtree (bt, s, size);
                break;
              }
          }
        else
          {
            rebalance_subtree (bt, bt->root, bt->size);
            bt->max_size = bt->size;
            break;
          }
    }

  return NULL;
}
Esempio n. 18
0
void rb_tree_delete_repair(tree_t *tree, node_t *n)
{
	// przypadek 1: korzeń lub czerwony
    if (is_nil(parent(n)) || n->color == RED)
        return;
    
	// przypadek 2:
    if (sibling(n)->color == RED)
	{
        parent(n)->color = RED;
        sibling(n)->color = BLACK;

        if (is_left_child(n))
            node_rotate_left(tree, parent(n));
        else
            node_rotate_right(tree, parent(n));
    }

	// przypadek 3: 
    if (parent(n)->color == BLACK && sibling(n)->color == BLACK && sibling(n)->left->color == BLACK && sibling(n)->right->color == BLACK)
    {
        sibling(n)->color = RED;
        rb_tree_delete_repair(tree, parent(n));
		return;
    }

	// przypadek 4:
    if (parent(n)->color == RED && sibling(n)->color == BLACK && sibling(n)->left->color == BLACK && sibling(n)->right->color == BLACK)
    {
        sibling(n)->color = RED;
        parent(n)->color = BLACK;
		return;
    }

	// przypadek 5
    if (is_left_child(n) && sibling(n)->color == BLACK && sibling(n)->left->color == RED && sibling(n)->right->color == BLACK)
    {
        sibling(n)->color = RED;
        sibling(n)->left->color = BLACK;

        node_rotate_right(tree, sibling(n));
    }
    else if (is_right_child(n) && sibling(n)->color == BLACK &&	sibling(n)->right->color == RED && sibling(n)->left->color == BLACK)
    {
        sibling(n)->color = RED;
        sibling(n)->right->color = BLACK;

        node_rotate_left(tree, sibling(n));
    }

	// przypadek 6:
    sibling(n)->color = parent(n)->color;
    parent(n)->color = BLACK;

    if (is_left_child(n))
	{
        sibling(n)->right->color = BLACK;

        node_rotate_left(tree, parent(n));
    }
    else
    {
        sibling(n)->left->color = BLACK;

        node_rotate_right(tree, parent(n));
    }
}
 //! spawn right task, serves as callback for partitioner
 void offer_work(const Range& r, depth_t d = 0) {
     start_for sibling(*this, r, d);
     sibling.execute();
     join(sibling.m_executedBegin, sibling.m_executedEnd);
 }
void middle() {
  sleeper();
  sibling();
  recurser();
}
Esempio n. 21
0
File: rb.cpp Progetto: edsomjr/TEP
 Node * uncle(Node* node)
 {
     return sibling(parent(node));
 } 
static gboolean
ring_notify_show_text_message(ContactMethod *cm, const QModelIndex& idx)
{
    g_return_val_if_fail(idx.isValid() && cm, FALSE);
    gboolean success = FALSE;

    auto title = g_markup_printf_escaped(C_("Text message notification", "%s says:"), idx.data(static_cast<int>(Ring::Role::Name)).toString().toUtf8().constData());
    auto body = g_markup_escape_text(idx.data(Qt::DisplayRole).toString().toUtf8().constData(), -1);

    NotifyNotification *notification_new = nullptr;
    NotifyNotification *notification_old = nullptr;

    /* try to get the previous notification */
    auto chat_table = ring_notify_get_chat_table();
    auto list = (GList *)g_hash_table_lookup(chat_table, cm);
    if (list)
        notification_old = (NotifyNotification *)list->data;

    /* we display chat notifications in different ways to suit different notification servers and
     * their capabilities:
     * 1. if the server doesn't support appending (eg: Notification Daemon) then we update the
     *    previous notification (if exists) with new text; otherwise it takes we have many
     *    notifications from the same person... we don't concatinate the old messages because
     *    servers which don't support append usually don't support multi line bodies
     * 2. the notify-osd server supports appending; however it doesn't clear the old notifications
     *    on demand, which means in our case that chat messages which have already been read could
     *    still be displayed when a new notification is appended, thus in this case, we update
     *    the old notification body manually to only contain the unread messages
     * 3. the 3rd case is that the server supports append but is not notify-osd, then we simply use
     *    the append feature
     */

    if (notification_old && !server_info.append) {
        /* case 1 */
        notify_notification_update(notification_old, title, body, nullptr);
        notification_new = notification_old;
    } else if (notification_old && g_strcmp0(server_info.name, SERVER_NOTIFY_OSD) == 0) {
        /* case 2 */
        /* print up to MAX_NOTIFICATIONS unread messages */
        int msg_count = 0;
        auto idx_next = idx.sibling(idx.row() - 1, idx.column());
        auto read = idx_next.data(static_cast<int>(Media::TextRecording::Role::IsRead)).toBool();
        while (idx_next.isValid() && !read && msg_count < MAX_NOTIFICATIONS) {

            auto body_prev = body;
            body = g_markup_printf_escaped("%s\n%s", body_prev, idx_next.data(Qt::DisplayRole).toString().toUtf8().constData());
            g_free(body_prev);

            idx_next = idx_next.sibling(idx_next.row() - 1, idx_next.column());
            read = idx_next.data(static_cast<int>(Media::TextRecording::Role::IsRead)).toBool();
            ++msg_count;
        }

        notify_notification_update(notification_old, title, body, nullptr);

        notification_new = notification_old;
    } else {
        /* need new notification for case 1, 2, or 3 */
        notification_new = notify_notification_new(title, body, nullptr);

        /* track in hash table */
        auto list = (GList *)g_hash_table_lookup(chat_table, cm);
        list = g_list_append(list, notification_new);
        g_hash_table_replace(chat_table, cm, list);

        /* get photo */
        QVariant var_p = GlobalInstances::pixmapManipulator().callPhoto(
            cm, QSize(50, 50), false);
        std::shared_ptr<GdkPixbuf> photo = var_p.value<std::shared_ptr<GdkPixbuf>>();
        notify_notification_set_image_from_pixbuf(notification_new, photo.get());

        /* normal priority for messages */
        notify_notification_set_urgency(notification_new, NOTIFY_URGENCY_NORMAL);

        /* remove the key and value from the hash table once the notification is
         * closed; note that this will also unref the notification */
        g_signal_connect(notification_new, "closed", G_CALLBACK(notification_closed), cm);

        /* if the notification server supports actions, make the default action to show the chat view */
        if (server_info.actions) {
            notify_notification_add_action(notification_new,
                                           "default",
                                           C_("notification action name", "Show"),
                                           (NotifyActionCallback)ring_notify_show_cm,
                                           cm,
                                           nullptr);
        }
    }

    GError *error = nullptr;
    success = notify_notification_show(notification_new, &error);
    if (!success) {
        g_warning("failed to show notification: %s", error->message);
        g_clear_error(&error);
    }

    g_free(title);
    g_free(body);

    return success;
}
Esempio n. 23
0
void SSTree::tree_lookup(ulong v, int *_enclose){
  if (v != 0) add_enclose(v, _enclose);
  if(!(isleaf(v))) tree_lookup(v + 1, _enclose);
  v = sibling(v);
  if (v != 0) tree_lookup(v, _enclose);
}
Esempio n. 24
0
	void appendSibling (T * data) {
		Node sibling(data);
		siblings.push_back(sibling);
	}
Esempio n. 25
0
void delete_case5(struct rbtree *t, rbtree_node *n)
{
    if (n == n->parent->left &&
            get_color(sibling(n)) ==RB_BLACK &&
            get_color(sibling(n)->left) == RB_RED &&
            get_color(sibling(n)->right) == RB_BLACK)
    {
        sibling(n)->color = RB_RED;
        sibling(n)->left->color =RB_BLACK;
        rotate_right(sibling(n),t);
    }
    else if (n == n->parent->right &&
            get_color(sibling(n)) == RB_BLACK &&
            get_color(sibling(n)->right) == RB_RED &&
            get_color(sibling(n)->left) == RB_BLACK)
    {
        sibling(n)->color = RB_RED;
        sibling(n)->right->color = RB_BLACK;
        rotate_left(sibling(n),t);
    }
    delete_case6(t, n);
}
 //! spawn right task, serves as callback for partitioner
 void offer_work(typename Partitioner::split_type& split_obj) {
     start_for sibling(*this, split_obj);
     sibling.execute();
     join(sibling.m_executedBegin, sibling.m_executedEnd);
 }
Esempio n. 27
0
void jrb_delete_node(JRB n)
{
  JRB s, p, gp;
  char ir;

  if (isint(n)) {
    fprintf(stderr, "Cannot delete an internal node: 0x%p\n", (void *)n);
    exit(1);
  }
  if (ishead(n)) {
    fprintf(stderr, "Cannot delete the head of an jrb_tree: 0x%p\n", (void *)n);
    exit(1);
  }
  delete_item(n); /* Delete it from the list */
  p = n->parent;  /* The only node */
  if (isroot(n)) {
    p->parent = p;
    free(n);
    return;
  }
  s = sibling(n);    /* The only node after deletion */
  if (isroot(p)) {
    s->parent = p->parent;
    s->parent->parent = s;
    setroot(s);
    free(p);
    free(n);
    return;
  }
  gp = p->parent;  /* Set parent to sibling */
  s->parent = gp;
  if (isleft(p)) {
    gp->flink = s;
    setleft(s);
  } else {
    gp->blink = s;
    setright(s);
  }
  ir = isred(p);
  free(p);
  free(n);

  if (isext(s)) {      /* Update proper rext and lext values */
    p = lprev(s);
    if (!ishead(p)) setrext(p, s);
    p = rprev(s);
    if (!ishead(p)) setlext(p, s);
  } else if (isblack(s)) {
    fprintf(stderr, "DELETION PROB -- sib is black, internal\n");
    exit(1);
  } else {
    p = lprev(s);
    if (!ishead(p)) setrext(p, s->flink);
    p = rprev(s);
    if (!ishead(p)) setlext(p, s->blink);
    setblack(s);
    return;
  }

  if (ir) return;

  /* Recolor */

  n = s;
  p = n->parent;
  s = sibling(n);
  while(isblack(p) && isblack(s) && isint(s) &&
        isblack(s->flink) && isblack(s->blink)) {
    setred(s);
    n = p;
    if (isroot(n)) return;
    p = n->parent;
    s = sibling(n);
  }

  if (isblack(p) && isred(s)) {  /* Rotation 2.3b */
    single_rotate(p, isright(n));
    setred(p);
    setblack(s);
    s = sibling(n);
  }

  { JRB x, z; char il;

    if (isext(s)) {
      fprintf(stderr, "DELETION ERROR: sibling not internal\n");
      exit(1);
    }

    il = isleft(n);
    x = il ? s->flink : s->blink ;
    z = sibling(x);

    if (isred(z)) {  /* Rotation 2.3f */
      single_rotate(p, !il);
      setblack(z);
      if (isred(p)) setred(s); else setblack(s);
      setblack(p);
    } else if (isblack(x)) {   /* Recoloring only (2.3c) */
      if (isred(s) || isblack(p)) {
        fprintf(stderr, "DELETION ERROR: 2.3c not quite right\n");
        exit(1);
      }
      setblack(p);
      setred(s);
      return;
    } else if (isred(p)) { /* 2.3d */
      single_rotate(s, il);
      single_rotate(p, !il);
      setblack(x);
      setred(s);
      return;
    } else {  /* 2.3e */
      single_rotate(s, il);
      single_rotate(p, !il);
      setblack(x);
      return;
    }
  }
}
Esempio n. 28
0
void delete_case5(rbtree t, node n) {
    if (n == n->parent->left &&
            node_color(sibling(n)) == BLACK &&
            node_color(sibling(n)->left) == RED &&
            node_color(sibling(n)->right) == BLACK)
    {
        sibling(n)->color = RED;
        sibling(n)->left->color = BLACK;
        rotate_right(t, sibling(n));
    }
    else if (n == n->parent->right &&
             node_color(sibling(n)) == BLACK &&
             node_color(sibling(n)->right) == RED &&
             node_color(sibling(n)->left) == BLACK)
    {
        sibling(n)->color = RED;
        sibling(n)->right->color = BLACK;
        rotate_left(t, sibling(n));
    }
    delete_case6(t, n);
}
Esempio n. 29
0
static void delete_case5(L_RBTREE *t, node *n) {
    if (n == n->parent->left &&
        node_color(sibling(n)) == L_BLACK_NODE &&
        node_color(sibling(n)->left) == L_RED_NODE &&
        node_color(sibling(n)->right) == L_BLACK_NODE) {
        sibling(n)->color = L_RED_NODE;
        sibling(n)->left->color = L_BLACK_NODE;
        rotate_right(t, sibling(n));
    } else if (n == n->parent->right &&
               node_color(sibling(n)) == L_BLACK_NODE &&
               node_color(sibling(n)->right) == L_RED_NODE &&
               node_color(sibling(n)->left) == L_BLACK_NODE) {
        sibling(n)->color = L_RED_NODE;
        sibling(n)->right->color = L_BLACK_NODE;
        rotate_left(t, sibling(n));
    }
    delete_case6(t, n);
}
Esempio n. 30
0
node uncle(node n) {
    assert (n != NULL);
    assert (n->parent != NULL); /* Root node has no uncle */
    assert (n->parent->parent != NULL); /* Children of root have no uncle */
    return sibling(n->parent);
}