Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
rotate.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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
21namespace adobe {
22
23/**************************************************************************************************/
32/**************************************************************************************************/
38template <typename I> // I models Bidirectional Iterator
39std::pair<I, I> rotate(I f, I m, I l, std::bidirectional_iterator_tag) {
40 using std::reverse;
41
42 reverse(f, m);
43
44 reverse(m, l);
45
46 std::pair<I, I> p = reverse_until(f, m, l);
47
48 reverse(p.first, p.second);
49
50 return p;
51}
52
63template <typename I> // I models Forward Iterator
64std::pair<I, I> rotate(I f, I m, I l) {
65 typedef typename std::iterator_traits<I>::iterator_category iterator_category;
66
67 return rotate(f, m, l, iterator_category());
68}
69
70/**************************************************************************************************/
71
72} // namespace adobe
73
74/**************************************************************************************************/
75
76#endif
77
78/**************************************************************************************************/
std::pair< I, I > reverse_until(I f, I m, I l)
reverse implementation
Definition reverse.hpp:123
void reverse(BidirectionalRange &range)
reverse implementation
Definition reverse.hpp:92
std::pair< I, I > rotate(I f, I m, I l, std::bidirectional_iterator_tag)
Definition rotate.hpp:39