[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 996
  • Last Modified:

upper_bound vs. lower_bound

Is it true that there is no practical difference between std::lower_bound and std::upper_bound if the sorted range has all unique values?
0
chsalvia
Asked:
chsalvia
2 Solutions
 
Infinity08Commented:
upper_bound returns the first value higher than a given value in a sorted series.
lower_bound returns the first value which is not less than a given value in a sorted series

        http://www.cplusplus.com/reference/algorithm/upper_bound.html
        http://www.cplusplus.com/reference/algorithm/lower_bound.html

So, in other words, lower_bound is equivalent to >=, while upper_bound is equivalent to >. ie. they're not exactly the same.
0
 
jkrCommented:
No. See the code samples and the output at http://www.sgi.com/tech/stl/upper_bound.html and http://www.sgi.com/tech/stl/lower_bound.html (scroll down a bit for the examples on both pages)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now