本文整理汇总了C++中ACE_RB_Tree_Node::color方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_RB_Tree_Node::color方法的具体用法?C++ ACE_RB_Tree_Node::color怎么用?C++ ACE_RB_Tree_Node::color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_RB_Tree_Node
的用法示例。
在下文中一共展示了ACE_RB_Tree_Node::color方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::
dump_node_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> &node) const
{
#if defined (ACE_HAS_DUMP)
const char * color_str = (node.color () == ACE_RB_Tree_Node_Base::RED)
? "RED" : "BLACK";
ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" color=[%s]\n"), color_str));
#else /* !ACE_HAS_DUMP */
ACE_UNUSED_ARG (node);
#endif /* ACE_HAS_DUMP */
}
示例2:
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)
{
ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)");
// Delete the node and reorganize the tree to satisfy the Red-Black
// properties.
ACE_RB_Tree_Node<EXT_ID, INT_ID> *x;
ACE_RB_Tree_Node<EXT_ID, INT_ID> *y;
ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent;
if (z->left () && z->right ())
y = RB_tree_successor (z);
else
y = z;
if (!y)
return -1;
if (y->left ())
x = y->left ();
else
x = y->right ();
parent = y->parent ();
if (x)
{
x->parent (parent);
}
if (parent)
{
if (y == parent->left ())
parent->left (x);
else
parent->right (x);
}
else
this->root_ = x;
if (y != z)
{
// Replace node z with node y, since y's pointer may well be
// held externally, and be linked with y's key and item.
// We will end up deleting the old unlinked, node z.
ACE_RB_Tree_Node<EXT_ID, INT_ID> *zParent = z->parent ();
ACE_RB_Tree_Node<EXT_ID, INT_ID> *zLeftChild = z->left ();
ACE_RB_Tree_Node<EXT_ID, INT_ID> *zRightChild = z->right ();
if (zParent)
{
if (z == zParent->left ())
{
zParent->left (y);
}
else
{
zParent->right (y);
}
}
else
{
this->root_ = y;
}
y->parent (zParent);
if (zLeftChild)
{
zLeftChild->parent (y);
}
y->left (zLeftChild);
if (zRightChild)
{
zRightChild->parent (y);
}
y->right (zRightChild);
if (parent == z)
{
parent = y;
}
ACE_RB_Tree_Node_Base::RB_Tree_Node_Color yColor = y->color ();
y->color (z->color ());
z->color (yColor);
//Reassign the y pointer to z because the node that y points to will be
//deleted
y = z;
}
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (!y || y->color () == ACE_RB_Tree_Node_Base::BLACK)
RB_delete_fixup (x, parent);
y->parent (0);
y->right (0);
//.........这里部分代码省略.........
示例3: while
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> void
ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::
RB_delete_fixup (ACE_RB_Tree_Node<EXT_ID, INT_ID> *x,
ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent)
{
ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup");
while (x != this->root_
&& (!x
|| x->color () == ACE_RB_Tree_Node_Base::BLACK))
{
if (x == parent->left ())
{
ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = parent->right ();
if (w && w->color () == ACE_RB_Tree_Node_Base::RED)
{
w->color (ACE_RB_Tree_Node_Base::BLACK);
parent->color (ACE_RB_Tree_Node_Base::RED);
RB_rotate_left (parent);
w = parent->right ();
}
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (w
&& (!w->left ()
|| w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)
&& (!w->right ()
|| w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
{
w->color (ACE_RB_Tree_Node_Base::RED);
x = parent;
parent = x->parent ();
}
else
{
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (w
&& (!w->right ()
|| w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
{
if (w->left ())
w->left ()->color (ACE_RB_Tree_Node_Base::BLACK);
w->color (ACE_RB_Tree_Node_Base::RED);
RB_rotate_right (w);
w = parent->right ();
}
if (w)
{
w->color (parent->color ());
if (w->right ())
w->right ()->color (ACE_RB_Tree_Node_Base::BLACK);
}
parent->color (ACE_RB_Tree_Node_Base::BLACK);
RB_rotate_left (parent);
x = root_;
}
}
else
{
ACE_RB_Tree_Node<EXT_ID, INT_ID> *w = parent->left ();
if (w && w->color () == ACE_RB_Tree_Node_Base::RED)
{
w->color (ACE_RB_Tree_Node_Base::BLACK);
parent->color (ACE_RB_Tree_Node_Base::RED);
RB_rotate_right (parent);
w = parent->left ();
}
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (w
&& (!w->left ()
|| w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)
&& (!w->right ()
|| w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK))
{
w->color (ACE_RB_Tree_Node_Base::RED);
x = parent;
parent = x->parent ();
}
else
{
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (w
&& (!w->left ()
|| w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK))
{
w->color (ACE_RB_Tree_Node_Base::RED);
if (w->right ())
w->right ()->color (ACE_RB_Tree_Node_Base::BLACK);
RB_rotate_left (w);
w = parent->left ();
}
if (w)
{
w->color (parent->color ());
if (w->left ())
w->left ()->color (ACE_RB_Tree_Node_Base::BLACK);
}
parent->color (ACE_RB_Tree_Node_Base::BLACK);
RB_rotate_right (parent);
x = root_;
}
//.........这里部分代码省略.........
示例4:
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK> int
ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)
{
ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<EXT_ID, INT_ID> *z)");
// Delete the node and reorganize the tree to satisfy the Red-Black
// properties.
ACE_RB_Tree_Node<EXT_ID, INT_ID> *x;
ACE_RB_Tree_Node<EXT_ID, INT_ID> *y;
ACE_RB_Tree_Node<EXT_ID, INT_ID> *parent;
if (z->left () && z->right ())
y = RB_tree_successor (z);
else
y = z;
if (!y)
return -1;
if (y->left ())
x = y->left ();
else
x = y->right ();
parent = y->parent ();
if (x)
{
x->parent (parent);
}
if (parent)
{
if (y == parent->left ())
parent->left (x);
else
parent->right (x);
}
else
this->root_ = x;
if (y != z)
{
// Copy the elements of y into z.
z->key () = y->key ();
z->item () = y->item ();
}
// CLR pp. 263 says that nil nodes are implicitly colored BLACK
if (!y || y->color () == ACE_RB_Tree_Node_Base::BLACK)
RB_delete_fixup (x, parent);
y->parent (0);
y->right (0);
y->left (0);
ACE_DES_FREE_TEMPLATE2 (y,
this->allocator_->free,
ACE_RB_Tree_Node,
EXT_ID, INT_ID);
--this->current_size_;
return 0;
}