stlab.adobe.com Adobe Systems Incorporated

rotate.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 /*************************************************************************************************/
00007 
00008 #ifndef ADOBE_ALGORITHM_ROTATE_HPP
00009 #define ADOBE_ALGORITHM_ROTATE_HPP
00010 
00011 #include <adobe/config.hpp>
00012 
00013 #include <adobe/algorithm/reverse.hpp>
00014 
00015 #include <algorithm>
00016 #include <iterator>
00017 #include <utility>
00018 
00019 /*************************************************************************************************/
00020 
00021 namespace adobe {
00022 
00023 /*************************************************************************************************/
00032 /*************************************************************************************************/
00038 template <typename I> // I models Bidirectional Iterator
00039 std::pair<I, I> rotate(I f, I m, I l, std::bidirectional_iterator_tag)
00040 {
00041     using std::reverse;
00042 
00043     reverse(f, m);
00044 
00045     reverse(m, l);
00046 
00047     std::pair<I, I> p = reverse_until(f, m, l);
00048 
00049     reverse(p.first, p.second);
00050 
00051     return p;
00052 }
00053 
00064 template <typename I> // I models Forward Iterator
00065 std::pair<I, I> rotate(I f, I m, I l)
00066 {
00067     typedef typename std::iterator_traits<I>::iterator_category iterator_category;
00068 
00069     return rotate(f, m, l, iterator_category());
00070 }
00071 
00072 /*************************************************************************************************/
00073 
00074 } // namespace adobe
00075 
00076 /*************************************************************************************************/
00077 
00078 #endif
00079 
00080 /*************************************************************************************************/

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