thrust::replace_copy#
Overloads#
replace_copy(exec, first, last, result, old_value, new_value)#
-
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename T>
OutputIterator thrust::replace_copy( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator first,
- InputIterator last,
- OutputIterator result,
- const T &old_value,
- const T &new_value,
replace_copycopies elements from the range[first, last)to the range[result, result + (last-first)), except that any element equal toold_valueis not copied;new_valueis copied instead.More precisely, for every integer
nsuch that0 <= n < last-first,replace_copyperforms the assignment*(result+n) = new_valueif*(first+n) == old_value, and*(result+n) = *(first+n)otherwise.The algorithm’s execution is parallelized as determined by
exec.#include <thrust/replace.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> ... thrust::device_vector<int> A(4); A[0] = 1; A[1] = 2; A[2] = 3; A[3] = 1; thrust::device_vector<int> B(4); thrust::replace_copy(thrust::device, A.begin(), A.end(), B.begin(), 1, 99); // B contains [99, 2, 3, 99]
See also
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the sequence to copy from.
last – The end of the sequence to copy from.
result – The beginning of the sequence to copy to.
old_value – The value to replace.
new_value – The replacement value for which
*i == old_valueevaluates totrue.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator – is a model of Input Iterator.
OutputIterator – is a model of Output Iterator.
T – is a model of Assignable,
Tis a model of Equality Comparable,Tmay be compared for equality withInputIterator'svalue_type, andTis convertible toOutputIterator'svalue_type.
- Returns:
result + (last-first)- Pre:
firstmay equalresult, but the ranges[first, last)and[result, result + (last - first))shall not overlap otherwise.
replace_copy(first, last, result, old_value, new_value)#
-
template<typename InputIterator, typename OutputIterator, typename T>
OutputIterator thrust::replace_copy( - InputIterator first,
- InputIterator last,
- OutputIterator result,
- const T &old_value,
- const T &new_value,
replace_copycopies elements from the range[first, last)to the range[result, result + (last-first)), except that any element equal toold_valueis not copied;new_valueis copied instead.More precisely, for every integer
nsuch that0 <= n < last-first,replace_copyperforms the assignment*(result+n) = new_valueif*(first+n) == old_value, and*(result+n) = *(first+n)otherwise.#include <thrust/replace.h> #include <thrust/device_vector.h> ... thrust::device_vector<int> A(4); A[0] = 1; A[1] = 2; A[2] = 3; A[3] = 1; thrust::device_vector<int> B(4); thrust::replace_copy(A.begin(), A.end(), B.begin(), 1, 99); // B contains [99, 2, 3, 99]
See also
See also
See also
See also
- Parameters:
first – The beginning of the sequence to copy from.
last – The end of the sequence to copy from.
result – The beginning of the sequence to copy to.
old_value – The value to replace.
new_value – The replacement value for which
*i == old_valueevaluates totrue.
- Template Parameters:
InputIterator – is a model of Input Iterator.
OutputIterator – is a model of Output Iterator.
T – is a model of Assignable,
Tis a model of Equality Comparable,Tmay be compared for equality withInputIterator'svalue_type, andTis convertible toOutputIterator'svalue_type.
- Returns:
result + (last-first)- Pre:
firstmay equalresult, but the ranges[first, last)and[result, result + (last - first))shall not overlap otherwise.