| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #pragma once |
|
|
| #include <thrust/detail/config.h> |
|
|
| #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) |
| # pragma GCC system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) |
| # pragma clang system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) |
| # pragma system_header |
| #endif |
| #include <thrust/system/detail/generic/reverse.h> |
| #include <thrust/advance.h> |
| #include <thrust/distance.h> |
| #include <thrust/detail/copy.h> |
| #include <thrust/swap.h> |
| #include <thrust/iterator/iterator_traits.h> |
| #include <thrust/iterator/reverse_iterator.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace system |
| { |
| namespace detail |
| { |
| namespace generic |
| { |
|
|
|
|
| template<typename ExecutionPolicy, typename BidirectionalIterator> |
| __host__ __device__ |
| void reverse(thrust::execution_policy<ExecutionPolicy> &exec, |
| BidirectionalIterator first, |
| BidirectionalIterator last) |
| { |
| typedef typename thrust::iterator_difference<BidirectionalIterator>::type difference_type; |
|
|
| |
| difference_type N = thrust::distance(first, last); |
| BidirectionalIterator mid(first); |
| thrust::advance(mid, N / 2); |
|
|
| |
| thrust::swap_ranges(exec, first, mid, thrust::make_reverse_iterator(last)); |
| } |
|
|
|
|
| template<typename ExecutionPolicy, |
| typename BidirectionalIterator, |
| typename OutputIterator> |
| __host__ __device__ |
| OutputIterator reverse_copy(thrust::execution_policy<ExecutionPolicy> &exec, |
| BidirectionalIterator first, |
| BidirectionalIterator last, |
| OutputIterator result) |
| { |
| return thrust::copy(exec, |
| thrust::make_reverse_iterator(last), |
| thrust::make_reverse_iterator(first), |
| result); |
| } |
|
|
|
|
| } |
| } |
| } |
| THRUST_NAMESPACE_END |
|
|
|
|
|
|