Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
permutation.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_PERMUTATION_HPP
9#define ADOBE_ALGORITHM_PERMUTATION_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15
16#include <algorithm>
17#include <functional>
18
19/**************************************************************************************************/
20
21namespace adobe {
22
23/**************************************************************************************************/
32/**************************************************************************************************/
38template <class BidirectionalRange>
39inline bool next_permutation(BidirectionalRange& range) {
40 return std::next_permutation(boost::begin(range), boost::end(range));
41}
42
48template <class BidirectionalIterator, class Compare>
49inline bool next_permutation(BidirectionalIterator first, BidirectionalIterator last,
50 Compare comp) {
51 return std::next_permutation(first, last,
52 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
53}
54
60template <class BidirectionalRange, class Compare>
61inline bool next_permutation(BidirectionalRange& range, Compare comp) {
62 return adobe::next_permutation(boost::begin(range), boost::end(range), comp);
63}
64
70template <class BidirectionalRange>
71inline bool prev_permutation(BidirectionalRange& range) {
72 return std::prev_permutation(boost::begin(range), boost::end(range));
73}
74
80template <class BidirectionalIterator, class Compare>
81inline bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last,
82 Compare comp) {
83 return std::prev_permutation(first, last,
84 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
85}
86
92template <class BidirectionalRange, class Compare>
93inline bool prev_permutation(BidirectionalRange& range, Compare comp) {
94 return adobe::prev_permutation(boost::begin(range), boost::end(range), comp);
95}
96
97/**************************************************************************************************/
98
99} // namespace adobe
100
101/**************************************************************************************************/
102
103#endif
104
105/**************************************************************************************************/
bool next_permutation(BidirectionalRange &range)
permutation implementation
bool prev_permutation(BidirectionalRange &range)
permutation implementation