thrust

◆ remove_copy() [1/2]

template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename T >
__host__ __device__ OutputIterator thrust::remove_copy ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
OutputIterator  result,
const T &  value 
)

remove_copy copies elements that are not equal to value from the range [first, last) to a range beginning at result. 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 in the range [first, last).

The algorithm's execution 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.
resultThe resulting range is copied to the sequence beginning at this location.
valueThe value to omit from the copied range.
Returns
An OutputIterator pointing to the end of the resulting range of elements which are not equal to value.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator, and InputIterator's value_type is convertible to a type in OutputIterator's set of value_types.
OutputIteratoris a model of Output Iterator.
Tis a model of Equality Comparable, and objects of type T can be compared for equality with objects of InputIterator's value_type.
Precondition
The range [first, last) shall not overlap the range [result, result + (last - first)).

The following code snippet demonstrates how to use remove_copy to copy a sequence of numbers to an output range while omitting a value of interest 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 result[N-2];
thrust::remove_copy(thrust::host, V, V + N, result, 0);
// V remains {-2, 0, -1, 0, 1, 2}
// result is now {-2, -1, 1, 2}
See also
http://www.sgi.com/tech/stl/remove_copy.html
remove
remove_if
remove_copy_if