thrust

◆ mismatch() [4/4]

template<typename InputIterator1 , typename InputIterator2 , typename BinaryPredicate >
thrust::pair<InputIterator1, InputIterator2> thrust::mismatch ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
BinaryPredicate  pred 
)

mismatch finds the first position where the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) differ. The two versions of mismatch use different tests for whether elements differ.

This version of mismatch finds the first iterator i in [first1, last1) such that pred(*i, *(first2 + (i - first1)) is false. The return value is a pair whose first element is i and whose second element is *(first2 + (i - first1)). If no such iterator i exists, the return value is a pair whose first element is last1 and whose second element is *(first2 + (last1 - first1)).

Parameters
first1The beginning of the first sequence.
last1The end of the first sequence.
first2The beginning of the second sequence.
predThe binary predicate to compare elements.
Returns
The first position where the sequences differ.
Template Parameters
InputIterator1is a model of Input Iterator.
InputIterator2is a model of Input Iterator.
Predicateis a model of Input Iterator.
...
thrust::device_vector<int> vec1(4);
vec1[0] = 0; vec2[0] = 0;
vec1[1] = 5; vec2[1] = 5;
vec1[2] = 3; vec2[2] = 8;
vec1[3] = 7; vec2[3] = 7;
result = thrust::mismatch(vec1.begin(), vec1.end(), vec2.begin(), thrust::equal_to<int>());
// result.first is vec1.begin() + 2
// result.second is vec2.begin() + 2
See also
find
find_if