1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Concept BidirectionalIterator</title> |
---|
5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> |
---|
7 | <link rel="start" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> |
---|
8 | <link rel="up" href="id620092-bb.html#concepts.reference" title="Concept reference"> |
---|
9 | <link rel="prev" href="ForwardIterator.html" title="Concept ForwardIterator"> |
---|
10 | <link rel="next" href="RandomAccessIterator.html" title="Concept RandomAccessIterator"> |
---|
11 | </head> |
---|
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
13 | <table cellpadding="2" width="100%"> |
---|
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> |
---|
15 | <td align="center"><a href="../../index.htm">Home</a></td> |
---|
16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
---|
17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
---|
18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
---|
19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
---|
20 | </table> |
---|
21 | <hr> |
---|
22 | <div class="spirit-nav"> |
---|
23 | <a accesskey="p" href="ForwardIterator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="id620092-bb.html#concepts.reference"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="RandomAccessIterator.html"><img src="images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="refentry" lang="en"> |
---|
26 | <a name="BidirectionalIterator"></a><div class="titlepage"></div> |
---|
27 | <div class="refnamediv"> |
---|
28 | <h2><span class="refentrytitle">Concept BidirectionalIterator</span></h2> |
---|
29 | <p>BidirectionalIterator</p> |
---|
30 | </div> |
---|
31 | <div class="refsect1" lang="en"> |
---|
32 | <a name="id961305"></a><h2>Description</h2> |
---|
33 | <p>A bidirectional iterator is an iterator that can read through a sequence |
---|
34 | of values. It can move in either direction through the sequence, and can |
---|
35 | be either mutable (data pointed to by it can be changed) or not mutable.</p> |
---|
36 | <p>An iterator represents a position in a sequence. Therefore, the |
---|
37 | iterator can point into the sequence (returning a value when dereferenced |
---|
38 | and being incrementable), or be off-the-end (and not dereferenceable or |
---|
39 | incrementable).</p> |
---|
40 | </div> |
---|
41 | <div class="refsect1" lang="en"> |
---|
42 | <a name="id961324"></a><h2>Refinement of</h2> |
---|
43 | <div class="itemizedlist"><ul type="disc"><li><p><a href="ForwardIterator.html" title="Concept ForwardIterator">ForwardIterator</a></p></li></ul></div> |
---|
44 | </div> |
---|
45 | <div class="refsect1" lang="en"> |
---|
46 | <a name="id961336"></a><h2>Associated types</h2> |
---|
47 | <div class="itemizedlist"><ul type="disc"> |
---|
48 | <li> |
---|
49 | <p><span class="bold"><strong>value_type</strong></span></p> |
---|
50 | <pre class="literallayout">std::iterator_traits<Iter>::value_type</pre> |
---|
51 | <p>The value type of the iterator</p> |
---|
52 | </li> |
---|
53 | <li> |
---|
54 | <p><span class="bold"><strong>category</strong></span></p> |
---|
55 | <pre class="literallayout">std::iterator_traits<Iter>::iterator_category</pre> |
---|
56 | <p>The category of the iterator</p> |
---|
57 | </li> |
---|
58 | </ul></div> |
---|
59 | </div> |
---|
60 | <div class="refsect1" lang="en"> |
---|
61 | <a name="id961376"></a><h2>Notation</h2> |
---|
62 | <div class="variablelist"><dl> |
---|
63 | <dt><span class="term">Iter</span></dt> |
---|
64 | <dd>A type playing the role of iterator-type in the <a href="BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a> concept.</dd> |
---|
65 | <dt> |
---|
66 | <span class="term"><code class="varname">i</code>, </span><span class="term"><code class="varname">j</code></span> |
---|
67 | </dt> |
---|
68 | <dd>Objects of type Iter</dd> |
---|
69 | <dt><span class="term"><code class="varname">x</code></span></dt> |
---|
70 | <dd>Object of type value_type</dd> |
---|
71 | </dl></div> |
---|
72 | </div> |
---|
73 | <div class="refsect1" lang="en"> |
---|
74 | <a name="id961415"></a><h2>Type expressions</h2> |
---|
75 | <div class="variablelist"><dl> |
---|
76 | <dt><span class="term">Category tag</span></dt> |
---|
77 | <dd><p><span class="type">category</span> must be |
---|
78 | derived from <span class="type">std::bidirectional_iterator_tag</span>. |
---|
79 | </p></dd> |
---|
80 | </dl></div> |
---|
81 | </div> |
---|
82 | <div class="refsect1" lang="en"> |
---|
83 | <a name="id961434"></a><h2>Valid expressions</h2> |
---|
84 | <div class="informaltable"><table class="table"> |
---|
85 | <colgroup> |
---|
86 | <col> |
---|
87 | <col> |
---|
88 | <col> |
---|
89 | <col> |
---|
90 | <col> |
---|
91 | <col> |
---|
92 | </colgroup> |
---|
93 | <thead><tr> |
---|
94 | <th>Name</th> |
---|
95 | <th>Expression</th> |
---|
96 | <th>Type</th> |
---|
97 | <th>Precondition</th> |
---|
98 | <th>Semantics</th> |
---|
99 | <th>Postcondition</th> |
---|
100 | </tr></thead> |
---|
101 | <tbody> |
---|
102 | <tr> |
---|
103 | <td><p>Predecrement</p></td> |
---|
104 | <td><p>--i</p></td> |
---|
105 | <td><p><span class="type">Iter &</span></p></td> |
---|
106 | <td><p><code class="computeroutput">i</code> is incrementable (not |
---|
107 | off-the-end) and some dereferenceable iterator <code class="computeroutput">j</code> exists |
---|
108 | such that <code class="computeroutput">i == ++j</code></p></td> |
---|
109 | <td> </td> |
---|
110 | <td> </td> |
---|
111 | </tr> |
---|
112 | <tr> |
---|
113 | <td><p>Postdecrement</p></td> |
---|
114 | <td><p>i--</p></td> |
---|
115 | <td><p><span class="type">Iter</span></p></td> |
---|
116 | <td><p>Same as for predecrement</p></td> |
---|
117 | <td><p>Equivalent to <code class="computeroutput">{Iter j = i; --i; return j;}</code></p></td> |
---|
118 | <td><p><code class="computeroutput">i</code> is dereferenceable or |
---|
119 | off-the-end</p></td> |
---|
120 | </tr> |
---|
121 | </tbody> |
---|
122 | </table></div> |
---|
123 | </div> |
---|
124 | <div class="refsect1" lang="en"> |
---|
125 | <a name="id961525"></a><h2>Complexity</h2> |
---|
126 | <p> |
---|
127 | All iterator operations must take amortized constant time. |
---|
128 | </p> |
---|
129 | </div> |
---|
130 | <div class="refsect1" lang="en"> |
---|
131 | <a name="id961532"></a><h2>Invariants</h2> |
---|
132 | <div class="variablelist"><dl> |
---|
133 | <dt><span class="term">Predecrement must return object</span></dt> |
---|
134 | <dd><p> |
---|
135 | <code class="computeroutput">&i = &(--i)</code> |
---|
136 | </p></dd> |
---|
137 | <dt><span class="term">Unique path through sequence</span></dt> |
---|
138 | <dd><p> |
---|
139 | <code class="computeroutput">i == j</code> implies <code class="computeroutput">--i == --j</code> |
---|
140 | </p></dd> |
---|
141 | <dt><span class="term">Increment and decrement are inverses</span></dt> |
---|
142 | <dd><p> |
---|
143 | <code class="computeroutput">++i; --i;</code> and <code class="computeroutput">--i; ++i;</code> must end up with the |
---|
144 | value of <code class="computeroutput">i</code> unmodified, if <code class="computeroutput">i</code> both of the |
---|
145 | operations in the pair are valid. |
---|
146 | </p></dd> |
---|
147 | </dl></div> |
---|
148 | </div> |
---|
149 | <div class="refsect1" lang="en"> |
---|
150 | <a name="id961600"></a><h2>Models</h2> |
---|
151 | <div class="itemizedlist"><ul type="disc"> |
---|
152 | <li><span class="simplelist"><span class="type">T *</span></span></li> |
---|
153 | <li><span class="simplelist"><span class="type">std::list<T>::iterator</span></span></li> |
---|
154 | </ul></div> |
---|
155 | </div> |
---|
156 | <div class="refsect1" lang="en"> |
---|
157 | <a name="id961621"></a><h2>See also</h2> |
---|
158 | <div class="itemizedlist"><ul type="disc"><li><p><a href="RandomAccessIterator.html" title="Concept RandomAccessIterator">RandomAccessIterator</a></p></li></ul></div> |
---|
159 | </div> |
---|
160 | </div> |
---|
161 | <table width="100%"><tr> |
---|
162 | <td align="left"></td> |
---|
163 | <td align="right"><small>Copyright © 2001, 2002 Indiana University<br>Copyright © 2000, 2001 University of Notre Dame du Lac<br>Copyright © 2000 Jeremy Siek, Lie-Quan Lee, Andrew Lumsdaine<br>Copyright © 1996-1999 Silicon Graphics Computer Systems, Inc.<br>Copyright © 1994 Hewlett-Packard Company</small></td> |
---|
164 | </tr></table> |
---|
165 | <hr> |
---|
166 | <div class="spirit-nav"> |
---|
167 | <a accesskey="p" href="ForwardIterator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="id620092-bb.html#concepts.reference"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="RandomAccessIterator.html"><img src="images/next.png" alt="Next"></a> |
---|
168 | </div> |
---|
169 | </body> |
---|
170 | </html> |
---|