lower_bound problem

Started by
2 comments, last by Turold 14 years, 1 month ago
What does lower_bound return when an element is NOT found?
Advertisement
std::lower_bound doesn't check for a specific element, it returns the first position whose value is greater than or equal to the specified value.
Quote:Source: SGI
Description

Lower_bound is a version of binary search: it attempts to find the element value in an ordered range [first, last) [1]. Specifically, it returns the first position where value could be inserted without violating the ordering. [2] The first version of lower_bound uses operator< for comparison, and the second uses the function object comp.
The first version of lower_bound returns the furthermost iterator i in [first, last) such that, for every iterator j in [first, i), *j < value.

The second version of lower_bound returns the furthermost iterator i in [first, last) such that, for every iterator j in [first, i), comp(*j, value) is true.

Emphasis added.
I get it. What a swift reply! Thx guys! :)

This topic is closed to new replies.

Advertisement