File indexing completed on 2025-01-18 09:29:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
0013
0014 #include <boost/compute/system.hpp>
0015 #include <boost/compute/algorithm/copy.hpp>
0016 #include <boost/compute/container/vector.hpp>
0017
0018 namespace boost {
0019 namespace compute {
0020
0021
0022
0023
0024
0025
0026
0027 template<class InputIterator>
0028 inline void rotate(InputIterator first,
0029 InputIterator n_first,
0030 InputIterator last,
0031 command_queue &queue = system::default_queue())
0032 {
0033
0034 if (n_first==first || n_first==last)
0035 {
0036 return;
0037 }
0038
0039
0040 typedef typename std::iterator_traits<InputIterator>::value_type T;
0041
0042 size_t count = detail::iterator_range_size(first, n_first);
0043 size_t count2 = detail::iterator_range_size(first, last);
0044
0045 const context &context = queue.get_context();
0046 vector<T> temp(count2, context);
0047 ::boost::compute::copy(first, last, temp.begin(), queue);
0048
0049 ::boost::compute::copy(temp.begin()+count, temp.end(), first, queue);
0050 ::boost::compute::copy(temp.begin(), temp.begin()+count, last-count, queue);
0051 }
0052
0053 }
0054 }
0055
0056 #endif