stlab.adobe.com Adobe Systems Incorporated
permutation.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 
9 #ifndef ADOBE_ALGORITHM_PERMUTATION_HPP
10 #define ADOBE_ALGORITHM_PERMUTATION_HPP
11 
12 #include <adobe/config.hpp>
13 
14 #include <boost/range/begin.hpp>
15 #include <boost/range/end.hpp>
16 #include <boost/bind.hpp>
17 
18 #include <algorithm>
19 
20 /*************************************************************************************************/
21 
22 namespace adobe {
23 
24 /*************************************************************************************************/
33 /*************************************************************************************************/
39 template <class BidirectionalRange>
40 inline bool next_permutation(BidirectionalRange& range)
41 {
42  return std::next_permutation(boost::begin(range), boost::end(range));
43 }
44 
50 template <class BidirectionalIterator, class Compare>
51 inline bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp)
52 {
53  return std::next_permutation(first, last, boost::bind(comp, _1, _2));
54 }
55 
61 template <class BidirectionalRange, class Compare>
62 inline bool next_permutation(BidirectionalRange& range, Compare comp)
63 {
64  return adobe::next_permutation(boost::begin(range), boost::end(range), comp);
65 }
66 
72 template <class BidirectionalRange>
73 inline bool prev_permutation(BidirectionalRange& range)
74 {
75  return std::prev_permutation(boost::begin(range), boost::end(range));
76 }
77 
83 template <class BidirectionalIterator, class Compare>
84 inline bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp)
85 {
86  return std::prev_permutation(first, last, boost::bind(comp, _1, _2));
87 }
88 
94 template <class BidirectionalRange, class Compare>
95 inline bool prev_permutation(BidirectionalRange& range, Compare comp)
96 {
97  return adobe::prev_permutation(boost::begin(range), boost::end(range), comp);
98 }
99 
100 /*************************************************************************************************/
101 
102 } // namespace adobe
103 
104 /*************************************************************************************************/
105 
106 #endif
107 
108 /*************************************************************************************************/

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