thrust::reverse
Defined in thrust/reverse.h
-
template<typename BidirectionalIterator>
void thrust::reverse(BidirectionalIterator first, BidirectionalIterator last) reverse
reverses a range. That is: for everyi
such that0 <= i <= (last - first) / 2
, it exchanges*(first + i)
and*(last - (i + 1))
.The following code snippet demonstrates how to use
reverse
to reverse adevice_vector
of integers.#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(v.begin(), v.end()); // v is now {5, 4, 3, 2, 1, 0}
See also
reverse_copy
See also
- Parameters
first – The beginning of the range to reverse.
last – The end of the range to reverse.
- Template Parameters
BidirectionalIterator – is a model of Bidirectional Iterator and
BidirectionalIterator
is mutable.