stlab.adobe.com Adobe Systems Incorporated
rotate.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 /*************************************************************************************************/
7 
8 #ifndef ADOBE_ALGORITHM_ROTATE_HPP
9 #define ADOBE_ALGORITHM_ROTATE_HPP
10 
11 #include <adobe/config.hpp>
12 
14 
15 #include <algorithm>
16 #include <iterator>
17 #include <utility>
18 
19 /*************************************************************************************************/
20 
21 namespace adobe {
22 
23 /*************************************************************************************************/
32 /*************************************************************************************************/
38 template <typename I> // I models Bidirectional Iterator
39 std::pair<I, I> rotate(I f, I m, I l, std::bidirectional_iterator_tag)
40 {
41  using std::reverse;
42 
43  reverse(f, m);
44 
45  reverse(m, l);
46 
47  std::pair<I, I> p = reverse_until(f, m, l);
48 
49  reverse(p.first, p.second);
50 
51  return p;
52 }
53 
64 template <typename I> // I models Forward Iterator
65 std::pair<I, I> rotate(I f, I m, I l)
66 {
67  typedef typename std::iterator_traits<I>::iterator_category iterator_category;
68 
69  return rotate(f, m, l, iterator_category());
70 }
71 
72 /*************************************************************************************************/
73 
74 } // namespace adobe
75 
76 /*************************************************************************************************/
77 
78 #endif
79 
80 /*************************************************************************************************/
std::pair< I, I > rotate(I f, I m, I l, std::bidirectional_iterator_tag)
Definition: rotate.hpp:39
std::pair< I, I > reverse_until(I f, I m, I l)
reverse implementation
Definition: reverse.hpp:130
void reverse(BidirectionalRange &range)
reverse implementation
Definition: reverse.hpp:96

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google