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
Probably wrong complexity of std::includes #2082
Comments
This is not an editorial issue; it needs to go to LWG. |
Should I create an issue here issues.isocpp.org ? |
I believe this issue is incorrect. Remember that either range can contain duplicate elements. Consider:
Clearly we cannot give a complexity bound better than |
See http://lists.isocpp.org/lib/2018/05/7092.php; |
The complexity requirements are consistent with the current description, and should be fixed if/when the description is fixed to actually describe what the algorithm is "supposed' to do. Seems like LWG is already on the case. I'll reply to that lib thread to request that the complexity be revisited when the spec is fixed. |
I started from the question at stackoverflow.
Here stated that algorithm
std::includes
has complexity at most2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons.But it seems the algorithm has complexity at most
2 * (last1 - first1)
comparisons. Probably this mistake arose from complexity of operationsstd::union
andstd::intersection
.It would be cool to see a nice answer at stackoverflow on it.
The text was updated successfully, but these errors were encountered: