thrust::partition

Defined in thrust/partition.h

template<typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename Predicate>
ForwardIterator thrust::partition(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred)

partition reorders the elements [first, last) based on the function object pred applied to a stencil range [stencil, stencil + (last - first)), such that all of the elements whose corresponding stencil element satisfies pred precede all of the elements whose corresponding stencil element fails to satisfy it. The postcondition is that, for some iterator middle in the range [first, last), pred(*stencil_i) is true for every iterator stencil_i in the range [stencil,stencil + (middle - first)) and false for every iterator stencil_i in the range [stencil

The following code snippet demonstrates how to use to reorder a sequence so that even numbers precede odd numbers using the execution policy for parallelization: