-
Notifications
You must be signed in to change notification settings - Fork 269
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
Use a single binary search for array contains_range #385
Use a single binary search for array contains_range #385
Conversation
Very nice. |
Merged. clap ! clap ! clap ! |
Hi, Sorry to intervene with a potentially useless comment, but this change seems to introduce an issue (that may be irrelevant). I was able to generate an incorrect answer with this newly merged code in the following way: array_container_t * a = array_container_create_range(3, 10);
bool answer = array_container_contains_range(a, 3, 0);
std::cout << "contains? " << (answer? "yes" : "no") << std::endl; I'm getting an incorrect positive bool from The previous version of Very briefly:
My suggestion - again, if this is all relevant and apologies otherwise! - would be to slightly modify this PR so that if (range_count <= 0) becomes if (range_start >= range_end) mimicking I'd be happy to open a PR for this (or to go away ha) ;-) Cheers! |
Please do so. |
I'm sorry... I was confused. Checking I guess the real question is: should |
We definitively want Meanwhile |
Makes sense, thanks. So what should Right now, passing start=3 end=0 returns a spurious |
I think the existing behavior is actually correct: |
The rest can be done by checking a single memory location