stlab.adobe.com Adobe Systems Incorporated

permutation.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 
00009 #ifndef ADOBE_ALGORITHM_PERMUTATION_HPP
00010 #define ADOBE_ALGORITHM_PERMUTATION_HPP
00011 
00012 #include <adobe/config.hpp>
00013 
00014 #include <boost/range/begin.hpp>
00015 #include <boost/range/end.hpp>
00016 #include <boost/bind.hpp>
00017 
00018 #include <algorithm>
00019 
00020 /*************************************************************************************************/
00021 
00022 namespace adobe {
00023 
00024 /*************************************************************************************************/
00033 /*************************************************************************************************/
00039 template <class BidirectionalRange>
00040 inline bool next_permutation(BidirectionalRange& range)
00041 {
00042     return std::next_permutation(boost::begin(range), boost::end(range));
00043 }
00044 
00050 template <class BidirectionalIterator, class Compare>
00051 inline bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp)
00052 {
00053     return std::next_permutation(first, last, boost::bind(comp, _1, _2));
00054 }
00055 
00061 template <class BidirectionalRange, class Compare>
00062 inline bool next_permutation(BidirectionalRange& range, Compare comp)
00063 {
00064     return adobe::next_permutation(boost::begin(range), boost::end(range), comp);
00065 }
00066 
00072 template <class BidirectionalRange>
00073 inline bool prev_permutation(BidirectionalRange& range)
00074 {
00075     return std::prev_permutation(boost::begin(range), boost::end(range));
00076 }
00077 
00083 template <class BidirectionalIterator, class Compare>
00084 inline bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp)
00085 {
00086     return std::prev_permutation(first, last, boost::bind(comp, _1, _2));
00087 }
00088 
00094 template <class BidirectionalRange, class Compare>
00095 inline bool prev_permutation(BidirectionalRange& range, Compare comp)
00096 {
00097     return adobe::prev_permutation(boost::begin(range), boost::end(range), comp);
00098 }
00099 
00100 /*************************************************************************************************/
00101 
00102 } // namespace adobe
00103 
00104 /*************************************************************************************************/
00105 
00106 #endif
00107 
00108 /*************************************************************************************************/

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