Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:59:17

0001 //  Copyright Neil Groves 2009. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
0008 //
0009 #ifndef BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
0011 
0012 #include <boost/concept_check.hpp>
0013 #include <boost/range/begin.hpp>
0014 #include <boost/range/end.hpp>
0015 #include <boost/range/concepts.hpp>
0016 #include <algorithm>
0017 
0018 namespace boost
0019 {
0020     namespace range
0021     {
0022 
0023 /// \brief template function next_permutation
0024 ///
0025 /// range-based version of the next_permutation std algorithm
0026 ///
0027 /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
0028 /// \pre Compare is a model of the BinaryPredicateConcept
0029 template<class BidirectionalRange>
0030 inline bool next_permutation(BidirectionalRange& rng)
0031 {
0032     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
0033     return std::next_permutation(boost::begin(rng), boost::end(rng));
0034 }
0035 
0036 /// \overload
0037 template<class BidirectionalRange>
0038 inline bool next_permutation(const BidirectionalRange& rng)
0039 {
0040     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
0041     return std::next_permutation(boost::begin(rng), boost::end(rng));
0042 }
0043 
0044 /// \overload
0045 template<class BidirectionalRange, class Compare>
0046 inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred)
0047 {
0048     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
0049     return std::next_permutation(boost::begin(rng), boost::end(rng),
0050                                  comp_pred);
0051 }
0052 
0053 /// \overload
0054 template<class BidirectionalRange, class Compare>
0055 inline bool next_permutation(const BidirectionalRange& rng,
0056                              Compare                   comp_pred)
0057 {
0058     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
0059     return std::next_permutation(boost::begin(rng), boost::end(rng),
0060                                  comp_pred);
0061 }
0062 
0063 /// \brief template function prev_permutation
0064 ///
0065 /// range-based version of the prev_permutation std algorithm
0066 ///
0067 /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
0068 /// \pre Compare is a model of the BinaryPredicateConcept
0069 template<class BidirectionalRange>
0070 inline bool prev_permutation(BidirectionalRange& rng)
0071 {
0072     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
0073     return std::prev_permutation(boost::begin(rng), boost::end(rng));
0074 }
0075 
0076 /// \overload
0077 template<class BidirectionalRange>
0078 inline bool prev_permutation(const BidirectionalRange& rng)
0079 {
0080     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
0081     return std::prev_permutation(boost::begin(rng), boost::end(rng));
0082 }
0083 
0084 /// \overload
0085 template<class BidirectionalRange, class Compare>
0086 inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred)
0087 {
0088     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
0089     return std::prev_permutation(boost::begin(rng), boost::end(rng),
0090                                  comp_pred);
0091 }
0092 
0093 /// \overload
0094 template<class BidirectionalRange, class Compare>
0095 inline bool prev_permutation(const BidirectionalRange& rng,
0096                              Compare                   comp_pred)
0097 {
0098     BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
0099     return std::prev_permutation(boost::begin(rng), boost::end(rng),
0100                                  comp_pred);
0101 }
0102 
0103     } // namespace range
0104     using range::next_permutation;
0105     using range::prev_permutation;
0106 } // namespace boost
0107 
0108 #endif // include guard