thrust

◆ reverse() [1/2]

template<typename DerivedPolicy , typename BidirectionalIterator >
__host__ __device__ void thrust::reverse ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
BidirectionalIterator  first,
BidirectionalIterator  last 
)

reverse reverses a range. That is: for every i such that 0 <= i <= (last - first) / 2, it exchanges *(first + i) and *(last - (i + 1)).

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the range to reverse.
lastThe end of the range to reverse.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
BidirectionalIteratoris a model of Bidirectional Iterator and BidirectionalIterator is mutable.

The following code snippet demonstrates how to use reverse to reverse a device_vector of integers using the thrust::device execution policy for parallelization:

#include <thrust/reverse.h>
...
const int N = 6;
int data[N] = {0, 1, 2, 3, 4, 5};
thrust::device_vector<int> v(data, data + N);
thrust::reverse(thrust::device, v.begin(), v.end());
// v is now {5, 4, 3, 2, 1, 0}
See also
http://www.sgi.com/tech/stl/reverse.html
reverse_copy
reverse_iterator