◆ remove_copy() [2/2]

template<typename InputIterator , typename OutputIterator , typename T >
OutputIterator thrust::remove_copy ( 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).

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.
An OutputIterator pointing to the end of the resulting range of elements which are not equal to value.
Template Parameters
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.
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.

#include <thrust/remove.h>
const int N = 6;
int V[N] = {-2, 0, -1, 0, 1, 2};
int result[N-2];
thrust::remove_copy(V, V + N, result, 0);
// V remains {-2, 0, -1, 0, 1, 2}
// result is now {-2, -1, 1, 2}
See also