Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect merge in adaptive_merge when the number of unique items is limited #15

Closed
igaztanaga opened this issue Oct 7, 2017 · 2 comments

Comments

@igaztanaga
Copy link
Member

Currently when the number of unique elements of the left sequence is limited:

  //Not the minimum number of keys is not available on the first range, so fallback to rotations
  if(collected != to_collect && collected < 4){
     merge_bufferless(first, first + len1, first + len1 + len2, comp);
  }

but this logic is invalid as the first sequence has been mutated when extracting elements. Instead, the extracted elements must be merged back to the sequence before merging with the second sequence:

  //Not the minimum number of keys is not available on the first range, so fallback to rotations
  if(collected != to_collect && collected < 4){
     merge_bufferless(first, first+collected, first+len1, comp);
     merge_bufferless(first, first + len1, first + len1 + len2, comp);
     return;
  }
igaztanaga added a commit that referenced this issue Oct 7, 2017
@igaztanaga
Copy link
Member Author

Fixed in commit:

fcf217b

@vinniefalco
Copy link
Member

Well, I'm glad I tried to diagnose it but to be honest, I would have never figured this out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants