From 569ea1fd77d80c86be231b98cad7827be96e966d Mon Sep 17 00:00:00 2001 From: coryan Date: Sun, 4 Jul 1999 00:06:16 +0000 Subject: ChangeLogTag:Sat Jul 3 18:54:18 1999 Carlos O'Ryan --- ace/RB_Tree.cpp | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'ace/RB_Tree.cpp') diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp index 0a0b0e073d4..c09b293a2ab 100644 --- a/ace/RB_Tree.cpp +++ b/ace/RB_Tree.cpp @@ -209,8 +209,8 @@ ACE_RB_Tree::RB_delete_fixup (ACE_RB_Tre { ACE_TRACE ("ACE_RB_Tree::RB_delete_fixup"); - while (x - && x->parent () + while (x + && x->parent () && x->color () == ACE_RB_Tree_Node_Base::BLACK) { if (x == x->parent ()->left ()) @@ -225,9 +225,9 @@ ACE_RB_Tree::RB_delete_fixup (ACE_RB_Tre } // 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->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); @@ -237,7 +237,7 @@ ACE_RB_Tree::RB_delete_fixup (ACE_RB_Tre { // CLR pp. 263 says that nil nodes are implicitly colored BLACK if (w && - (!w->right () + (!w->right () || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { if (w->left ()) @@ -269,9 +269,9 @@ ACE_RB_Tree::RB_delete_fixup (ACE_RB_Tre } // 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->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); @@ -281,7 +281,7 @@ ACE_RB_Tree::RB_delete_fixup (ACE_RB_Tre { // CLR pp. 263 says that nil nodes are implicitly colored BLACK if (w && - (!w->left () + (!w->left () || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { w->color (ACE_RB_Tree_Node_Base::RED); @@ -371,7 +371,7 @@ ACE_RB_Tree::RB_rebalance (ACE_RB_Tree_N ACE_RB_Tree_Node *y = 0; while (x && - x->parent () + x->parent () && x->parent ()->color () == ACE_RB_Tree_Node_Base::RED) { if (! x->parent ()->parent ()) @@ -585,8 +585,12 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, // The right subtree is empty: insert new node there. ACE_RB_Tree_Node *tmp = 0; +// This is a hack to use ACE_NEW_RETURN with this ctor that has +// multiple parameters. +#define ACE_RB_TREE_CTOR ACE_RB_Tree_Node (k, t) + ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node (k, t), + ACE_RB_TREE_CTOR, 0); current->right (tmp); @@ -610,14 +614,14 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nleft subtree already present in " - "ACE_RB_Tree::insert_i\n")), + "ACE_RB_Tree::insert_i\n")), 0); else { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node (k, t), + ACE_RB_TREE_CTOR, 0); current->left (tmp); @@ -637,8 +641,8 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, { // The tree is empty: insert at the root and color the root // black. - ACE_NEW_RETURN (ACE_root_, - ACE_RB_Tree_Node (k, t), + ACE_NEW_RETURN (root_, + ACE_RB_TREE_CTOR, 0); if (root_) { @@ -689,7 +693,7 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nright subtree already present in " - "ACE_RB_Tree::insert_i\n")), + "ACE_RB_Tree::insert_i\n")), -1); } else @@ -697,7 +701,7 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, // The right subtree is empty: insert new node there. ACE_RB_Tree_Node *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node (k, t), + ACE_RB_TREE_CTOR, -1); current->right (tmp); @@ -721,14 +725,14 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("\nleft subtree already present in " - "ACE_RB_Tree::insert_i\n")), + "ACE_RB_Tree::insert_i\n")), -1); else { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node (k, t), + ACE_RB_TREE_CTOR, -1); current->left (tmp); // If the node was successfully inserted, set its @@ -747,7 +751,7 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, { // The tree is empty: insert at the root and color the root black. ACE_NEW_RETURN (root_, - ACE_RB_Tree_Node (k, t), + ACE_RB_TREE_CTOR, -1); root_->color (ACE_RB_Tree_Node_Base::BLACK); ++current_size_; @@ -757,6 +761,8 @@ ACE_RB_Tree::insert_i (const EXT_ID &k, return -1; } +#undef ACE_RB_TREE_CTOR + // Removes the item associated with the given key from the tree and // destroys it. Returns 1 if it found the item and successfully // destroyed it, 0 if it did not find the item, or -1 if an error -- cgit v1.2.1