• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Random Access 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="bidirectional_range.html" title="Bidirectional Range">
10<link rel="next" href="concept_checking.html" title="Concept Checking">
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="bidirectional_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="concept_checking.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.random_access_range"></a><a class="link" href="random_access_range.html" title="Random Access Range">Random Access Range</a>
28</h3></div></div></div>
29<h5>
30<a name="range.concepts.random_access_range.h0"></a>
31        <span class="phrase"><a name="range.concepts.random_access_range.description"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.description">Description</a>
32      </h5>
33<p>
34        A range <code class="computeroutput"><span class="identifier">X</span></code> where <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code> is a model of <a href="../../../../../../libs/iterator/doc/new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators" target="_top">Random
35        Access Traversal Iterator</a>.
36      </p>
37<h5>
38<a name="range.concepts.random_access_range.h1"></a>
39        <span class="phrase"><a name="range.concepts.random_access_range.refinement_of"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.refinement_of">Refinement
40        of</a>
41      </h5>
42<p>
43        <a class="link" href="bidirectional_range.html" title="Bidirectional Range">Bidirectional Range</a>
44      </p>
45<h5>
46<a name="range.concepts.random_access_range.h2"></a>
47        <span class="phrase"><a name="range.concepts.random_access_range.valid_expressions"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.valid_expressions">Valid expressions</a>
48      </h5>
49<div class="informaltable"><table class="table">
50<colgroup>
51<col>
52<col>
53<col>
54</colgroup>
55<thead><tr>
56<th>
57                <p>
58                  Name
59                </p>
60              </th>
61<th>
62                <p>
63                  Expression
64                </p>
65              </th>
66<th>
67                <p>
68                  Return type
69                </p>
70              </th>
71</tr></thead>
72<tbody><tr>
73<td>
74                <p>
75                  Size of range
76                </p>
77              </td>
78<td>
79                <p>
80                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
81                </p>
82              </td>
83<td>
84                <p>
85                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_size</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
86                </p>
87              </td>
88</tr></tbody>
89</table></div>
90<h5>
91<a name="range.concepts.random_access_range.h3"></a>
92        <span class="phrase"><a name="range.concepts.random_access_range.expression_semantics"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.expression_semantics">Expression
93        semantics</a>
94      </h5>
95<div class="informaltable"><table class="table">
96<colgroup>
97<col>
98<col>
99<col>
100</colgroup>
101<thead><tr>
102<th>
103                <p>
104                  Expression
105                </p>
106              </th>
107<th>
108                <p>
109                  Semantics
110                </p>
111              </th>
112<th>
113                <p>
114                  Postcondition
115                </p>
116              </th>
117</tr></thead>
118<tbody><tr>
119<td>
120                <p>
121                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
122                </p>
123              </td>
124<td>
125                <p>
126                  Returns the size of the Range, that is, its number of elements.
127                  Note <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span>
128                  <span class="special">==</span> <span class="number">0u</span></code>
129                  is equivalent to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">empty</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>.
130                </p>
131              </td>
132<td>
133                <p>
134                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span>
135                  <span class="special">&gt;=</span> <span class="number">0</span></code>
136                </p>
137              </td>
138</tr></tbody>
139</table></div>
140<h5>
141<a name="range.concepts.random_access_range.h4"></a>
142        <span class="phrase"><a name="range.concepts.random_access_range.complexity_guarantees"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.complexity_guarantees">Complexity
143        guarantees</a>
144      </h5>
145<p>
146        <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code> completes in amortized constant time.
147      </p>
148<h5>
149<a name="range.concepts.random_access_range.h5"></a>
150        <span class="phrase"><a name="range.concepts.random_access_range.invariants"></a></span><a class="link" href="random_access_range.html#range.concepts.random_access_range.invariants">Invariants</a>
151      </h5>
152<div class="informaltable"><table class="table">
153<colgroup>
154<col>
155<col>
156</colgroup>
157<thead><tr></tr></thead>
158<tbody><tr>
159<td>
160                <p>
161                  Range size
162                </p>
163              </td>
164<td>
165                <p>
166                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">size</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
167                  is equal to the <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> - <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>.
168                </p>
169              </td>
170</tr></tbody>
171</table></div>
172</div>
173<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
174<td align="left"></td>
175<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
176      Neil Groves<p>
177        Distributed under the Boost Software License, Version 1.0. (See accompanying
178        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>)
179      </p>
180</div></td>
181</tr></table>
182<hr>
183<div class="spirit-nav">
184<a accesskey="p" href="bidirectional_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="concept_checking.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
185</div>
186</body>
187</html>
188