thrust
Functions
Comparisons

Functions

template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 >
__host__ __device__ bool thrust::equal (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 
template<typename InputIterator1 , typename InputIterator2 >
bool thrust::equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 
template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 , typename BinaryPredicate >
__host__ __device__ bool thrust::equal (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred)
 
template<typename InputIterator1 , typename InputIterator2 , typename BinaryPredicate >
bool thrust::equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred)
 

Detailed Description

Function Documentation

template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 >
__host__ __device__ bool thrust::equal ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2 
)

equal returns true if the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) are identical when compared element-by-element, and otherwise returns false.

This version of equal returns true if and only if for every iterator i in [first1, last1), *i == *(first2 + (i - first1)).

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

Parameters
execThe execution policy to use for parallelization.
first1The beginning of the first sequence.
last1The end of the first sequence.
first2The beginning of the second sequence.
Returns
true, if the sequences are equal; false, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIterator1is a model of Input Iterator, and InputIterator1's value_type is a model of Equality Comparable, and InputIterator1's value_type can be compared for equality with InputIterator2's value_type.
InputIterator2is a model of Input Iterator, and InputIterator2's value_type is a model of Equality Comparable, and InputIterator2's value_type can be compared for equality with InputIterator1's value_type.

The following code snippet demonstrates how to use equal to test two ranges for equality using the thrust::host execution policy:

#include <thrust/equal.h>
...
int A1[7] = {3, 1, 4, 1, 5, 9, 3};
int A2[7] = {3, 1, 4, 2, 8, 5, 7};
...
bool result = thrust::equal(thrust::host, A1, A1 + 7, A2);
// result == false
See Also
http://www.sgi.com/tech/stl/equal.html
template<typename InputIterator1 , typename InputIterator2 >
bool thrust::equal ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2 
)

equal returns true if the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) are identical when compared element-by-element, and otherwise returns false.

This version of equal returns true if and only if for every iterator i in [first1, last1), *i == *(first2 + (i - first1)).

Parameters
first1The beginning of the first sequence.
last1The end of the first sequence.
first2The beginning of the second sequence.
Returns
true, if the sequences are equal; false, otherwise.
Template Parameters
InputIterator1is a model of Input Iterator, and InputIterator1's value_type is a model of Equality Comparable, and InputIterator1's value_type can be compared for equality with InputIterator2's value_type.
InputIterator2is a model of Input Iterator, and InputIterator2's value_type is a model of Equality Comparable, and InputIterator2's value_type can be compared for equality with InputIterator1's value_type.

The following code snippet demonstrates how to use equal to test two ranges for equality.

#include <thrust/equal.h>
...
int A1[7] = {3, 1, 4, 1, 5, 9, 3};
int A2[7] = {3, 1, 4, 2, 8, 5, 7};
...
bool result = thrust::equal(A1, A1 + 7, A2);
// result == false
See Also
http://www.sgi.com/tech/stl/equal.html
template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 , typename BinaryPredicate >
__host__ __device__ bool thrust::equal ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
BinaryPredicate  binary_pred 
)

equal returns true if the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) are identical when compared element-by-element, and otherwise returns false.

This version of equal returns true if and only if for every iterator i in [first1, last1), binary_pred(*i, *(first2 + (i - first1))) is true.

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

Parameters
execThe execution policy to use for parallelization.
first1The beginning of the first sequence.
last1The end of the first sequence.
first2The beginning of the second sequence.
binary_predBinary predicate used to test element equality.
Returns
true, if the sequences are equal; false, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIterator1is a model of Input Iterator, and InputIterator1's value_type is convertible to BinaryPredicate's first_argument_type.
InputIterator2is a model of Input Iterator, and InputIterator2's value_type is convertible to BinaryPredicate's second_argument_type.
BinaryPredicateis a model of Binary Predicate.

The following code snippet demonstrates how to use equal to compare the elements in two ranges modulo 2 using the thrust::host execution policy.

#include <thrust/equal.h>
...
struct compare_modulo_two
{
__host__ __device__
bool operator()(int x, int y) const
{
return (x % 2) == (y % 2);
}
};
...
int x[6] = {0, 2, 4, 6, 8, 10};
int y[6] = {1, 3, 5, 7, 9, 11};
bool result = thrust::equal(x, x + 6, y, compare_modulo_two());
// result is false
See Also
http://www.sgi.com/tech/stl/equal.html
template<typename InputIterator1 , typename InputIterator2 , typename BinaryPredicate >
bool thrust::equal ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
BinaryPredicate  binary_pred 
)

equal returns true if the two ranges [first1, last1) and [first2, first2 + (last1 - first1)) are identical when compared element-by-element, and otherwise returns false.

This version of equal returns true if and only if for every iterator i in [first1, last1), binary_pred(*i, *(first2 + (i - first1))) is true.

Parameters
first1The beginning of the first sequence.
last1The end of the first sequence.
first2The beginning of the second sequence.
binary_predBinary predicate used to test element equality.
Returns
true, if the sequences are equal; false, otherwise.
Template Parameters
InputIterator1is a model of Input Iterator, and InputIterator1's value_type is convertible to BinaryPredicate's first_argument_type.
InputIterator2is a model of Input Iterator, and InputIterator2's value_type is convertible to BinaryPredicate's second_argument_type.
BinaryPredicateis a model of Binary Predicate.

The following code snippet demonstrates how to use equal to compare the elements in two ranges modulo 2.

#include <thrust/equal.h>
struct compare_modulo_two
{
__host__ __device__
bool operator()(int x, int y) const
{
return (x % 2) == (y % 2);
}
};
...
int x[6] = {0, 2, 4, 6, 8, 10};
int y[6] = {1, 3, 5, 7, 9, 11};
bool result = thrust::equal(x, x + 5, y, compare_modulo_two());
// result is true
See Also
http://www.sgi.com/tech/stl/equal.html