thrust::partition_point#
Overloads#
partition_point(exec, first, last, pred)#
-
template<typename DerivedPolicy, typename ForwardIterator, typename Predicate>
ForwardIterator thrust::partition_point( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- ForwardIterator first,
- ForwardIterator last,
- Predicate pred,
partition_pointreturns an iterator pointing to the end of the true partition of a partitioned range.partition_pointrequires the input range[first,last)to be a partition; that is, all elements which satisfypredshall appear before those that do not.The algorithm’s execution is parallelized as determined by
exec.#include <thrust/partition.h> #include <thrust/execution_policy.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 = thrust::partition_point(thrust::host, A, A + 10, is_even()); // B - A is 5 // [A, B) contains only even values
See also
See also
Note
Though similar,
partition_pointis not redundant withfind_if_not.partition_point'sprecondition provides an opportunity for a faster implementation.- Parameters:
exec – The execution policy to use for parallelization.
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:
DerivedPolicy – The name of the derived execution policy.
ForwardIterator – is a model of Forward Iterator, and
ForwardIterator'svalue_typeis convertible toPredicate'sargument type.Predicate – is a model of Predicate.
- Returns:
An iterator
midsuch thatall_of(first, mid, pred)andnone_of(mid, last, pred)are both true.- Pre:
The range
[first, last)shall be partitioned bypred.
partition_point(first, last, pred)#
-
template<typename ForwardIterator, typename Predicate>
ForwardIterator thrust::partition_point( - ForwardIterator first,
- ForwardIterator last,
- Predicate pred,
partition_pointreturns an iterator pointing to the end of the true partition of a partitioned range.partition_pointrequires the input range[first,last)to be a partition; that is, all elements which satisfypredshall appear 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 = thrust::partition_point(A, A + 10, is_even()); // B - A is 5 // [A, B) contains only even values
See also
See also
Note
Though similar,
partition_pointis not redundant withfind_if_not.partition_point'sprecondition provides an opportunity for a faster implementation.- 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:
ForwardIterator – is a model of Forward Iterator, and
ForwardIterator'svalue_typeis convertible toPredicate'sargument type.Predicate – is a model of Predicate.
- Returns:
An iterator
midsuch thatall_of(first, mid, pred)andnone_of(mid, last, pred)are both true.- Pre:
The range
[first, last)shall be partitioned bypred.