source: XIOS/dev/dev_olga/src/extern/boost/include/boost/range/algorithm/permutation.hpp @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 3.7 KB
Line 
1//  Copyright Neil Groves 2009. Use, modification and
2//  distribution is subject to the Boost Software License, Version
3//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
4//  http://www.boost.org/LICENSE_1_0.txt)
5//
6//
7// For more information, see http://www.boost.org/libs/range/
8//
9#ifndef BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
10#define BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
11
12#include <boost/concept_check.hpp>
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15#include <boost/range/concepts.hpp>
16#include <algorithm>
17
18namespace boost
19{
20    namespace range
21    {
22
23/// \brief template function next_permutation
24///
25/// range-based version of the next_permutation std algorithm
26///
27/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
28/// \pre Compare is a model of the BinaryPredicateConcept
29template<class BidirectionalRange>
30inline bool next_permutation(BidirectionalRange& rng)
31{
32    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
33    return std::next_permutation(boost::begin(rng), boost::end(rng));
34}
35
36/// \overload
37template<class BidirectionalRange>
38inline bool next_permutation(const BidirectionalRange& rng)
39{
40    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
41    return std::next_permutation(boost::begin(rng), boost::end(rng));
42}
43
44/// \overload
45template<class BidirectionalRange, class Compare>
46inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred)
47{
48    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
49    return std::next_permutation(boost::begin(rng), boost::end(rng),
50                                 comp_pred);
51}
52
53/// \overload
54template<class BidirectionalRange, class Compare>
55inline bool next_permutation(const BidirectionalRange& rng,
56                             Compare                   comp_pred)
57{
58    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
59    return std::next_permutation(boost::begin(rng), boost::end(rng),
60                                 comp_pred);
61}
62
63/// \brief template function prev_permutation
64///
65/// range-based version of the prev_permutation std algorithm
66///
67/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
68/// \pre Compare is a model of the BinaryPredicateConcept
69template<class BidirectionalRange>
70inline bool prev_permutation(BidirectionalRange& rng)
71{
72    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
73    return std::prev_permutation(boost::begin(rng), boost::end(rng));
74}
75
76/// \overload
77template<class BidirectionalRange>
78inline bool prev_permutation(const BidirectionalRange& rng)
79{
80    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
81    return std::prev_permutation(boost::begin(rng), boost::end(rng));
82}
83
84/// \overload
85template<class BidirectionalRange, class Compare>
86inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred)
87{
88    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
89    return std::prev_permutation(boost::begin(rng), boost::end(rng),
90                                 comp_pred);
91}
92
93/// \overload
94template<class BidirectionalRange, class Compare>
95inline bool prev_permutation(const BidirectionalRange& rng,
96                             Compare                   comp_pred)
97{
98    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
99    return std::prev_permutation(boost::begin(rng), boost::end(rng),
100                                 comp_pred);
101}
102
103    } // namespace range
104    using range::next_permutation;
105    using range::prev_permutation;
106} // namespace boost
107
108#endif // include guard
Note: See TracBrowser for help on using the repository browser.