1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Concept BidirectionalIterator</title> 6<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="concept_check.html#concepts.reference" title="Concept reference"> 10<link rel="prev" href="ForwardIterator.html" title="Concept ForwardIterator"> 11<link rel="next" href="RandomAccessIterator.html" title="Concept RandomAccessIterator"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> 16<td align="center"><a href="../../index.html">Home</a></td> 17<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="ForwardIterator.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="concept_check.html#concepts.reference"><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="RandomAccessIterator.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="BidirectionalIterator"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Concept BidirectionalIterator</span></h2> 30<p>BidirectionalIterator</p> 31</div> 32<div class="refsect1"> 33<a name="id-1.3.49.3.8.3"></a><h2>Description</h2> 34<p>A bidirectional iterator is an iterator that can read through a sequence 35 of values. It can move in either direction through the sequence, and can 36 be either mutable (data pointed to by it can be changed) or not mutable.</p> 37<p>An iterator represents a position in a sequence. Therefore, the 38 iterator can point into the sequence (returning a value when dereferenced 39 and being incrementable), or be off-the-end (and not dereferenceable or 40 incrementable).</p> 41</div> 42<div class="refsect1"> 43<a name="id-1.3.49.3.8.4"></a><h2>Refinement of</h2> 44<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="link" href="ForwardIterator.html" title="Concept ForwardIterator">ForwardIterator</a></p></li></ul></div> 45</div> 46<div class="refsect1"> 47<a name="id-1.3.49.3.8.5"></a><h2>Associated types</h2> 48<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 49<li class="listitem"> 50<p><span class="bold"><strong>value_type</strong></span></p> 51<pre class="literallayout">std::iterator_traits<Iter>::value_type</pre> 52<p>The value type of the iterator</p> 53</li> 54<li class="listitem"> 55<p><span class="bold"><strong>category</strong></span></p> 56<pre class="literallayout">std::iterator_traits<Iter>::iterator_category</pre> 57<p>The category of the iterator</p> 58</li> 59</ul></div> 60</div> 61<div class="refsect1"> 62<a name="id-1.3.49.3.8.6"></a><h2>Notation</h2> 63<div class="variablelist"><dl class="variablelist"> 64<dt><span class="term">Iter</span></dt> 65<dd>A type playing the role of iterator-type in the <a class="link" href="BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a> concept.</dd> 66<dt> 67<span class="term"><code class="varname">i</code>, </span><span class="term"><code class="varname">j</code></span> 68</dt> 69<dd>Objects of type Iter</dd> 70<dt><span class="term"><code class="varname">x</code></span></dt> 71<dd>Object of type value_type</dd> 72</dl></div> 73</div> 74<div class="refsect1"> 75<a name="id-1.3.49.3.8.7"></a><h2>Type expressions</h2> 76<div class="variablelist"><dl class="variablelist"> 77<dt><span class="term">Category tag</span></dt> 78<dd><p><span class="type">category</span> must be 79 derived from <span class="type">std::bidirectional_iterator_tag</span>. 80 </p></dd> 81</dl></div> 82</div> 83<div class="refsect1"> 84<a name="id-1.3.49.3.8.8"></a><h2>Valid expressions</h2> 85<div class="informaltable"><table class="table"> 86<colgroup> 87<col> 88<col> 89<col> 90<col> 91<col> 92<col> 93</colgroup> 94<thead><tr> 95<th>Name</th> 96<th>Expression</th> 97<th>Type</th> 98<th>Precondition</th> 99<th>Semantics</th> 100<th>Postcondition</th> 101</tr></thead> 102<tbody> 103<tr> 104<td><p>Predecrement</p></td> 105<td><p>--i</p></td> 106<td><p><span class="type">Iter &</span></p></td> 107<td><p><code class="computeroutput">i</code> is incrementable (not 108 off-the-end) and some dereferenceable iterator <code class="computeroutput">j</code> exists 109 such that <code class="computeroutput">i == ++j</code></p></td> 110<td> </td> 111<td> </td> 112</tr> 113<tr> 114<td><p>Postdecrement</p></td> 115<td><p>i--</p></td> 116<td><p><span class="type">Iter</span></p></td> 117<td><p>Same as for predecrement</p></td> 118<td><p>Equivalent to <code class="computeroutput">{Iter j = i; --i; return j;}</code></p></td> 119<td><p><code class="computeroutput">i</code> is dereferenceable or 120 off-the-end</p></td> 121</tr> 122</tbody> 123</table></div> 124</div> 125<div class="refsect1"> 126<a name="id-1.3.49.3.8.9"></a><h2>Complexity</h2> 127<p> 128 All iterator operations must take amortized constant time. 129 </p> 130</div> 131<div class="refsect1"> 132<a name="id-1.3.49.3.8.10"></a><h2>Invariants</h2> 133<div class="variablelist"><dl class="variablelist"> 134<dt><span class="term">Predecrement must return object</span></dt> 135<dd><p> 136 <code class="computeroutput">&i = &(--i)</code> 137 </p></dd> 138<dt><span class="term">Unique path through sequence</span></dt> 139<dd><p> 140 <code class="computeroutput">i == j</code> implies <code class="computeroutput">--i == --j</code> 141 </p></dd> 142<dt><span class="term">Increment and decrement are inverses</span></dt> 143<dd><p> 144 <code class="computeroutput">++i; --i;</code> and <code class="computeroutput">--i; ++i;</code> must end up with the 145 value of <code class="computeroutput">i</code> unmodified, if <code class="computeroutput">i</code> both of the 146 operations in the pair are valid. 147 </p></dd> 148</dl></div> 149</div> 150<div class="refsect1"> 151<a name="id-1.3.49.3.8.11"></a><h2>Models</h2> 152<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 153<li class="listitem"><span class="simplelist"><span class="type">T *</span></span></li> 154<li class="listitem"><span class="simplelist"><span class="type">std::list<T>::iterator</span></span></li> 155</ul></div> 156</div> 157<div class="refsect1"> 158<a name="id-1.3.49.3.8.12"></a><h2>See also</h2> 159<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="link" href="RandomAccessIterator.html" title="Concept RandomAccessIterator">RandomAccessIterator</a></p></li></ul></div> 160</div> 161</div> 162<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 163<td align="left"></td> 164<td align="right"><div class="copyright-footer">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<p>Distributed under the Boost Software License, Version 1.0. 165 (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at 166 <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 167 </p> 168<p>This product includes software developed at the University 169 of Notre Dame and the Pervasive Technology Labs at Indiana 170 University. For technical information contact Andrew Lumsdaine 171 at the Pervasive Technology Labs at Indiana University. For 172 administrative and license questions contact the Advanced 173 Research and Technology Institute at 351 West 10th Street. 174 Indianapolis, Indiana 46202, phone 317-278-4100, fax 175 317-274-5902.</p> 176<p>Some concepts based on versions from the MTL draft manual 177 and Boost Graph and Property Map documentation, the SGI Standard 178 Template Library documentation and the Hewlett-Packard STL, 179 under the following license: 180 </p> 181<div class="blockquote"><blockquote class="blockquote"><p>Permission to use, copy, modify, distribute and 182 sell this software and its documentation for any purpose is 183 hereby granted without fee, provided that the above copyright 184 notice appears in all copies and that both that copyright 185 notice and this permission notice appear in supporting 186 documentation. Silicon Graphics makes no representations 187 about the suitability of this software for any purpose. It is 188 provided "as is" without express or implied 189 warranty.</p></blockquote></div> 190</div></td> 191</tr></table> 192<hr> 193<div class="spirit-nav"> 194<a accesskey="p" href="ForwardIterator.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="concept_check.html#concepts.reference"><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="RandomAccessIterator.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 195</div> 196</body> 197</html> 198