Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / common / boost / 1.64.0 / include / boost-1_64 / boost / compute / algorithm / rotate.hpp
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
11 #ifndef BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
12 #define BOOST_COMPUTE_ALGORITHM_ROTATE_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy.hpp>
16 #include <boost/compute/container/vector.hpp>
17
18 namespace boost {
19 namespace compute {
20
21 /// Performs left rotation such that element at \p n_first comes to the
22 /// beginning.
23 ///
24 /// \see rotate_copy()
25 template<class InputIterator>
26 inline void rotate(InputIterator first,
27                    InputIterator n_first,
28                    InputIterator last,
29                    command_queue &queue = system::default_queue())
30 {
31     //Handle trivial cases
32     if (n_first==first || n_first==last)
33     {
34         return;
35     }
36
37     //Handle others
38     typedef typename std::iterator_traits<InputIterator>::value_type T;
39
40     size_t count = detail::iterator_range_size(first, n_first);
41     size_t count2 = detail::iterator_range_size(first, last);
42
43     const context &context = queue.get_context();
44     vector<T> temp(count2, context);
45     ::boost::compute::copy(first, last, temp.begin(), queue);
46
47     ::boost::compute::copy(temp.begin()+count, temp.end(), first, queue);
48     ::boost::compute::copy(temp.begin(), temp.begin()+count, last-count, queue);
49 }
50
51 } //end compute namespace
52 } //end boost namespace
53
54 #endif // BOOST_COMPUTE_ALGORITHM_ROTATE_HPP