summaryrefslogtreecommitdiff
path: root/ace/RB_Tree.cpp
diff options
context:
space:
mode:
authorjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-30 02:59:01 +0000
committerjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-30 02:59:01 +0000
commite12dec23472e539a3e43b14e6276a647ef3bc6a7 (patch)
treea76e826a1910d352a0bd30d75900f3397bf6e2cc /ace/RB_Tree.cpp
parenta71b451ff1a46023c9d145da43e2c2a39296483d (diff)
downloadATCD-e12dec23472e539a3e43b14e6276a647ef3bc6a7.tar.gz
Debugged some minor typo errors, and changes related to internalizing
the RED and BLACK enums.
Diffstat (limited to 'ace/RB_Tree.cpp')
-rw-r--r--ace/RB_Tree.cpp51
1 files changed, 26 insertions, 25 deletions
diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp
index d8ff3786993..df1a7133f73 100644
--- a/ace/RB_Tree.cpp
+++ b/ace/RB_Tree.cpp
@@ -153,7 +153,7 @@ RB_Tree<KEY, T>::insert (const KEY &k, const T &t)
T *item = &(current->right ()->item ());
current->right ()->parent (current);
RB_rebalance (current->right ());
- root_->color (BLACK);
+ root_->color (RB_Tree_Node<KEY, T>::BLACK);
return item;
}
else
@@ -186,7 +186,7 @@ RB_Tree<KEY, T>::insert (const KEY &k, const T &t)
T *item = &(current->left ()->item ());
current->left ()->parent (current);
RB_rebalance (current->left ());
- root_->color (BLACK);
+ root_->color (RB_Tree_Node<KEY, T>::BLACK);
return item;
}
else
@@ -210,7 +210,7 @@ RB_Tree<KEY, T>::insert (const KEY &k, const T &t)
root_ = new RB_Tree_Node<KEY, T> (k, t);
if (root_)
{
- root_->color (BLACK);
+ root_->color (RB_Tree_Node<KEY, T>::BLACK);
return &(root_->item ());
}
else
@@ -234,7 +234,7 @@ template <class KEY, class T> int
RB_Tree<KEY, T>::remove (const KEY &k)
{
// find a matching node, if there is one
- RB_Tree_Node<KEY, T> *z = find_node (k);
+ RB_Tree_Node<KEY, T> *x, *z = find_node (k);
if ((z) && (! this->lessthan (z->key (), k))
&& (! this->lessthan (k, z->key ())))
@@ -422,11 +422,11 @@ RB_Tree<KEY, T>::RB_delete_fixup (RB_Tree_Node<KEY, T> * x)
w->left ()->color (RB_Tree_Node<KEY, T>::BLACK);
w->color (RB_Tree_Node<KEY, T>::RED);
RB_rotate_right (w);
- w = x->parent->right ();
+ w = x->parent ()->right ();
}
- w->color (x->parent->color ());
- x->parent->color (RB_Tree_Node<KEY, T>::BLACK);
- w->right->color (RB_Tree_Node<KEY, T>::BLACK);
+ w->color (x->parent ()->color ());
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ w->right ()->color (RB_Tree_Node<KEY, T>::BLACK);
RB_rotate_left (x->parent ());
x = root_;
}
@@ -454,11 +454,11 @@ RB_Tree<KEY, T>::RB_delete_fixup (RB_Tree_Node<KEY, T> * x)
w->right ()->color (RB_Tree_Node<KEY, T>::BLACK);
w->color (RB_Tree_Node<KEY, T>::RED);
RB_rotate_left (w);
- w = x->parent->left ();
+ w = x->parent ()->left ();
}
- w->color (x->parent->color ());
- x->parent->color (RB_Tree_Node<KEY, T>::BLACK);
- w->left->color (RB_Tree_Node<KEY, T>::BLACK);
+ w->color (x->parent ()->color ());
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ w->left ()->color (RB_Tree_Node<KEY, T>::BLACK);
RB_rotate_right (x->parent ());
x = root_;
}
@@ -527,7 +527,8 @@ RB_Tree<KEY, T>::RB_rebalance (RB_Tree_Node<KEY, T> * x)
{
RB_Tree_Node<KEY, T> *y = 0;
- while ((x) && (x->parent ()) && (x->parent ()->color () == RED))
+ while ((x) && (x->parent ())
+ && (x->parent ()->color () == RB_Tree_Node<KEY, T>::RED))
{
if (! x->parent ()->parent ())
{
@@ -541,12 +542,12 @@ RB_Tree<KEY, T>::RB_rebalance (RB_Tree_Node<KEY, T> * x)
if (x->parent () == x->parent ()->parent ()->left ())
{
y = x->parent ()->parent ()->right ();
- if (y && (y->color () == RED))
+ if (y && (y->color () == RB_Tree_Node<KEY, T>::RED))
{
// handle case 1 (see CLR book, pp. 269)
- x->parent ()->color (BLACK);
- y->color (BLACK);
- x->parent ()->parent ()->color (RED);
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ y->color (RB_Tree_Node<KEY, T>::BLACK);
+ x->parent ()->parent ()->color (RB_Tree_Node<KEY, T>::RED);
x = x->parent ()->parent ();
}
else
@@ -559,20 +560,20 @@ RB_Tree<KEY, T>::RB_rebalance (RB_Tree_Node<KEY, T> * x)
}
// handle case 3 (see CLR book, pp. 269)
- x->parent ()->color (BLACK);
- x->parent ()->parent ()->color (RED);
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ x->parent ()->parent ()->color (RB_Tree_Node<KEY, T>::RED);
RB_rotate_right (x->parent ()->parent ());
}
}
else
{
y = x->parent ()->parent ()->left ();
- if (y && (y->color () == RED))
+ if (y && (y->color () == RB_Tree_Node<KEY, T>::RED))
{
// handle case 1 (see CLR book, pp. 269)
- x->parent ()->color (BLACK);
- y->color (BLACK);
- x->parent ()->parent ()->color (RED);
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ y->color (RB_Tree_Node<KEY, T>::BLACK);
+ x->parent ()->parent ()->color (RB_Tree_Node<KEY, T>::RED);
x = x->parent ()->parent ();
}
else
@@ -585,8 +586,8 @@ RB_Tree<KEY, T>::RB_rebalance (RB_Tree_Node<KEY, T> * x)
}
// handle case 3 (see CLR book, pp. 269)
- x->parent ()->color (BLACK);
- x->parent ()->parent ()->color (RED);
+ x->parent ()->color (RB_Tree_Node<KEY, T>::BLACK);
+ x->parent ()->parent ()->color (RB_Tree_Node<KEY, T>::RED);
RB_rotate_left (x->parent ()->parent ());
}
}