1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Bidirectional Range</title> 5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Chapter 1. Range 2.0"> 8<link rel="up" href="../concepts.html" title="Range Concepts"> 9<link rel="prev" href="forward_range.html" title="Forward Range"> 10<link rel="next" href="random_access_range.html" title="Random Access Range"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="forward_range.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><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="random_access_range.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="range.concepts.bidirectional_range"></a><a class="link" href="bidirectional_range.html" title="Bidirectional Range">Bidirectional Range</a> 28</h3></div></div></div> 29<h5> 30<a name="range.concepts.bidirectional_range.h0"></a> 31 <span class="phrase"><a name="range.concepts.bidirectional_range.notation"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.notation">Notation</a> 32 </h5> 33<div class="informaltable"><table class="table"> 34<colgroup> 35<col> 36<col> 37</colgroup> 38<thead><tr></tr></thead> 39<tbody> 40<tr> 41<td> 42 <p> 43 <code class="computeroutput"><span class="identifier">X</span></code> 44 </p> 45 </td> 46<td> 47 <p> 48 A type that is a model of <a class="link" href="bidirectional_range.html" title="Bidirectional Range">Bidirectional 49 Range</a>. 50 </p> 51 </td> 52</tr> 53<tr> 54<td> 55 <p> 56 <code class="computeroutput"><span class="identifier">a</span></code> 57 </p> 58 </td> 59<td> 60 <p> 61 Object of type X. 62 </p> 63 </td> 64</tr> 65</tbody> 66</table></div> 67<h5> 68<a name="range.concepts.bidirectional_range.h1"></a> 69 <span class="phrase"><a name="range.concepts.bidirectional_range.description"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.description">Description</a> 70 </h5> 71<p> 72 This concept provides access to iterators that traverse in both directions 73 (forward and reverse). The <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> iterator must meet all of the requirements 74 of <a href="../../../../../../libs/iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators" target="_top">Bidirectional 75 Traversal Iterator</a>. 76 </p> 77<h5> 78<a name="range.concepts.bidirectional_range.h2"></a> 79 <span class="phrase"><a name="range.concepts.bidirectional_range.refinement_of"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.refinement_of">Refinement 80 of</a> 81 </h5> 82<p> 83 <a class="link" href="forward_range.html" title="Forward Range">Forward Range</a> 84 </p> 85<h5> 86<a name="range.concepts.bidirectional_range.h3"></a> 87 <span class="phrase"><a name="range.concepts.bidirectional_range.associated_types"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.associated_types">Associated 88 types</a> 89 </h5> 90<div class="informaltable"><table class="table"> 91<colgroup> 92<col> 93<col> 94<col> 95</colgroup> 96<thead><tr></tr></thead> 97<tbody> 98<tr> 99<td> 100 <p> 101 Reverse Iterator type 102 </p> 103 </td> 104<td> 105 <p> 106 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> 107 </p> 108 </td> 109<td> 110 <p> 111 The type of iterator used to iterate through a Range's elements 112 in reverse order. The iterator's value type is expected to be the 113 Range's value type. A conversion from the reverse iterator type 114 to the const reverse iterator type must exist. 115 </p> 116 </td> 117</tr> 118<tr> 119<td> 120 <p> 121 Const reverse iterator type 122 </p> 123 </td> 124<td> 125 <p> 126 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> 127 </p> 128 </td> 129<td> 130 <p> 131 A type of reverse iterator that may be used to examine, but not 132 to modify, a Range's elements. 133 </p> 134 </td> 135</tr> 136</tbody> 137</table></div> 138<h5> 139<a name="range.concepts.bidirectional_range.h4"></a> 140 <span class="phrase"><a name="range.concepts.bidirectional_range.valid_expressions"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.valid_expressions">Valid expressions</a> 141 </h5> 142<div class="informaltable"><table class="table"> 143<colgroup> 144<col> 145<col> 146<col> 147<col> 148</colgroup> 149<thead><tr> 150<th> 151 <p> 152 Name 153 </p> 154 </th> 155<th> 156 <p> 157 Expression 158 </p> 159 </th> 160<th> 161 <p> 162 Return type 163 </p> 164 </th> 165<th> 166 <p> 167 Semantics 168 </p> 169 </th> 170</tr></thead> 171<tbody> 172<tr> 173<td> 174 <p> 175 Beginning of range 176 </p> 177 </td> 178<td> 179 <p> 180 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> 181 </p> 182 </td> 183<td> 184 <p> 185 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> if <code class="computeroutput"><span class="identifier">a</span></code> 186 is mutable <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="keyword">const</span> 187 <span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> otherwise. 188 </p> 189 </td> 190<td> 191 <p> 192 Equivalent to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">a</span><span class="special">))</span></code>. 193 </p> 194 </td> 195</tr> 196<tr> 197<td> 198 <p> 199 End of range 200 </p> 201 </td> 202<td> 203 <p> 204 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> 205 </p> 206 </td> 207<td> 208 <p> 209 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> if <code class="computeroutput"><span class="identifier">a</span></code> 210 is mutable, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="keyword">const</span> 211 <span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span></code> otherwise. 212 </p> 213 </td> 214<td> 215 <p> 216 Equivalent to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_reverse_iterator</span><span class="special"><</span><span class="identifier">X</span><span class="special">>::</span><span class="identifier">type</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">a</span><span class="special">))</span></code>. 217 </p> 218 </td> 219</tr> 220</tbody> 221</table></div> 222<h5> 223<a name="range.concepts.bidirectional_range.h5"></a> 224 <span class="phrase"><a name="range.concepts.bidirectional_range.complexity_guarantees"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.complexity_guarantees">Complexity 225 guarantees</a> 226 </h5> 227<p> 228 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> has 229 the same complexity as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">end</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> and 230 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> has the same complexity as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> from 231 <a class="link" href="forward_range.html" title="Forward Range">Forward Range</a>. 232 </p> 233<h5> 234<a name="range.concepts.bidirectional_range.h6"></a> 235 <span class="phrase"><a name="range.concepts.bidirectional_range.invariants"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.invariants">Invariants</a> 236 </h5> 237<div class="informaltable"><table class="table"> 238<colgroup> 239<col> 240<col> 241</colgroup> 242<thead><tr></tr></thead> 243<tbody> 244<tr> 245<td> 246 <p> 247 Valid reverse range 248 </p> 249 </td> 250<td> 251 <p> 252 For any Bidirectional Range a, <code class="computeroutput"><span class="special">[</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">a</span><span class="special">))</span></code> 253 is a valid range, that is, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> is reachable from <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> 254 in a finite number of increments. 255 </p> 256 </td> 257</tr> 258<tr> 259<td> 260 <p> 261 Completeness 262 </p> 263 </td> 264<td> 265 <p> 266 An algorithm that iterates through the range <code class="computeroutput"><span class="special">[</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rbegin</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">rend</span><span class="special">(</span><span class="identifier">a</span><span class="special">))</span></code> 267 will pass through every element of <code class="computeroutput"><span class="identifier">a</span></code>. 268 </p> 269 </td> 270</tr> 271</tbody> 272</table></div> 273<h5> 274<a name="range.concepts.bidirectional_range.h7"></a> 275 <span class="phrase"><a name="range.concepts.bidirectional_range.see_also"></a></span><a class="link" href="bidirectional_range.html#range.concepts.bidirectional_range.see_also">See 276 also</a> 277 </h5> 278<p> 279 <a class="link" href="../reference/concept_implementation/semantics/metafunctions.html" title="Metafunctions">Implementation 280 of metafunctions</a> 281 </p> 282<p> 283 <a class="link" href="../reference/concept_implementation/semantics/functions.html" title="Functions">Implementation 284 of functions</a> 285 </p> 286</div> 287<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 288<td align="left"></td> 289<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen, 290 Neil Groves<p> 291 Distributed under the Boost Software License, Version 1.0. (See accompanying 292 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 293 </p> 294</div></td> 295</tr></table> 296<hr> 297<div class="spirit-nav"> 298<a accesskey="p" href="forward_range.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><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="random_access_range.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 299</div> 300</body> 301</html> 302