Michael - 1 year ago 61

C++ Question

I have a vector of objects which implement

`operator<`

`operator==`

I will have many searches on that sorted vector, so std::find does not seem to be a good option, since it just walks through the iterator until it finds a match.

Answer Source

Of course, there are.

For example, have a look at lower_bound and upper_bound functions.

Also binary_search may be useful.

All these functions work on the sorted input and have logarithmic complexity.