binary_search()
Assumes that the container is sorted by the less-than operator. If the container is sorted by some other ordering relationship, the binary operator must be passed in. The algorithm returns true or false.
#include <algorithm>
found_it = binary_search( ilist.begin(), ilist.end(), value );
found_it = binary_search( vec.begin(), vec.end(), value,
greater<int>() );
|