Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::upper_bound is an algorithm that returns the location where a given element can be inserted in a sorted container without violating the order.
std::upper_bound is defined in the header file algorithm.h.
Screen output:
v[0] = 1
v[1] = 4
v[2] = 9
v[3] = 9
v[4] = 16
The value '0' can be safely inserted at index 0 without violating the order
The value '1' can be safely inserted at index 1 without violating the order
The value '2' can be safely inserted at index 1 without violating the order
The value '3' can be safely inserted at index 1 without violating the order
The value '4' can be safely inserted at index 2 without violating the order
The value '5' can be safely inserted at index 2 without violating the order
The value '6' can be safely inserted at index 2 without violating the order
The value '7' can be safely inserted at index 2 without violating the order
The value '8' can be safely inserted at index 2 without violating the order
The value '9' can be safely inserted at index 4 without violating the order
The value '10' can be safely inserted at index 4 without violating the order
The value '11' can be safely inserted at index 4 without violating the order
The value '12' can be safely inserted at index 4 without violating the order
The value '13' can be safely inserted at index 4 without violating the order
The value '14' can be safely inserted at index 4 without violating the order
The value '15' can be safely inserted at index 4 without violating the order
The value '16' can be safely inserted at index 5 without violating the order
The value '17' can be safely inserted at index 5 without violating the order
The value '18' can be safely inserted at index 5 without violating the order
The value '19' can be safely inserted at index 5 without violating the order
|
External links
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.
