My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 189: RBTree::Insert has issue when insert a value already exist
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Feb 2013


 
Reported by wyy...@gmail.com, Jul 18, 2012
After read the code of RedBlack.h, I found the RBTree::Insert has a issue when insert an exist value:

          /*
            Stop working if we inserted a node. This
            check also disallows duplicates in the tree
          */
          if ( q->key== inKey )
          {
 	    q->value = inValue;
            break;
 	  }

When value already exist, it breaks the loop, but at the end of this function it still increased the "size":

      /* Make the root black for simplified logic */
      root->red = 0;
      ++size;



Feb 1, 2013
Project Member #1 gameh...@gmail.com
Hi,
Thanks for the analysis & fix.  I'm not sure that 'size' is being used - where did you notice this issue?
Status: Fixed

Powered by Google Project Hosting