removed same diff type req from Interoperator

and did some work on permutation iterator


[SVN r21705]
This commit is contained in:
Jeremy Siek
2004-01-13 21:00:31 +00:00
parent 9540444061
commit d2dae62215
4 changed files with 195 additions and 75 deletions

View File

@ -827,11 +827,11 @@ random_access_traversal_tag for consistency -->
<h4><a class="toc-backref" href="#id21" name="interoperable-iterators-lib-interoperable-iterators">Interoperable Iterators [lib.interoperable.iterators]</a></h4> <h4><a class="toc-backref" href="#id21" name="interoperable-iterators-lib-interoperable-iterators">Interoperable Iterators [lib.interoperable.iterators]</a></h4>
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> that models Single Pass Iterator is <p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> that models Single Pass Iterator is
<em>interoperable with</em> a class or built-in type <tt class="literal"><span class="pre">Y</span></tt> that also models <em>interoperable with</em> a class or built-in type <tt class="literal"><span class="pre">Y</span></tt> that also models
Single Pass Iterator if both <tt class="literal"><span class="pre">X</span></tt> and <tt class="literal"><span class="pre">Y</span></tt> have the same difference Single Pass Iterator if both <tt class="literal"><span class="pre">X</span></tt> and <tt class="literal"><span class="pre">Y</span></tt> have the same traversal
type and traversal tag and if the following expressions are valid and tag and if the following expressions are valid and respect the stated
respect the stated semantics. In the tables below, <tt class="literal"><span class="pre">x</span></tt> is an object semantics. In the tables below, <tt class="literal"><span class="pre">x</span></tt> is an object of type <tt class="literal"><span class="pre">X</span></tt>,
of type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">y</span></tt> is an object of type <tt class="literal"><span class="pre">Y</span></tt>, <tt class="literal"><span class="pre">Distance</span></tt> is <tt class="literal"><span class="pre">y</span></tt> is an object of type <tt class="literal"><span class="pre">Y</span></tt>, <tt class="literal"><span class="pre">Distance</span></tt> is
<tt class="literal"><span class="pre">iterator_traits&lt;X&gt;::difference_type</span></tt>, and <tt class="literal"><span class="pre">n</span></tt> represents a <tt class="literal"><span class="pre">iterator_traits&lt;Y&gt;::difference_type</span></tt>, and <tt class="literal"><span class="pre">n</span></tt> represents a
constant object of type <tt class="literal"><span class="pre">Distance</span></tt>.</p> constant object of type <tt class="literal"><span class="pre">Distance</span></tt>.</p>
<p>If the traversal tag for <tt class="literal"><span class="pre">X</span></tt> and <tt class="literal"><span class="pre">Y</span></tt> is convertible to <p>If the traversal tag for <tt class="literal"><span class="pre">X</span></tt> and <tt class="literal"><span class="pre">Y</span></tt> is convertible to
<tt class="literal"><span class="pre">single_pass_traversal_tag</span></tt> then the following requirements must be <tt class="literal"><span class="pre">single_pass_traversal_tag</span></tt> then the following requirements must be
@ -940,8 +940,9 @@ ordering relation</td>
</tr> </tr>
<tr><td><tt class="literal"><span class="pre">y</span> <span class="pre">-</span> <span class="pre">x</span></tt></td> <tr><td><tt class="literal"><span class="pre">y</span> <span class="pre">-</span> <span class="pre">x</span></tt></td>
<td><tt class="literal"><span class="pre">Distance</span></tt></td> <td><tt class="literal"><span class="pre">Distance</span></tt></td>
<td><tt class="literal"><span class="pre">x</span> <span class="pre">&lt;</span> <span class="pre">y</span> <span class="pre">?</span>&nbsp; <span class="pre">distance(x,y)</span> <td><tt class="literal"><span class="pre">x</span> <span class="pre">&lt;</span> <span class="pre">y</span> <span class="pre">?</span>
<span class="pre">:</span> <span class="pre">-distance(y,x)</span></tt></td> <span class="pre">distance(Y(x),y)</span>
<span class="pre">:</span> <span class="pre">-distance(y,Y(x))</span></tt></td>
<td>pre: there exists a <td>pre: there exists a
value <tt class="literal"><span class="pre">n</span></tt> of value <tt class="literal"><span class="pre">n</span></tt> of
<tt class="literal"><span class="pre">Distance</span></tt> such that <tt class="literal"><span class="pre">Distance</span></tt> such that
@ -950,8 +951,9 @@ value <tt class="literal"><span class="pre">n</span></tt> of
</tr> </tr>
<tr><td><tt class="literal"><span class="pre">x</span> <span class="pre">-</span> <span class="pre">y</span></tt></td> <tr><td><tt class="literal"><span class="pre">x</span> <span class="pre">-</span> <span class="pre">y</span></tt></td>
<td><tt class="literal"><span class="pre">Distance</span></tt></td> <td><tt class="literal"><span class="pre">Distance</span></tt></td>
<td><tt class="literal"><span class="pre">y</span> <span class="pre">&lt;</span> <span class="pre">x</span> <span class="pre">?</span>&nbsp; <span class="pre">distance(y,x)</span> <td><tt class="literal"><span class="pre">y</span> <span class="pre">&lt;</span> <span class="pre">x</span> <span class="pre">?</span>
<span class="pre">:</span> <span class="pre">-distance(x,y)</span></tt></td> <span class="pre">distance(y,Y(x))</span>
<span class="pre">:</span> <span class="pre">-distance(Y(x),y)</span></tt></td>
<td>pre: there exists a <td>pre: there exists a
value <tt class="literal"><span class="pre">n</span></tt> of value <tt class="literal"><span class="pre">n</span></tt> of
<tt class="literal"><span class="pre">Distance</span></tt> such that <tt class="literal"><span class="pre">Distance</span></tt> such that
@ -1023,7 +1025,7 @@ LocalWords: TraversalTag typename lvalues DWA Hmm JGS mis enum -->
<hr class="footer" /> <hr class="footer" />
<div class="footer"> <div class="footer">
<a class="reference" href="new-iter-concepts.rst">View document source</a>. <a class="reference" href="new-iter-concepts.rst">View document source</a>.
Generated on: 2004-01-13 19:31 UTC. Generated on: 2004-01-13.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div> </div>
</body> </body>

View File

@ -669,11 +669,11 @@ Interoperable Iterators [lib.interoperable.iterators]
A class or built-in type ``X`` that models Single Pass Iterator is A class or built-in type ``X`` that models Single Pass Iterator is
*interoperable with* a class or built-in type ``Y`` that also models *interoperable with* a class or built-in type ``Y`` that also models
Single Pass Iterator if both ``X`` and ``Y`` have the same difference Single Pass Iterator if both ``X`` and ``Y`` have the same traversal
type and traversal tag and if the following expressions are valid and tag and if the following expressions are valid and respect the stated
respect the stated semantics. In the tables below, ``x`` is an object semantics. In the tables below, ``x`` is an object of type ``X``,
of type ``X``, ``y`` is an object of type ``Y``, ``Distance`` is ``y`` is an object of type ``Y``, ``Distance`` is
``iterator_traits<X>::difference_type``, and ``n`` represents a ``iterator_traits<Y>::difference_type``, and ``n`` represents a
constant object of type ``Distance``. constant object of type ``Distance``.
If the traversal tag for ``X`` and ``Y`` is convertible to If the traversal tag for ``X`` and ``Y`` is convertible to
@ -724,16 +724,16 @@ be met.
+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ +-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+
|``y <= x`` |convertible to ``bool`` |``!(y > x)`` | | |``y <= x`` |convertible to ``bool`` |``!(y > x)`` | |
+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ +-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+
|``y - x`` |``Distance`` |``x < y ? distance(x,y) |pre: there exists a | |``y - x`` |``Distance`` |``x < y ? |pre: there exists a |
| | |: -distance(y,x)`` |value ``n`` of | | | |distance(Y(x),y) |value ``n`` of |
| | | |``Distance`` such that| | | |: -distance(y,Y(x))`` |``Distance`` such that|
| | | |``x + n == y``. ``y | | | | |``x + n == y``. ``y |
| | | |== x + (y - x)``. | | | | |== x + (y - x)``. |
+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ +-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+
|``x - y`` |``Distance`` |``y < x ? distance(y,x) |pre: there exists a | |``x - y`` |``Distance`` |``y < x ? |pre: there exists a |
| | |: -distance(x,y)`` |value ``n`` of | | | |distance(y,Y(x)) |value ``n`` of |
| | | |``Distance`` such that| | | |: -distance(Y(x),y)`` |``Distance`` such that|
| | | |``y + n == x``. ``x | | | | |``y + n == x``. ``x |
| | | |== y + (x - y)``. | | | | |== y + (x - y)``. |
+-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+ +-------------------------------------------+-------------------------------------------------+-------------------------+----------------------+

View File

@ -44,17 +44,18 @@ in a potentially different order.</td>
<div class="contents topic" id="table-of-contents"> <div class="contents topic" id="table-of-contents">
<p class="topic-title"><a name="table-of-contents">Table of Contents</a></p> <p class="topic-title"><a name="table-of-contents">Table of Contents</a></p>
<ul class="simple"> <ul class="simple">
<li><a class="reference" href="#introduction" id="id5" name="id5">Introduction</a></li> <li><a class="reference" href="#introduction" id="id2" name="id2">Introduction</a></li>
<li><a class="reference" href="#reference" id="id6" name="id6">Reference</a><ul> <li><a class="reference" href="#reference" id="id3" name="id3">Reference</a><ul>
<li><a class="reference" href="#permutation-iterator-requirements" id="id7" name="id7"><tt class="literal"><span class="pre">permutation_iterator</span></tt> requirements</a></li> <li><a class="reference" href="#permutation-iterator-requirements" id="id4" name="id4"><tt class="literal"><span class="pre">permutation_iterator</span></tt> requirements</a></li>
<li><a class="reference" href="#permutation-iterator-operations" id="id8" name="id8"><tt class="literal"><span class="pre">permutation_iterator</span></tt> operations</a></li> <li><a class="reference" href="#permutation-iterator-models" id="id5" name="id5"><tt class="literal"><span class="pre">permutation_iterator</span></tt> models</a></li>
<li><a class="reference" href="#permutation-iterator-operations" id="id6" name="id6"><tt class="literal"><span class="pre">permutation_iterator</span></tt> operations</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#example" id="id9" name="id9">Example</a></li> <li><a class="reference" href="#example" id="id7" name="id7">Example</a></li>
</ul> </ul>
</div> </div>
<div class="section" id="introduction"> <div class="section" id="introduction">
<h1><a class="toc-backref" href="#id5" name="introduction">Introduction</a></h1> <h1><a class="toc-backref" href="#id2" name="introduction">Introduction</a></h1>
<p>The adaptor takes two arguments:</p> <p>The adaptor takes two arguments:</p>
<blockquote> <blockquote>
<ul class="simple"> <ul class="simple">
@ -74,7 +75,7 @@ end permutation iterator is completely defined by means of the
past-the-end iterator to the indices.</p> past-the-end iterator to the indices.</p>
</div> </div>
<div class="section" id="reference"> <div class="section" id="reference">
<h1><a class="toc-backref" href="#id6" name="reference">Reference</a></h1> <h1><a class="toc-backref" href="#id3" name="reference">Reference</a></h1>
<pre class="literal-block"> <pre class="literal-block">
template&lt; class ElementIterator template&lt; class ElementIterator
, class IndexIterator , class IndexIterator
@ -94,9 +95,12 @@ public:
, typename enable_if_convertible&lt;OEIter, ElementIterator&gt;::type* = 0 , typename enable_if_convertible&lt;OEIter, ElementIterator&gt;::type* = 0
, typename enable_if_convertible&lt;OIIter, IndexIterator&gt;::type* = 0 , typename enable_if_convertible&lt;OIIter, IndexIterator&gt;::type* = 0
); );
reference operator*() const;
permutation_iterator&amp; operator++();
ElementIterator base() const; ElementIterator base() const;
private: private:
ElementIterator m_iterator; // exposition ElementIterator m_iterator; // exposition only
IndexIterator m_order; // exposition only
}; };
template &lt;class ElementIterator, class IndexIterator&gt; template &lt;class ElementIterator, class IndexIterator&gt;
@ -104,33 +108,87 @@ permutation_iterator&lt;ElementIterator, IndexIterator&gt;
make_permutation_iterator( ElementIterator e, IndexIterator i); make_permutation_iterator( ElementIterator e, IndexIterator i);
</pre> </pre>
<div class="section" id="permutation-iterator-requirements"> <div class="section" id="permutation-iterator-requirements">
<h2><a class="toc-backref" href="#id7" name="permutation-iterator-requirements"><tt class="literal"><span class="pre">permutation_iterator</span></tt> requirements</a></h2> <h2><a class="toc-backref" href="#id4" name="permutation-iterator-requirements"><tt class="literal"><span class="pre">permutation_iterator</span></tt> requirements</a></h2>
<p><tt class="literal"><span class="pre">ElementIterator</span></tt> must be a model of <a class="reference" href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>. <p><tt class="literal"><span class="pre">ElementIterator</span></tt> shall model Random Access Traversal Iterator.
<tt class="literal"><span class="pre">IndexIterator</span></tt> must at least be a model <a class="reference" href="http://www.sgi.com/tech/stl/ForwardIterator.html">ForwardIterator</a>. The <tt class="literal"><span class="pre">IndexIterator</span></tt> shall model Readable Iterator. The value type of
value type of the <tt class="literal"><span class="pre">IndexIterator</span></tt> must be convertible to the the <tt class="literal"><span class="pre">IndexIterator</span></tt> must be convertible to the difference type of
difference type of <tt class="literal"><span class="pre">ElementIterator</span></tt>.</p> <tt class="literal"><span class="pre">ElementIterator</span></tt>.</p>
</div>
<div class="section" id="permutation-iterator-models">
<h2><a class="toc-backref" href="#id5" name="permutation-iterator-models"><tt class="literal"><span class="pre">permutation_iterator</span></tt> models</a></h2>
<p><tt class="literal"><span class="pre">permutation_iterator</span></tt> models the same iterator traversal concepts
as <tt class="literal"><span class="pre">IndexIterator</span></tt> and the same iterator access concepts as
<tt class="literal"><span class="pre">ElementIterator</span></tt>.</p>
<p>If <tt class="literal"><span class="pre">IndexIterator</span></tt> models Single Pass Iterator and
<tt class="literal"><span class="pre">ElementIterator</span></tt> models Readable Iterator then
<tt class="literal"><span class="pre">permutation_iterator</span></tt> models Input Iterator.</p>
<p>If <tt class="literal"><span class="pre">IndexIterator</span></tt> models Forward Traversal Iterator and
<tt class="literal"><span class="pre">ElementIterator</span></tt> models Readable Lvalue Iterator then
<tt class="literal"><span class="pre">permutation_iterator</span></tt> models Forward Iterator.</p>
<p>If <tt class="literal"><span class="pre">IndexIterator</span></tt> models Bidirectional Traversal Iterator and
<tt class="literal"><span class="pre">ElementIterator</span></tt> models Readable Lvalue Iterator then
<tt class="literal"><span class="pre">permutation_iterator</span></tt> models Bidirectional Iterator.</p>
<p>If <tt class="literal"><span class="pre">IndexIterator</span></tt> models Random Access Traversal Iterator and
<tt class="literal"><span class="pre">ElementIterator</span></tt> models Readable Lvalue Iterator then
<tt class="literal"><span class="pre">permutation_iterator</span></tt> models Random Access Iterator.</p>
</div> </div>
<div class="section" id="permutation-iterator-operations"> <div class="section" id="permutation-iterator-operations">
<h2><a class="toc-backref" href="#id8" name="permutation-iterator-operations"><tt class="literal"><span class="pre">permutation_iterator</span></tt> operations</a></h2> <h2><a class="toc-backref" href="#id6" name="permutation-iterator-operations"><tt class="literal"><span class="pre">permutation_iterator</span></tt> operations</a></h2>
<p>The permutation iterator implements the member functions and operators <p>In addition to those operations required by the concepts that
required for the <a class="reference" href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">Random Access Iterator</a> concept. However, the <tt class="literal"><span class="pre">permutation_iterator</span></tt> models, <tt class="literal"><span class="pre">permutation_iterator</span></tt> provides the
permutation iterator can only meet the complexity guarantees of the following operations.</p>
same concept as the IndexIterator. Thus for instance, although the <p><tt class="literal"><span class="pre">permutation_iterator();</span></tt></p>
permutation iterator provides <tt class="literal"><span class="pre">operator+=(distance)</span></tt>, this operation <table class="field-list" frame="void" rules="none">
will take linear time in case the IndexIterator is a model of <col class="field-name" />
ForwardIterator instead of amortized constant time.</p> <col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Effects:</th><td class="field-body">Default constructs <tt class="literal"><span class="pre">m_iterator</span></tt> and <tt class="literal"><span class="pre">m_order</span></tt>.</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">explicit</span> <span class="pre">permutation_iterator(ElementIterator</span> <span class="pre">x,</span> <span class="pre">IndexIterator</span> <span class="pre">y);</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Effects:</th><td class="field-body">Constructs <tt class="literal"><span class="pre">m_iterator</span></tt> from <tt class="literal"><span class="pre">x</span></tt> and <tt class="literal"><span class="pre">m_order</span></tt> from <tt class="literal"><span class="pre">y</span></tt>.</td>
</tr>
</tbody>
</table>
<pre class="literal-block"> <pre class="literal-block">
template &lt;class ElementIterator, class IndexIterator&gt; template&lt; class OEIter, class OIIter, class V, class C, class R, class D &gt;
permutation_iterator&lt;ElementIterator, IndexIterator&gt; permutation_iterator(
make_permutation_iterator(ElementIterator e, IndexIterator i); permutation_iterator&lt;OEIter, OIIter, V, C, R, D&gt; const&amp; r
, typename enable_if_convertible&lt;OEIter, ElementIterator&gt;::type* = 0
, typename enable_if_convertible&lt;OIIter, IndexIterator&gt;::type* = 0
);
</pre> </pre>
<table class="field-list" frame="void" rules="none"> <table class="field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
<col class="field-body" /> <col class="field-body" />
<tbody valign="top"> <tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">permutation_iterator&lt;ElementIterator,</span> <span class="pre">IndexIterator&gt;</span></tt> <tr class="field"><th class="field-name">Effects:</th><td class="field-body">Constructs <tt class="literal"><span class="pre">m_iterator</span></tt> from <tt class="literal"><span class="pre">r.m_iterator</span></tt> and
that views the range of elements starting at <tt class="literal"><span class="pre">e`</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">order</span> <span class="pre">given</span> <tt class="literal"><span class="pre">m_order</span></tt> from <tt class="literal"><span class="pre">y.m_order</span></tt>.</td>
<span class="pre">by</span> <span class="pre">``i</span></tt>.</td> </tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">reference</span> <span class="pre">operator*()</span> <span class="pre">const;</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">*(m_iterator</span> <span class="pre">+</span> <span class="pre">*m_order)</span></tt></td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">permutation_iterator&amp;</span> <span class="pre">operator++();</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><tt class="literal"><span class="pre">++m_order</span></tt></td>
</tr>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">*this</span></tt></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -143,10 +201,23 @@ that views the range of elements starting at <tt class="literal"><span class="pr
</tr> </tr>
</tbody> </tbody>
</table> </table>
<pre class="literal-block">
template &lt;class ElementIterator, class IndexIterator&gt;
permutation_iterator&lt;ElementIterator, IndexIterator&gt;
make_permutation_iterator(ElementIterator e, IndexIterator i);
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">permutation_iterator&lt;ElementIterator,</span> <span class="pre">IndexIterator&gt;(e,</span> <span class="pre">i)</span></tt></td>
</tr>
</tbody>
</table>
</div> </div>
</div> </div>
<div class="section" id="example"> <div class="section" id="example">
<h1><a class="toc-backref" href="#id9" name="example">Example</a></h1> <h1><a class="toc-backref" href="#id7" name="example">Example</a></h1>
<pre class="literal-block"> <pre class="literal-block">
using namespace boost; using namespace boost;
int i = 0; int i = 0;
@ -214,7 +285,7 @@ Iterate backward with stride 2 : 6 8
<hr class="footer" /> <hr class="footer" />
<div class="footer"> <div class="footer">
<a class="reference" href="permutation_iterator.rst">View document source</a>. <a class="reference" href="permutation_iterator.rst">View document source</a>.
Generated on: 2004-01-13 14:27 UTC. Generated on: 2004-01-13.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div> </div>
</body> </body>

View File

@ -18,9 +18,12 @@
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0 , typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0 , typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
); );
reference operator*() const;
permutation_iterator& operator++();
ElementIterator base() const; ElementIterator base() const;
private: private:
ElementIterator m_iterator; // exposition ElementIterator m_iterator; // exposition only
IndexIterator m_order; // exposition only
}; };
template <class ElementIterator, class IndexIterator> template <class ElementIterator, class IndexIterator>
@ -32,30 +35,80 @@
``permutation_iterator`` requirements ``permutation_iterator`` requirements
------------------------------------- -------------------------------------
``ElementIterator`` must be a model of RandomAccessIterator__. ``ElementIterator`` shall model Random Access Traversal Iterator.
``IndexIterator`` must at least be a model ForwardIterator__. The ``IndexIterator`` shall model Readable Iterator. The value type of
value type of the ``IndexIterator`` must be convertible to the the ``IndexIterator`` must be convertible to the difference type of
difference type of ``ElementIterator``. ``ElementIterator``.
__ http://www.sgi.com/tech/stl/RandomAccessIterator.html
__ http://www.sgi.com/tech/stl/ForwardIterator.html
``permutation_iterator`` models
-------------------------------
``permutation_iterator`` models the same iterator traversal concepts
as ``IndexIterator`` and the same iterator access concepts as
``ElementIterator``.
If ``IndexIterator`` models Single Pass Iterator and
``ElementIterator`` models Readable Iterator then
``permutation_iterator`` models Input Iterator.
If ``IndexIterator`` models Forward Traversal Iterator and
``ElementIterator`` models Readable Lvalue Iterator then
``permutation_iterator`` models Forward Iterator.
If ``IndexIterator`` models Bidirectional Traversal Iterator and
``ElementIterator`` models Readable Lvalue Iterator then
``permutation_iterator`` models Bidirectional Iterator.
If ``IndexIterator`` models Random Access Traversal Iterator and
``ElementIterator`` models Readable Lvalue Iterator then
``permutation_iterator`` models Random Access Iterator.
``permutation_iterator`` operations ``permutation_iterator`` operations
----------------------------------- -----------------------------------
The permutation iterator implements the member functions and operators In addition to those operations required by the concepts that
required for the `Random Access Iterator`__ concept. However, the ``permutation_iterator`` models, ``permutation_iterator`` provides the
permutation iterator can only meet the complexity guarantees of the following operations.
same concept as the IndexIterator. Thus for instance, although the
permutation iterator provides ``operator+=(distance)``, this operation
will take linear time in case the IndexIterator is a model of
ForwardIterator instead of amortized constant time.
__ http://www.sgi.com/tech/stl/RandomAccessIterator.html ``permutation_iterator();``
:Effects: Default constructs ``m_iterator`` and ``m_order``.
``explicit permutation_iterator(ElementIterator x, IndexIterator y);``
:Effects: Constructs ``m_iterator`` from ``x`` and ``m_order`` from ``y``.
::
template< class OEIter, class OIIter, class V, class C, class R, class D >
permutation_iterator(
permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
);
:Effects: Constructs ``m_iterator`` from ``r.m_iterator`` and
``m_order`` from ``y.m_order``.
``reference operator*() const;``
:Returns: ``*(m_iterator + *m_order)``
``permutation_iterator& operator++();``
:Effects: ``++m_order``
:Returns: ``*this``
``ElementIterator base() const;``
:Returns: ``m_iterator``
:: ::
@ -64,11 +117,5 @@ __ http://www.sgi.com/tech/stl/RandomAccessIterator.html
permutation_iterator<ElementIterator, IndexIterator> permutation_iterator<ElementIterator, IndexIterator>
make_permutation_iterator(ElementIterator e, IndexIterator i); make_permutation_iterator(ElementIterator e, IndexIterator i);
:Returns: An instance of ``permutation_iterator<ElementIterator, IndexIterator>`` :Returns: ``permutation_iterator<ElementIterator, IndexIterator>(e, i)``
that views the range of elements starting at ``e` in the order given
by ``i``.
``ElementIterator base() const;``
:Returns: ``m_iterator``