mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-29 12:27:33 +02:00
a couple small edits to the iterator adaptor tutorial
[SVN r21700]
This commit is contained in:
@ -348,17 +348,19 @@ to who-knows-where? The most we can do with that incremented
|
|||||||
position is to compare another <tt class="literal"><span class="pre">node_base*</span></tt> to it. In other
|
position is to compare another <tt class="literal"><span class="pre">node_base*</span></tt> to it. In other
|
||||||
words, the original iterator traverses a one-element array.</p>
|
words, the original iterator traverses a one-element array.</p>
|
||||||
</div>
|
</div>
|
||||||
<p>You probably didn't think of it that way, but the <tt class="literal"><span class="pre">node_base*</span></tt>
|
<p>You probably didn't think of it this way, but the <tt class="literal"><span class="pre">node_base*</span></tt>
|
||||||
object which underlies <tt class="literal"><span class="pre">node_iterator</span></tt> is itself an iterator,
|
object which underlies <tt class="literal"><span class="pre">node_iterator</span></tt> is itself an iterator,
|
||||||
just like all other pointers. If we examine that pointer closely
|
just like all other pointers. If we examine that pointer closely
|
||||||
from an iterator perspective, we can see that it has much in common
|
from an iterator perspective, we can see that it has much in common
|
||||||
with the <tt class="literal"><span class="pre">node_iterator</span></tt> we're building. First, they share most
|
with the <tt class="literal"><span class="pre">node_iterator</span></tt> we're building. First, they share most
|
||||||
of the same associated types (<tt class="literal"><span class="pre">value_type</span></tt>, <tt class="literal"><span class="pre">reference</span></tt>,
|
of the same associated types (<tt class="literal"><span class="pre">value_type</span></tt>, <tt class="literal"><span class="pre">reference</span></tt>,
|
||||||
<tt class="literal"><span class="pre">pointer</span></tt>, and <tt class="literal"><span class="pre">difference_type</span></tt>). Second, even much of the
|
<tt class="literal"><span class="pre">pointer</span></tt>, and <tt class="literal"><span class="pre">difference_type</span></tt>). Second, even some of the
|
||||||
core functionality is the same: <tt class="literal"><span class="pre">operator*</span></tt> and <tt class="literal"><span class="pre">operator==</span></tt> on
|
core functionality is the same: <tt class="literal"><span class="pre">operator*</span></tt> and <tt class="literal"><span class="pre">operator==</span></tt> on
|
||||||
the <tt class="literal"><span class="pre">node_iterator</span></tt> just return the result of invoking the same
|
the <tt class="literal"><span class="pre">node_iterator</span></tt> return the result of invoking the same
|
||||||
operations on the underlying pointer, via the <tt class="literal"><span class="pre">node_iterator</span></tt>'s
|
operations on the underlying pointer, via the <tt class="literal"><span class="pre">node_iterator</span></tt>'s
|
||||||
<a class="reference" href="iterator_facade.html#implementing-the-core-operations"><tt class="literal"><span class="pre">dereference</span></tt> and <tt class="literal"><span class="pre">equal</span></tt> member functions</a>)</p>
|
<a class="reference" href="iterator_facade.html#implementing-the-core-operations"><tt class="literal"><span class="pre">dereference</span></tt> and <tt class="literal"><span class="pre">equal</span></tt> member functions</a>). However, the <tt class="literal"><span class="pre">operator++</span></tt> for
|
||||||
|
<tt class="literal"><span class="pre">node_iterator</span></tt> behaves differently than for <tt class="literal"><span class="pre">node_base*</span></tt>
|
||||||
|
since it follows the <tt class="literal"><span class="pre">m_next</span></tt> pointer.</p>
|
||||||
<p>It turns out that the pattern of building an iterator on another
|
<p>It turns out that the pattern of building an iterator on another
|
||||||
iterator-like type (the <tt class="literal"><span class="pre">Base</span></tt> <a class="footnote-reference" href="#base" id="id3" name="id3"><sup>1</sup></a> type) while modifying
|
iterator-like type (the <tt class="literal"><span class="pre">Base</span></tt> <a class="footnote-reference" href="#base" id="id3" name="id3"><sup>1</sup></a> type) while modifying
|
||||||
just a few aspects of the underlying type's behavior is an
|
just a few aspects of the underlying type's behavior is an
|
||||||
@ -430,13 +432,15 @@ std::iterator_traits<Iterator>::<em>some-associated-type</em>
|
|||||||
<a class="reference" href="reverse_iterator.html"><tt class="literal"><span class="pre">reverse_iterator</span></tt></a> and the other Boost <a class="reference" href="index.html#specialized-adaptors">specialized iterator
|
<a class="reference" href="reverse_iterator.html"><tt class="literal"><span class="pre">reverse_iterator</span></tt></a> and the other Boost <a class="reference" href="index.html#specialized-adaptors">specialized iterator
|
||||||
adaptors</a> to get an idea of the sorts of things you can do with
|
adaptors</a> to get an idea of the sorts of things you can do with
|
||||||
<tt class="literal"><span class="pre">iterator_adaptor</span></tt>. In particular, have a look at
|
<tt class="literal"><span class="pre">iterator_adaptor</span></tt>. In particular, have a look at
|
||||||
<a class="reference" href="counting_iterator.html"><tt class="literal"><span class="pre">counting_iterator</span></tt></a>, which demonstrates that <tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s <tt class="literal"><span class="pre">Base</span></tt> type needn't be an iterator.</p>
|
<a class="reference" href="transform_iterator.html"><tt class="literal"><span class="pre">transform_iterator</span></tt></a>, which is perhaps the most straightforward
|
||||||
|
adaptor, and also <a class="reference" href="counting_iterator.html"><tt class="literal"><span class="pre">counting_iterator</span></tt></a>, which demonstrates that
|
||||||
|
<tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s <tt class="literal"><span class="pre">Base</span></tt> type needn't be an iterator.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="footer" />
|
<hr class="footer" />
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<a class="reference" href="iterator_adaptor.rst">View document source</a>.
|
<a class="reference" href="iterator_adaptor.rst">View document source</a>.
|
||||||
Generated on: 2004-01-13 14:26 UTC.
|
Generated on: 2004-01-13 19:35 UTC.
|
||||||
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>
|
||||||
|
@ -20,17 +20,19 @@ we're going to pick up right where it left off.
|
|||||||
position is to compare another ``node_base*`` to it. In other
|
position is to compare another ``node_base*`` to it. In other
|
||||||
words, the original iterator traverses a one-element array.
|
words, the original iterator traverses a one-element array.
|
||||||
|
|
||||||
You probably didn't think of it that way, but the ``node_base*``
|
You probably didn't think of it this way, but the ``node_base*``
|
||||||
object which underlies ``node_iterator`` is itself an iterator,
|
object which underlies ``node_iterator`` is itself an iterator,
|
||||||
just like all other pointers. If we examine that pointer closely
|
just like all other pointers. If we examine that pointer closely
|
||||||
from an iterator perspective, we can see that it has much in common
|
from an iterator perspective, we can see that it has much in common
|
||||||
with the ``node_iterator`` we're building. First, they share most
|
with the ``node_iterator`` we're building. First, they share most
|
||||||
of the same associated types (``value_type``, ``reference``,
|
of the same associated types (``value_type``, ``reference``,
|
||||||
``pointer``, and ``difference_type``). Second, even much of the
|
``pointer``, and ``difference_type``). Second, even some of the
|
||||||
core functionality is the same: ``operator*`` and ``operator==`` on
|
core functionality is the same: ``operator*`` and ``operator==`` on
|
||||||
the ``node_iterator`` just return the result of invoking the same
|
the ``node_iterator`` return the result of invoking the same
|
||||||
operations on the underlying pointer, via the ``node_iterator``\ 's
|
operations on the underlying pointer, via the ``node_iterator``\ 's
|
||||||
|dereference_and_equal|_)
|
|dereference_and_equal|_). However, the ``operator++`` for
|
||||||
|
``node_iterator`` behaves differently than for ``node_base*``
|
||||||
|
since it follows the ``m_next`` pointer.
|
||||||
|
|
||||||
.. |dereference_and_equal| replace:: ``dereference`` and ``equal`` member functions
|
.. |dereference_and_equal| replace:: ``dereference`` and ``equal`` member functions
|
||||||
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
||||||
@ -112,8 +114,9 @@ We urge you to review the documentation and implementations of
|
|||||||
|reverse_iterator|_ and the other Boost `specialized iterator
|
|reverse_iterator|_ and the other Boost `specialized iterator
|
||||||
adaptors`__ to get an idea of the sorts of things you can do with
|
adaptors`__ to get an idea of the sorts of things you can do with
|
||||||
``iterator_adaptor``. In particular, have a look at
|
``iterator_adaptor``. In particular, have a look at
|
||||||
|counting_iterator|_, which demonstrates that ``iterator_adaptor``\
|
|transform_iterator|_, which is perhaps the most straightforward
|
||||||
's ``Base`` type needn't be an iterator.
|
adaptor, and also |counting_iterator|_, which demonstrates that
|
||||||
|
``iterator_adaptor``\ 's ``Base`` type needn't be an iterator.
|
||||||
|
|
||||||
.. |reverse_iterator| replace:: ``reverse_iterator``
|
.. |reverse_iterator| replace:: ``reverse_iterator``
|
||||||
.. _reverse_iterator: reverse_iterator.html
|
.. _reverse_iterator: reverse_iterator.html
|
||||||
@ -121,5 +124,8 @@ adaptors`__ to get an idea of the sorts of things you can do with
|
|||||||
.. |counting_iterator| replace:: ``counting_iterator``
|
.. |counting_iterator| replace:: ``counting_iterator``
|
||||||
.. _counting_iterator: counting_iterator.html
|
.. _counting_iterator: counting_iterator.html
|
||||||
|
|
||||||
|
.. |transform_iterator| replace:: ``transform_iterator``
|
||||||
|
.. _transform_iterator: transform_iterator.html
|
||||||
|
|
||||||
__ index.html#specialized-adaptors
|
__ index.html#specialized-adaptors
|
||||||
|
|
||||||
|
@ -1023,7 +1023,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:24 UTC.
|
Generated on: 2004-01-13 19:31 UTC.
|
||||||
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>
|
||||||
|
Reference in New Issue
Block a user