Thrust
|
◆ upper_bound() [2/8]
template<class ForwardIterator , class LessThanComparable >
The following code snippet demonstrates how to use #include <thrust/binary_search.h> #include <thrust/device_vector.h> ... thrust::device_vector<int> input(5); input[0] = 0; input[1] = 2; input[2] = 5; input[3] = 7; input[4] = 8; thrust::upper_bound(input.begin(), input.end(), 0); // returns input.begin() + 1 thrust::upper_bound(input.begin(), input.end(), 1); // returns input.begin() + 1 thrust::upper_bound(input.begin(), input.end(), 2); // returns input.begin() + 2 thrust::upper_bound(input.begin(), input.end(), 3); // returns input.begin() + 2 thrust::upper_bound(input.begin(), input.end(), 8); // returns input.end() thrust::upper_bound(input.begin(), input.end(), 9); // returns input.end() |