Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / concept_check / doc / html / RandomAccessIterator.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Concept RandomAccessIterator</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="Concept reference">
8 <link rel="up" href="index.html" title="Concept reference">
9 <link rel="prev" href="BidirectionalIterator.html" title="Concept BidirectionalIterator">
10 <link rel="next" href="DefaultConstructible.html" title="Concept DefaultConstructible">
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="BidirectionalIterator.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.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="DefaultConstructible.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="refentry">
26 <a name="RandomAccessIterator"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Concept RandomAccessIterator</span></h2>
29 <p>RandomAccessIterator</p>
30 </div>
31 <div class="refsect1">
32 <a name="idm45853365385488"></a><h2>Description</h2>
33 <p>A random access iterator is an iterator that can read through
34   a sequence of values.  It can move in either direction through the
35   sequence (by any amount in constant time), and can be either mutable
36   (data pointed to by it can be changed) or not mutable.</p>
37 <p>An iterator represents a position in a sequence.  Therefore,
38   the iterator can point into the sequence (returning a value when
39   dereferenced and being incrementable), or be off-the-end (and not
40   dereferenceable or incrementable).</p>
41 </div>
42 <div class="refsect1">
43 <a name="idm45853365383680"></a><h2>Refinement of</h2>
44 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
45 <li class="listitem"><p><a class="link" href="BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a></p></li>
46 <li class="listitem"><p><a class="link" href="LessThanComparable.html" title="Concept LessThanComparable">LessThanComparable</a></p></li>
47 </ul></div>
48 </div>
49 <div class="refsect1">
50 <a name="idm45853365381664"></a><h2>Associated types</h2>
51 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
52 <li class="listitem">
53 <p><span class="bold"><strong>value_type</strong></span></p>
54 <pre class="literallayout">std::iterator_traits&lt;Iter&gt;::value_type</pre>
55 <p>The value type of the iterator</p>
56 </li>
57 <li class="listitem">
58 <p><span class="bold"><strong>category</strong></span></p>
59 <pre class="literallayout">std::iterator_traits&lt;Iter&gt;::iterator_category</pre>
60 <p>The category of the iterator</p>
61 </li>
62 <li class="listitem">
63 <p><span class="bold"><strong>difference_type</strong></span></p>
64 <pre class="literallayout">std::iterator_traits&lt;Iter&gt;::difference_type</pre>
65 <p>The difference type of the iterator (measure of the number
66     of steps between two iterators)</p>
67 </li>
68 </ul></div>
69 </div>
70 <div class="refsect1">
71 <a name="idm45853365375664"></a><h2>Notation</h2>
72 <div class="variablelist"><dl class="variablelist">
73 <dt><span class="term">Iter</span></dt>
74 <dd>A type playing the role of iterator-type in the <a class="link" href="RandomAccessIterator.html" title="Concept RandomAccessIterator">RandomAccessIterator</a> concept.</dd>
75 <dt>
76 <span class="term"><code class="varname">i</code>, </span><span class="term"><code class="varname">j</code></span>
77 </dt>
78 <dd>Objects of type Iter</dd>
79 <dt><span class="term"><code class="varname">x</code></span></dt>
80 <dd>Object of type value_type</dd>
81 <dt><span class="term"><code class="varname">n</code></span></dt>
82 <dd>Object of type difference_type</dd>
83 <dt><span class="term"><code class="varname">int_off</code></span></dt>
84 <dd>Object of type int</dd>
85 </dl></div>
86 </div>
87 <div class="refsect1">
88 <a name="idm45853365369792"></a><h2>Type expressions</h2>
89 <div class="variablelist"><dl class="variablelist">
90 <dt><span class="term">Category tag</span></dt>
91 <dd><p><span class="type">category</span> must be
92                   derived from <span class="type">std::random_access_iterator_tag</span>.
93                 </p></dd>
94 </dl></div>
95 </div>
96 <div class="refsect1">
97 <a name="idm45853365367872"></a><h2>Valid expressions</h2>
98 <div class="informaltable"><table class="table">
99 <colgroup>
100 <col>
101 <col>
102 <col>
103 <col>
104 </colgroup>
105 <thead><tr>
106 <th>Name</th>
107 <th>Expression</th>
108 <th>Type</th>
109 <th>Semantics</th>
110 </tr></thead>
111 <tbody>
112 <tr>
113 <td><p>Motion</p></td>
114 <td><p>i += n</p></td>
115 <td><p><span class="type">Iter &amp;</span></p></td>
116 <td><p>Equivalent to applying <code class="computeroutput">i++</code> <code class="computeroutput">n</code> times
117     if <code class="computeroutput">n</code> is positive, applying <code class="computeroutput">i--</code>
118     <code class="computeroutput">-n</code> times if <code class="computeroutput">n</code> is negative, and to a null
119     operation if <code class="computeroutput">n</code> is zero.</p></td>
120 </tr>
121 <tr>
122 <td><p>Motion (with integer offset)</p></td>
123 <td><p>i += int_off</p></td>
124 <td><p><span class="type">Iter &amp;</span></p></td>
125 <td><p>Equivalent to applying <code class="computeroutput">i++</code> <code class="computeroutput">n</code> times
126     if <code class="computeroutput">n</code> is positive, applying <code class="computeroutput">i--</code>
127     <code class="computeroutput">-n</code> times if <code class="computeroutput">n</code> is negative, and to a null
128     operation if <code class="computeroutput">n</code> is zero.</p></td>
129 </tr>
130 <tr>
131 <td><p>Subtractive motion</p></td>
132 <td><p>i -= n</p></td>
133 <td><p><span class="type">Iter &amp;</span></p></td>
134 <td><p>Equivalent to <code class="computeroutput">i+=(-n)</code></p></td>
135 </tr>
136 <tr>
137 <td><p>Subtractive motion (with integer offset)</p></td>
138 <td><p>i -= int_off</p></td>
139 <td><p><span class="type">Iter &amp;</span></p></td>
140 <td><p>Equivalent to <code class="computeroutput">i+=(-n)</code></p></td>
141 </tr>
142 <tr>
143 <td><p>Addition</p></td>
144 <td><p>i + n</p></td>
145 <td><p><span class="type">Iter</span></p></td>
146 <td><p>Equivalent to <code class="computeroutput">{Iter j = i; j += n; return j;}</code></p></td>
147 </tr>
148 <tr>
149 <td><p>Addition with integer</p></td>
150 <td><p>i + int_off</p></td>
151 <td><p><span class="type">Iter</span></p></td>
152 <td><p>Equivalent to <code class="computeroutput">{Iter j = i; j += n; return j;}</code></p></td>
153 </tr>
154 <tr>
155 <td><p>Addition (count first)</p></td>
156 <td><p>n + i</p></td>
157 <td><p><span class="type">Iter</span></p></td>
158 <td><p>Equivalent to <code class="computeroutput">i + n</code></p></td>
159 </tr>
160 <tr>
161 <td><p>Addition with integer (count first)</p></td>
162 <td><p>int_off + i</p></td>
163 <td><p><span class="type">Iter</span></p></td>
164 <td><p>Equivalent to <code class="computeroutput">i + n</code></p></td>
165 </tr>
166 <tr>
167 <td><p>Subtraction</p></td>
168 <td><p>i - n</p></td>
169 <td><p><span class="type">Iter</span></p></td>
170 <td><p>Equivalent to <code class="computeroutput">i + (-n)</code></p></td>
171 </tr>
172 <tr>
173 <td><p>Subtraction with integer</p></td>
174 <td><p>i - int_off</p></td>
175 <td><p><span class="type">Iter</span></p></td>
176 <td><p>Equivalent to <code class="computeroutput">i + (-n)</code></p></td>
177 </tr>
178 <tr>
179 <td><p>Distance</p></td>
180 <td><p>i - j</p></td>
181 <td><p><span class="type">difference_type</span></p></td>
182 <td><p>The number of times <code class="computeroutput">i</code> must be incremented (or
183     decremented if the result is negative) to reach <code class="computeroutput">j</code>.  Not
184     defined if <code class="computeroutput">j</code> is not reachable from
185     <code class="computeroutput">i</code>.</p></td>
186 </tr>
187 <tr>
188 <td><p>Element access</p></td>
189 <td><p>i[n]</p></td>
190 <td><p><span class="type">const-if-not-mutable value_type &amp;</span></p></td>
191 <td><p>Equivalent to <code class="computeroutput">*(i + n)</code></p></td>
192 </tr>
193 <tr>
194 <td><p>Element access with integer index</p></td>
195 <td><p>i[int_off]</p></td>
196 <td><p><span class="type">const-if-not-mutable value_type &amp;</span></p></td>
197 <td><p>Equivalent to <code class="computeroutput">*(i + n)</code></p></td>
198 </tr>
199 </tbody>
200 </table></div>
201 </div>
202 <div class="refsect1">
203 <a name="idm45853365325840"></a><h2>Complexity</h2>
204 <p>
205   All iterator operations must take amortized constant time.
206   </p>
207 </div>
208 <div class="refsect1">
209 <a name="idm45853365325120"></a><h2>Models</h2>
210 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
211 <li class="listitem"><span class="simplelist"><span class="type">T *</span></span></li>
212 <li class="listitem"><span class="simplelist"><span class="type">std::vector&lt;T&gt;::iterator</span></span></li>
213 <li class="listitem"><span class="simplelist"><span class="type">std::vector&lt;T&gt;::const_iterator</span></span></li>
214 <li class="listitem"><span class="simplelist"><span class="type">std::deque&lt;T&gt;::iterator</span></span></li>
215 <li class="listitem"><span class="simplelist"><span class="type">std::deque&lt;T&gt;::const_iterator</span></span></li>
216 </ul></div>
217 </div>
218 <div class="refsect1">
219 <a name="idm45853365320112"></a><h2>See also</h2>
220 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="link" href="LessThanComparable.html" title="Concept LessThanComparable">LessThanComparable</a></p></li></ul></div>
221 </div>
222 </div>
223 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
224 <td align="left"></td>
225 <td align="right"><div class="copyright-footer">Copyright &#169; 2001, 2002 Indiana University<br>Copyright &#169; 2000, 2001 University of Notre Dame du Lac<br>Copyright &#169; 2000 Jeremy Siek, Lie-Quan Lee, Andrew Lumsdaine<br>Copyright &#169; 1996-1999 Silicon Graphics Computer Systems, Inc.<br>Copyright &#169; 1994 Hewlett-Packard Company<p>Distributed under the Boost Software License, Version 1.0.
226       (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at 
227       <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
228       </p>
229 <p>This product includes software developed at the University
230       of Notre Dame and the Pervasive Technology Labs at Indiana
231       University. For technical information contact Andrew Lumsdaine
232       at the Pervasive Technology Labs at Indiana University.  For
233       administrative and license questions contact the Advanced
234       Research and Technology Institute at 351 West 10th Street.
235       Indianapolis, Indiana 46202, phone 317-278-4100, fax
236       317-274-5902.</p>
237 <p>Some concepts based on versions from the MTL draft manual
238       and Boost Graph and Property Map documentation, the SGI Standard
239       Template Library documentation and the Hewlett-Packard STL,
240       under the following license: 
241         </p>
242 <div class="blockquote"><blockquote class="blockquote"><p>Permission to use, copy, modify, distribute and
243         sell this software and its documentation for any purpose is
244         hereby granted without fee, provided that the above copyright
245         notice appears in all copies and that both that copyright
246         notice and this permission notice appear in supporting
247         documentation.  Silicon Graphics makes no representations
248         about the suitability of this software for any purpose.  It is
249         provided "as is" without express or implied
250         warranty.</p></blockquote></div>
251 </div></td>
252 </tr></table>
253 <hr>
254 <div class="spirit-nav">
255 <a accesskey="p" href="BidirectionalIterator.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.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="DefaultConstructible.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
256 </div>
257 </body>
258 </html>