rotate_copy.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #ifndef BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP
  11. #define BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP
  12. #include <boost/compute/system.hpp>
  13. #include <boost/compute/algorithm/copy.hpp>
  14. namespace boost {
  15. namespace compute {
  16. /// Performs left rotation such that element at n_first comes to the
  17. /// beginning and the output is stored in range starting at result.
  18. ///
  19. /// Space complexity: \Omega(1)
  20. ///
  21. /// \see rotate()
  22. template<class InputIterator, class OutputIterator>
  23. inline void rotate_copy(InputIterator first,
  24. InputIterator n_first,
  25. InputIterator last,
  26. OutputIterator result,
  27. command_queue &queue = system::default_queue())
  28. {
  29. size_t count = detail::iterator_range_size(first, n_first);
  30. size_t count2 = detail::iterator_range_size(n_first, last);
  31. ::boost::compute::copy(first+count, last, result, queue);
  32. ::boost::compute::copy(first, first+count, result+count2, queue);
  33. }
  34. } //end compute namespace
  35. } //end boost namespace
  36. #endif // BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP