thrust::remove_copy
Defined in thrust/remove.h
-
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 tovalue
from the range[first, last)
to a range beginning atresult
. 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 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
remove
See also
remove_if
See also
remove_copy_if
- Parameters
first – The beginning of the range of interest.
last – The end of the range of interest.
result – The resulting range is copied to the sequence beginning at this location.
value – The value to omit from the copied range.
- Template Parameters
InputIterator – is a model of Input Iterator, and
InputIterator's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.OutputIterator – is a model of Output Iterator.
T – is a model of Equality Comparable, and objects of type
T
can be compared for equality with objects ofInputIterator's
value_type
.
- Returns
An OutputIterator pointing to the end of the resulting range of elements which are not equal to
value
.- Pre
The range
[first, last)
shall not overlap the range[result, result + (last - first))
.