thrust

◆ remove_copy_if() [3/4]

template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate >
__host__ __device__ OutputIterator thrust::remove_copy_if ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator1  first,
InputIterator1  last,
InputIterator2  stencil,
OutputIterator  result,
Predicate  pred 
)

remove_copy_if copies elements from the range [first,last) to a range beginning at result, except that elements for which pred of the corresponding stencil value is true are not copied. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as the range [first,last).

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

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the range of interest.
lastThe end of the range of interest.
stencilThe beginning of the stencil sequence.
resultThe resulting range is copied to the sequence beginning at this location.
predA predicate to evaluate for each element of the range [first,last). Elements for which pred evaluates to false are not copied to the resulting sequence.
Returns
An OutputIterator pointing to the end of the resulting range.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIterator1is a model of Input Iterator, InputIterator1's value_type is convertible to a type in OutputIterator's set of value_types.
InputIterator2is a model of Input Iterator, and InputIterator2's value_type is convertible to Predicate's argument_type.
OutputIteratoris a model of Output Iterator.
Predicateis a model of Predicate.
Precondition
The range [stencil, stencil + (last - first)) shall not overlap the range [result, result + (last - first)).

The following code snippet demonstrates how to use remove_copy_if to copy a sequence of numbers to an output range while omitting specific elements using the thrust::host execution policy for parallelization.

#include <thrust/remove.h>
...
const int N = 6;
int V[N] = {-2, 0, -1, 0, 1, 2};
int S[N] = { 1, 1, 0, 1, 0, 1};
int result[2];
// V remains {-2, 0, -1, 0, 1, 2}
// result is now {-1, 1}
See also
http://www.sgi.com/tech/stl/remove_copy_if.html
remove
remove_copy
remove_if
copy_if