thrust

◆ find() [1/2]

template<typename DerivedPolicy , typename InputIterator , typename T >
__host__ __device__ InputIterator thrust::find ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
const T &  value 
)

find returns the first iterator i in the range [first, last) such that *i == value or last if no such iterator exists.

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

Parameters
execThe execution policy to use for parallelization.
firstBeginning of the sequence to search.
lastEnd of the sequence to search.
valueThe value to find.
Returns
The first iterator i such that *i == value or last.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator and InputIterator's value_type is equality comparable to type T.
Tis a model of EqualityComparable.
#include <thrust/find.h>
...
thrust::device_vector<int> input(4);
input[0] = 0;
input[1] = 5;
input[2] = 3;
input[3] = 7;
iter = thrust::find(thrust::device, input.begin(), input.end(), 3); // returns input.first() + 2
iter = thrust::find(thrust::device, input.begin(), input.end(), 5); // returns input.first() + 1
iter = thrust::find(thrust::device, input.begin(), input.end(), 9); // returns input.end()
See also
find_if
mismatch