thrust::reverse_copy#
Overloads#
reverse_copy(exec, first, last, result)#
-
template<typename DerivedPolicy, typename BidirectionalIterator, typename OutputIterator>
OutputIterator thrust::reverse_copy( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- BidirectionalIterator first,
- BidirectionalIterator last,
- OutputIterator result,
reverse_copydiffers fromreverseonly in that the reversed range is written to a different output range, rather than inplace.reverse_copycopies elements from the range[first, last)to the range[result, result + (last - first))such that the copy is a reverse of the original range. Specifically: for everyisuch that0 <= i < (last - first),reverse_copyperforms the assignment*(result + (last - first) - i) = *(first + i).The return value is
result + (last - first)).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
reverse_copyto reverse an inputdevice_vectorof integers to an outputdevice_vectorusing thethrust::deviceexecution policy for parallelization:#include <thrust/reverse.h> #include <thrust/execution_policy.h> ... const int N = 6; int data[N] = {0, 1, 2, 3, 4, 5}; thrust::device_vector<int> input(data, data + N); thrust::device_vector<int> output(N); thrust::reverse_copy(thrust::device, v.begin(), v.end(), output.begin()); // input is still {0, 1, 2, 3, 4, 5} // output is now {5, 4, 3, 2, 1, 0}
See also
See also
reverse_iterator- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the range to reverse.
last – The end of the range to reverse.
result – The beginning of the output range.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
BidirectionalIterator – is a model of Bidirectional Iterator, and
BidirectionalIterator'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator.
- Pre:
The range
[first, last)and the range[result, result + (last - first))shall not overlap.
reverse_copy(first, last, result)#
-
template<typename BidirectionalIterator, typename OutputIterator>
OutputIterator thrust::reverse_copy( - BidirectionalIterator first,
- BidirectionalIterator last,
- OutputIterator result,
reverse_copydiffers fromreverseonly in that the reversed range is written to a different output range, rather than inplace.reverse_copycopies elements from the range[first, last)to the range[result, result + (last - first))such that the copy is a reverse of the original range. Specifically: for everyisuch that0 <= i < (last - first),reverse_copyperforms the assignment*(result + (last - first) - i) = *(first + i).The return value is
result + (last - first)).The following code snippet demonstrates how to use
reverse_copyto reverse an inputdevice_vectorof integers to an outputdevice_vector.#include <thrust/reverse.h> ... const int N = 6; int data[N] = {0, 1, 2, 3, 4, 5}; thrust::device_vector<int> input(data, data + N); thrust::device_vector<int> output(N); thrust::reverse_copy(v.begin(), v.end(), output.begin()); // input is still {0, 1, 2, 3, 4, 5} // output is now {5, 4, 3, 2, 1, 0}
See also
See also
reverse_iterator- Parameters:
first – The beginning of the range to reverse.
last – The end of the range to reverse.
result – The beginning of the output range.
- Template Parameters:
BidirectionalIterator – is a model of Bidirectional Iterator, and
BidirectionalIterator'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator.
- Pre:
The range
[first, last)and the range[result, result + (last - first))shall not overlap.