remove_copy_if
#
Overloads#
remove_copy_if(exec, first, last, result, pred)
#
-
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator thrust::remove_copy_if( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator first,
- InputIterator last,
- OutputIterator result,
- Predicate pred,
remove_copy_if
copies elements from the range[first,last)
to a range beginning atresult
, except that elements for whichpred
istrue
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 is parallelized as determined by
exec
.The following code snippet demonstrates how to use
remove_copy_if
to copy a sequence of numbers to an output range while omitting even numbers using thethrust::host
execution policy for parallelization:#include <thrust/remove.h> #include <thrust/execution_policy.h> ... struct is_even { __host__ __device__ bool operator()(const int x) { return (x % 2) == 0; } }; ... const int N = 6; int V[N] = {-2, 0, -1, 0, 1, 2}; int result[2]; thrust::remove_copy_if(thrust::host, V, V + N, result, is_even()); // V remains {-2, 0, -1, 0, 1, 2} // result is now {-1, 1}
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
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.
pred – A predicate to evaluate for each element of the range
[first,last)
. Elements for whichpred
evaluates tofalse
are not copied to the resulting sequence.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator – is a model of Input Iterator,
InputIterator's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
, andInputIterator's
value_type
is convertible toPredicate's
argument type.OutputIterator – is a model of Output Iterator.
Predicate – is a model of Predicate.
- Returns:
An OutputIterator pointing to the end of the resulting range.
- Pre:
The range
[first, last)
shall not overlap the range[result, result + (last - first))
.
remove_copy_if(first, last, result, pred)
#
-
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator thrust::remove_copy_if( - InputIterator first,
- InputIterator last,
- OutputIterator result,
- Predicate pred,
remove_copy_if
copies elements from the range[first,last)
to a range beginning atresult
, except that elements for whichpred
istrue
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 following code snippet demonstrates how to use
remove_copy_if
to copy a sequence of numbers to an output range while omitting even numbers.#include <thrust/remove.h> ... struct is_even { __host__ __device__ bool operator()(const int x) { return (x % 2) == 0; } }; ... const int N = 6; int V[N] = {-2, 0, -1, 0, 1, 2}; int result[2]; thrust::remove_copy_if(V, V + N, result, is_even()); // V remains {-2, 0, -1, 0, 1, 2} // result is now {-1, 1}
See also
See also
See also
- 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.
pred – A predicate to evaluate for each element of the range
[first,last)
. Elements for whichpred
evaluates tofalse
are not copied to the resulting sequence.
- Template Parameters:
InputIterator – is a model of Input Iterator,
InputIterator's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
, andInputIterator's
value_type
is convertible toPredicate's
argument type.OutputIterator – is a model of Output Iterator.
Predicate – is a model of Predicate.
- Returns:
An OutputIterator pointing to the end of the resulting range.
- Pre:
The range
[first, last)
shall not overlap the range[result, result + (last - first))
.
remove_copy_if(exec, first, last, stencil, result, pred)
#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Predicate>
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 atresult
, except that elements for whichpred
of the corresponding stencil value istrue
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
.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 thethrust::host
execution policy for parallelization.#include <thrust/remove.h> #include <thrust/execution_policy.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]; thrust::remove_copy_if(thrust::host, V, V + N, S, result, ::cuda::std::identity{}); // V remains {-2, 0, -1, 0, 1, 2} // result is now {-1, 1}
See also
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the range of interest.
last – The end of the range of interest.
stencil – The beginning of the stencil sequence.
result – The resulting range is copied to the sequence beginning at this location.
pred – A predicate to evaluate for each element of the range
[first,last)
. Elements for whichpred
evaluates tofalse
are not copied to the resulting sequence.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator,
InputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator, and
InputIterator2's
value_type
is convertible toPredicate's
argument type.OutputIterator – is a model of Output Iterator.
Predicate – is a model of Predicate.
- Returns:
An OutputIterator pointing to the end of the resulting range.
- Pre:
The range
[stencil, stencil + (last - first))
shall not overlap the range[result, result + (last - first))
.
remove_copy_if(first, last, stencil, result, pred)
#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Predicate>
OutputIterator thrust::remove_copy_if( - InputIterator1 first,
- InputIterator1 last,
- InputIterator2 stencil,
- OutputIterator result,
- Predicate pred,
remove_copy_if
copies elements from the range[first,last)
to a range beginning atresult
, except that elements for whichpred
of the corresponding stencil value istrue
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 following code snippet demonstrates how to use
remove_copy_if
to copy a sequence of numbers to an output range while omitting specific elements.#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]; thrust::remove_copy_if(V, V + N, S, result, ::cuda::std::identity{}); // V remains {-2, 0, -1, 0, 1, 2} // result is now {-1, 1}
See also
See also
See also
See also
- Parameters:
first – The beginning of the range of interest.
last – The end of the range of interest.
stencil – The beginning of the stencil sequence.
result – The resulting range is copied to the sequence beginning at this location.
pred – A predicate to evaluate for each element of the range
[first,last)
. Elements for whichpred
evaluates tofalse
are not copied to the resulting sequence.
- Template Parameters:
InputIterator1 – is a model of Input Iterator,
InputIterator1's
value_type
is convertible to a type inOutputIterator's
set ofvalue_types
.InputIterator2 – is a model of Input Iterator, and
InputIterator2's
value_type
is convertible toPredicate's
argument type.OutputIterator – is a model of Output Iterator.
Predicate – is a model of Predicate.
- Returns:
An OutputIterator pointing to the end of the resulting range.
- Pre:
The range
[stencil, stencil + (last - first))
shall not overlap the range[result, result + (last - first))
.