stl:algorithm:upper_bound

C++ Reference

upper_bound

Syntax:

    #include <algorithm>
    iterator upper_bound( iterator start, iterator end, const TYPE& val );
    iterator upper_bound( iterator start, iterator end, const TYPE& val, StrictWeakOrdering cmp );

The upper_bound() algorithm searches the ordered range [start,end) for the last location that val could be inserted without disrupting the order of the range. This function requires the elements to be in order.

If the strict weak ordering function object cmp is given, it is used to compare elements instead of the < operator.

upper_bound() runs in logarithmic time.

Related Topics: binary_search, equal_range, lower_bound