• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>next_permutation</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Chapter 1. Range 2.0">
8<link rel="up" href="../permutation.html" title="Permutation algorithms">
9<link rel="prev" href="../permutation.html" title="Permutation algorithms">
10<link rel="next" href="prev_permutation.html" title="prev_permutation">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../permutation.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../permutation.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="prev_permutation.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="range.reference.algorithms.permutation.next_permutation"></a><a class="link" href="next_permutation.html" title="next_permutation">next_permutation</a>
28</h5></div></div></div>
29<h6>
30<a name="range.reference.algorithms.permutation.next_permutation.h0"></a>
31            <span class="phrase"><a name="range.reference.algorithms.permutation.next_permutation.prototype"></a></span><a class="link" href="next_permutation.html#range.reference.algorithms.permutation.next_permutation.prototype">Prototype</a>
32          </h6>
33<p>
34</p>
35<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalRange</span><span class="special">&gt;</span>
36<span class="keyword">bool</span> <span class="identifier">next_permutation</span><span class="special">(</span><span class="identifier">BidirectionalRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">);</span>
37
38<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalRange</span><span class="special">&gt;</span>
39<span class="keyword">bool</span> <span class="identifier">next_permutation</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">BidirectionalRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">);</span>
40
41<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">&gt;</span>
42<span class="keyword">bool</span> <span class="identifier">next_permutation</span><span class="special">(</span><span class="identifier">BidirectionalRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">pred</span><span class="special">);</span>
43
44<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">BidirectionalRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">&gt;</span>
45<span class="keyword">bool</span> <span class="identifier">next_permutation</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">BidirectionalRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">pred</span><span class="special">);</span>
46</pre>
47<p>
48          </p>
49<h6>
50<a name="range.reference.algorithms.permutation.next_permutation.h1"></a>
51            <span class="phrase"><a name="range.reference.algorithms.permutation.next_permutation.description"></a></span><a class="link" href="next_permutation.html#range.reference.algorithms.permutation.next_permutation.description">Description</a>
52          </h6>
53<p>
54            <code class="computeroutput"><span class="identifier">next_permutation</span></code> transforms
55            the range of elements <code class="computeroutput"><span class="identifier">rng</span></code>
56            into the lexicographically next greater permutation of the elements if
57            such a permutation exists. If one does not exist then the range is transformed
58            into the lexicographically smallest permutation and <code class="computeroutput"><span class="keyword">false</span></code>
59            is returned. <code class="computeroutput"><span class="keyword">true</span></code> is returned
60            when the next greater permutation is successfully generated.
61          </p>
62<p>
63            The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code> in the non-predicate versions, and
64            by evaluating <code class="computeroutput"><span class="identifier">pred</span></code> in
65            the predicate versions.
66          </p>
67<h6>
68<a name="range.reference.algorithms.permutation.next_permutation.h2"></a>
69            <span class="phrase"><a name="range.reference.algorithms.permutation.next_permutation.definition"></a></span><a class="link" href="next_permutation.html#range.reference.algorithms.permutation.next_permutation.definition">Definition</a>
70          </h6>
71<p>
72            Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">permutation</span><span class="special">.</span><span class="identifier">hpp</span></code>
73          </p>
74<h6>
75<a name="range.reference.algorithms.permutation.next_permutation.h3"></a>
76            <span class="phrase"><a name="range.reference.algorithms.permutation.next_permutation.requirements"></a></span><a class="link" href="next_permutation.html#range.reference.algorithms.permutation.next_permutation.requirements">Requirements</a>
77          </h6>
78<p>
79            <span class="bold"><strong>For the non-predicate versions:</strong></span>
80          </p>
81<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
82<li class="listitem">
83                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>
84                is a model of the <a class="link" href="../../../concepts/bidirectional_range.html" title="Bidirectional Range">Bidirectional
85                Range</a> Concept.
86              </li>
87<li class="listitem">
88                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>
89                is mutable.
90              </li>
91<li class="listitem">
92                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>'s
93                value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
94              </li>
95<li class="listitem">
96                The ordering of objects of type <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>'s
97                value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>,
98                as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>
99                requirements.
100              </li>
101</ul></div>
102<p>
103            <span class="bold"><strong>For the predicate versions:</strong></span>
104          </p>
105<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
106<li class="listitem">
107                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>
108                is a model of the <a class="link" href="../../../concepts/bidirectional_range.html" title="Bidirectional Range">Bidirectional
109                Range</a> Concept.
110              </li>
111<li class="listitem">
112                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>
113                is mutable.
114              </li>
115<li class="listitem">
116                <code class="computeroutput"><span class="identifier">Compare</span></code> is a model
117                of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>.
118              </li>
119<li class="listitem">
120                <code class="computeroutput"><span class="identifier">BidirectionalRange</span></code>'s
121                value type is convertible to both of <code class="computeroutput"><span class="identifier">Compare</span></code>'s
122                argument types.
123              </li>
124</ul></div>
125<h6>
126<a name="range.reference.algorithms.permutation.next_permutation.h4"></a>
127            <span class="phrase"><a name="range.reference.algorithms.permutation.next_permutation.complexity"></a></span><a class="link" href="next_permutation.html#range.reference.algorithms.permutation.next_permutation.complexity">Complexity</a>
128          </h6>
129<p>
130            Linear. At most <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span> <span class="special">/</span> <span class="number">2</span></code>
131            swaps.
132          </p>
133</div>
134<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
135<td align="left"></td>
136<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
137      Neil Groves<p>
138        Distributed under the Boost Software License, Version 1.0. (See accompanying
139        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
140      </p>
141</div></td>
142</tr></table>
143<hr>
144<div class="spirit-nav">
145<a accesskey="p" href="../permutation.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../permutation.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="prev_permutation.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
146</div>
147</body>
148</html>
149