thrust
Functions
Vectorized Searches

Functions

template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::lower_bound (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::lower_bound (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::lower_bound (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::lower_bound (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::upper_bound (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::upper_bound (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::upper_bound (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::upper_bound (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::binary_search (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::binary_search (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result)
 
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::binary_search (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::binary_search (ForwardIterator first, ForwardIterator last, InputIterator values_first, InputIterator values_last, OutputIterator result, StrictWeakOrdering comp)
 

Detailed Description

Function Documentation

template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::binary_search ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

binary_search is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). It returns true if an element that is equivalent to value is present in [first, last) and false if no such element exists.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and bool is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use binary_search to search for multiple values in a ordered range using the thrust::device execution policy for parallelization:

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [true, false, true, false, true, false]
See Also
http://www.sgi.com/tech/stl/binary_search.html
lower_bound
upper_bound
equal_range
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::binary_search ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

binary_search is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). It returns true if an element that is equivalent to value is present in [first, last) and false if no such element exists.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and bool is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use binary_search to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::binary_search(input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [true, false, true, false, true, false]
See Also
http://www.sgi.com/tech/stl/binary_search.html
lower_bound
upper_bound
equal_range
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::binary_search ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

binary_search is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). It returns true if an element that is equivalent to value is present in [first, last) and false if no such element exists. This version of binary_search uses function object comp for comparison.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and bool is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use binary_search to search for multiple values in a ordered range using the thrust::device execution policy for parallelization:

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [true, false, true, false, true, false]
See Also
http://www.sgi.com/tech/stl/binary_search.html
lower_bound
upper_bound
equal_range
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::binary_search ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

binary_search is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). It returns true if an element that is equivalent to value is present in [first, last) and false if no such element exists. This version of binary_search uses function object comp for comparison.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and bool is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use binary_search to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::binary_search(input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [true, false, true, false, true, false]
See Also
http://www.sgi.com/tech/stl/binary_search.html
lower_bound
upper_bound
equal_range
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::lower_bound ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

lower_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use lower_bound to search for multiple values in a ordered range using the thrust::device execution policy for parallelization:

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [0, 1, 1, 2, 4, 5]
See Also
http://www.sgi.com/tech/stl/lower_bound.html
upper_bound
equal_range
binary_search
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::lower_bound ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

lower_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use lower_bound to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::lower_bound(input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [0, 1, 1, 2, 4, 5]
See Also
http://www.sgi.com/tech/stl/lower_bound.html
upper_bound
equal_range
binary_search
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::lower_bound ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

lower_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering. This version of lower_bound uses function object comp for comparison.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is comparable to ForwardIterator's value_type.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use lower_bound to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::lower_bound(input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [0, 1, 1, 2, 4, 5]
See Also
http://www.sgi.com/tech/stl/lower_bound.html
upper_bound
equal_range
binary_search
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::lower_bound ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

lower_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering. This version of lower_bound uses function object comp for comparison.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is comparable to ForwardIterator's value_type.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use lower_bound to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::lower_bound(input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [0, 1, 1, 2, 4, 5]
See Also
http://www.sgi.com/tech/stl/lower_bound.html
upper_bound
equal_range
binary_search
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator >
__host__ __device__ OutputIterator thrust::upper_bound ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

upper_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of last position where value could be inserted without violating the ordering.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use upper_bound to search for multiple values in a ordered range using the thrust::device execution policy for parallelization:

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [1, 1, 2, 2, 5, 5]
See Also
http://www.sgi.com/tech/stl/upper_bound.html
upper_bound
equal_range
binary_search
template<class ForwardIterator , class InputIterator , class OutputIterator >
OutputIterator thrust::upper_bound ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result 
)

upper_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of last position where value could be inserted without violating the ordering.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is LessThanComparable.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use upper_bound to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::upper_bound(input.begin(), input.end(),
values.begin(), values.end(),
output.begin());
// output is now [1, 1, 2, 2, 5, 5]
See Also
http://www.sgi.com/tech/stl/upper_bound.html
upper_bound
equal_range
binary_search
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename OutputIterator , typename StrictWeakOrdering >
__host__ __device__ OutputIterator thrust::upper_bound ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

upper_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering. This version of upper_bound uses function object comp for comparison.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is comparable to ForwardIterator's value_type.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use upper_bound to search for multiple values in a ordered range using the thrust::device execution policy for parallelization:

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [1, 1, 2, 2, 5, 5]
See Also
http://www.sgi.com/tech/stl/upper_bound.html
lower_bound
equal_range
binary_search
template<class ForwardIterator , class InputIterator , class OutputIterator , class StrictWeakOrdering >
OutputIterator thrust::upper_bound ( ForwardIterator  first,
ForwardIterator  last,
InputIterator  values_first,
InputIterator  values_last,
OutputIterator  result,
StrictWeakOrdering  comp 
)

upper_bound is a vectorized version of binary search: for each iterator v in [values_first, values_last) it attempts to find the value *v in an ordered range [first, last). Specifically, it returns the index of first position where value could be inserted without violating the ordering. This version of upper_bound uses function object comp for comparison.

Parameters
firstThe beginning of the ordered sequence.
lastThe end of the ordered sequence.
values_firstThe beginning of the search values sequence.
values_lastThe end of the search values sequence.
resultThe beginning of the output sequence.
compThe comparison operator.
Template Parameters
ForwardIteratoris a model of Forward Iterator.
InputIteratoris a model of Input Iterator. and InputIterator's value_type is comparable to ForwardIterator's value_type.
OutputIteratoris a model of Output Iterator. and ForwardIterator's difference_type is convertible to OutputIterator's value_type.
StrictWeakOrderingis a model of Strict Weak Ordering.
Precondition
The ranges [first,last) and [result, result + (last - first)) shall not overlap.

The following code snippet demonstrates how to use upper_bound to search for multiple values in a ordered range.

...
thrust::device_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
values[0] = 0;
values[1] = 1;
values[2] = 2;
values[3] = 3;
values[4] = 8;
values[5] = 9;
thrust::upper_bound(input.begin(), input.end(),
values.begin(), values.end(),
output.begin(),
// output is now [1, 1, 2, 2, 5, 5]
See Also
http://www.sgi.com/tech/stl/upper_bound.html
lower_bound
equal_range
binary_search