diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 00:06:16 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 00:06:16 +0000 |
commit | 569ea1fd77d80c86be231b98cad7827be96e966d (patch) | |
tree | 5d7e6772266dd6bb94e9ebca34df27e17b2ab5f2 /ace/RB_Tree.cpp | |
parent | 90608490579f77962f9b6c32f47200d5851d1060 (diff) | |
download | ATCD-569ea1fd77d80c86be231b98cad7827be96e966d.tar.gz |
ChangeLogTag:Sat Jul 3 18:54:18 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'ace/RB_Tree.cpp')
-rw-r--r-- | ace/RB_Tree.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tre { ACE_TRACE ("ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_rebalance (ACE_RB_Tree_N ACE_RB_Tree_Node<EXT_ID, INT_ID> *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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, // The right subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *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<EXT_ID, INT_ID> (k, t) + ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + ACE_RB_TREE_CTOR, 0); current->right (tmp); @@ -610,14 +614,14 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID>::insert_i\n")), + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), 0); else { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + ACE_RB_TREE_CTOR, 0); current->left (tmp); @@ -637,8 +641,8 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID> (k, t), + ACE_NEW_RETURN (root_, + ACE_RB_TREE_CTOR, 0); if (root_) { @@ -689,7 +693,7 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID>::insert_i\n")), + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); } else @@ -697,7 +701,7 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::insert_i (const EXT_ID &k, // The right subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node<EXT_ID, INT_ID> (k, t), + ACE_RB_TREE_CTOR, -1); current->right (tmp); @@ -721,14 +725,14 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID>::insert_i\n")), + "ACE_RB_Tree<EXT_ID, INT_ID>::insert_i\n")), -1); else { // The left subtree is empty: insert new node there. ACE_RB_Tree_Node<EXT_ID, INT_ID> *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_RB_Tree_Node<EXT_ID, INT_ID> (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<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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<EXT_ID, INT_ID> (k, t), + ACE_RB_TREE_CTOR, -1); root_->color (ACE_RB_Tree_Node_Base::BLACK); ++current_size_; @@ -757,6 +761,8 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::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 |