thrust
Functions
Logical

Functions

template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::all_of (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, Predicate pred)
 
template<typename InputIterator , typename Predicate >
bool thrust::all_of (InputIterator first, InputIterator last, Predicate pred)
 
template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::any_of (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, Predicate pred)
 
template<typename InputIterator , typename Predicate >
bool thrust::any_of (InputIterator first, InputIterator last, Predicate pred)
 
template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::none_of (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, Predicate pred)
 
template<typename InputIterator , typename Predicate >
bool thrust::none_of (InputIterator first, InputIterator last, Predicate pred)
 

Detailed Description

Function Documentation

template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::all_of ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
Predicate  pred 
)

all_of determines whether all elements in a range satify a predicate. Specifically, all_of returns true if pred(*i) is true for every iterator i in the range [first, last) and false otherwise.

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

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if all elements satisfy the predicate; false, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::all_of(thrust::host, A, A + 2, thrust::identity<bool>()); // returns true
thrust::all_of(thrust::host, A, A + 3, thrust::identity<bool>()); // returns false
// empty range
See Also
any_of
none_of
transform_reduce
template<typename InputIterator , typename Predicate >
bool thrust::all_of ( InputIterator  first,
InputIterator  last,
Predicate  pred 
)

all_of determines whether all elements in a range satify a predicate. Specifically, all_of returns true if pred(*i) is true for every iterator i in the range [first, last) and false otherwise.

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if all elements satisfy the predicate; false, otherwise.
Template Parameters
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::all_of(A, A + 2, thrust::identity<bool>()); // returns true
thrust::all_of(A, A + 3, thrust::identity<bool>()); // returns false
// empty range
thrust::all_of(A, A, thrust::identity<bool>()); // returns false
See Also
any_of
none_of
transform_reduce
template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::any_of ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
Predicate  pred 
)

any_of determines whether any element in a range satifies a predicate. Specifically, any_of returns true if pred(*i) is true for any iterator i in the range [first, last) and false otherwise.

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

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if any element satisfies the predicate; false, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::any_of(thrust::host, A, A + 2, thrust::identity<bool>()); // returns true
thrust::any_of(thrust::host, A, A + 3, thrust::identity<bool>()); // returns true
thrust::any_of(thrust::host, A + 2, A + 3, thrust::identity<bool>()); // returns false
// empty range
See Also
all_of
none_of
transform_reduce
template<typename InputIterator , typename Predicate >
bool thrust::any_of ( InputIterator  first,
InputIterator  last,
Predicate  pred 
)

any_of determines whether any element in a range satifies a predicate. Specifically, any_of returns true if pred(*i) is true for any iterator i in the range [first, last) and false otherwise.

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if any element satisfies the predicate; false, otherwise.
Template Parameters
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::any_of(A, A + 2, thrust::identity<bool>()); // returns true
thrust::any_of(A, A + 3, thrust::identity<bool>()); // returns true
thrust::any_of(A + 2, A + 3, thrust::identity<bool>()); // returns false
// empty range
thrust::any_of(A, A, thrust::identity<bool>()); // returns false
See Also
all_of
none_of
transform_reduce
template<typename DerivedPolicy , typename InputIterator , typename Predicate >
__host__ __device__ bool thrust::none_of ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
Predicate  pred 
)

none_of determines whether no element in a range satifies a predicate. Specifically, none_of returns true if there is no iterator i in the range [first, last) such that pred(*i) is true, and false otherwise.

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

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if no element satisfies the predicate; false, otherwise.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::none_of(thrust::host, A, A + 2, thrust::identity<bool>()); // returns false
thrust::none_of(thrust::host, A, A + 3, thrust::identity<bool>()); // returns false
thrust::none_of(thrust::host, A + 2, A + 3, thrust::identity<bool>()); // returns true
// empty range
See Also
all_of
any_of
transform_reduce
template<typename InputIterator , typename Predicate >
bool thrust::none_of ( InputIterator  first,
InputIterator  last,
Predicate  pred 
)

none_of determines whether no element in a range satifies a predicate. Specifically, none_of returns true if there is no iterator i in the range [first, last) such that pred(*i) is true, and false otherwise.

Parameters
firstThe beginning of the sequence.
lastThe end of the sequence.
predA predicate used to test range elements.
Returns
true, if no element satisfies the predicate; false, otherwise.
Template Parameters
InputIteratoris a model of Input Iterator,
Predicatemust be a model of Predicate.
#include <thrust/logical.h>
...
bool A[3] = {true, true, false};
thrust::none_of(A, A + 2, thrust::identity<bool>()); // returns false
thrust::none_of(A, A + 3, thrust::identity<bool>()); // returns false
thrust::none_of(A + 2, A + 3, thrust::identity<bool>()); // returns true
// empty range
thrust::none_of(A, A, thrust::identity<bool>()); // returns true
See Also
all_of
any_of
transform_reduce