1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
- #define BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
- #include <boost/compute/system.hpp>
- #include <boost/compute/algorithm/copy.hpp>
- #include <boost/compute/container/vector.hpp>
- namespace boost {
- namespace compute {
- template<class InputIterator>
- inline void rotate(InputIterator first,
- InputIterator n_first,
- InputIterator last,
- command_queue &queue = system::default_queue())
- {
-
- if (n_first==first || n_first==last)
- {
- return;
- }
-
- typedef typename std::iterator_traits<InputIterator>::value_type T;
- size_t count = detail::iterator_range_size(first, n_first);
- size_t count2 = detail::iterator_range_size(first, last);
- const context &context = queue.get_context();
- vector<T> temp(count2, context);
- ::boost::compute::copy(first, last, temp.begin(), queue);
- ::boost::compute::copy(temp.begin()+count, temp.end(), first, queue);
- ::boost::compute::copy(temp.begin(), temp.begin()+count, last-count, queue);
- }
- }
- }
- #endif
|