I know that there is std::set::lower_bound
and the time complexity is O(log)
, and i see that std::lower_bound
is much slower than std::set::lower_bound
when operates on std::set
.
I googled and found this:
http://en.cppreference.com/w/cpp/algorithm/lower_bound http://en.cppreference.com/w/cpp/iterator/advance
so it's clear that because of the std::advance
is linear for set::iterator
, the whole std::lower_bound
takes up to O(n)
.
However, it runs much faster than O(n)
when i use it(and so did some friends say), can anybody explain why or tell me it's just not like that.