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
|
||||
words, the original iterator traverses a one-element array.</p>
|
||||
</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,
|
||||
just like all other pointers. If we examine that pointer closely
|
||||
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
|
||||
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
|
||||
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
|
||||
<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
|
||||
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
|
||||
@ -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
|
||||
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
|
||||
<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>
|
||||
<hr class="footer" />
|
||||
<div class="footer">
|
||||
<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.
|
||||
</div>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user