thrust::is_partitioned
Defined in thrust/partition.h
- 
template<typename InputIterator, typename Predicate>
 bool thrust::is_partitioned(InputIterator first, InputIterator last, Predicate pred)
- is_partitionedreturns- trueif the given range is partitioned with respect to a predicate, and- falseotherwise.- Specifically, - is_partitionedreturns- trueif- [first, last)is empty of if- [first, last)is partitioned by- pred, i.e. if all elements that satisfy- predappear before those that do not.- #include <thrust/partition.h> struct is_even { __host__ __device__ bool operator()(const int &x) { return (x % 2) == 0; } }; ... int A[] = {2, 4, 6, 8, 10, 1, 3, 5, 7, 9}; int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; thrust::is_partitioned(A, A + 10, is_even()); // returns true thrust::is_partitioned(B, B + 10, is_even()); // returns false - See also - partition- Parameters
- first – The beginning of the range to consider. 
- last – The end of the range to consider. 
- pred – A function object which decides to which partition each element of the range - [first, last)belongs.
 
- Template Parameters
- InputIterator – is a model of Input Iterator, and - InputIterator's- value_typeis convertible to- Predicate'sargument type.
- Predicate – is a model of Predicate. 
 
- Returns
- trueif the range- [first, last)is partitioned with respect to- pred, or if- [first, last)is empty.- false, otherwise.