| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Concept RandomAccessIterator</title><link rel="stylesheet" href="reference.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.61.3"><link rel="home" href="index.html" title="The Boost C++ Libraries"><link rel="up" href="index.html#concepts.reference" title="Concept reference"><link rel="previous" href="BidirectionalIterator.html" title="Concept BidirectionalIterator"><link rel="next" href="DefaultConstructible.html" title="Concept DefaultConstructible"><link rel="chapter" href="libraries.html" title="The Boost C++ Libraries"><link rel="chapter" href="any.html" title="Boost.Any"><link rel="refentry" href="class.boost.bad_any_cast.html" title="Class bad_any_cast"><link rel="refentry" href="class.boost.any.html" title="Class any"><link rel="refentry" href="id2383300-bb.html" title="Function any_cast"><link rel="chapter" href="array.html" title="Boost.Array"><link rel="refentry" href="class.boost.array.html" title="Class template array"><link rel="chapter" href="function.html" title="Boost.Function"><link rel="refentry" href="class.boost.bad_function_call.html" title="Class bad_function_call"><link rel="refentry" href="class.boost.function_base.html" title="Class function_base"><link rel="refentry" href="class.boost.functionN.html" title="Class template functionN"><link rel="refentry" href="class.boost.function.html" title="Class template function"><link rel="chapter" href="ref.html" title="Boost.Ref"><link rel="refentry" href="class.boost.reference_wrapper.html" title="Class template reference_wrapper"><link rel="refentry" href="class.boost.is_reference_wrapper.html" title="Class template is_reference_wrapper"><link rel="refentry" href="class.boost.unwrap_reference.html" title="Class template unwrap_reference"><link rel="chapter" href="signals.html" title="Boost.Signals"><link rel="refentry" href="class.boost.signalN.html" title="Class template signalN"><link rel="refentry" href="class.boost.signal.html" title="Class template signal"><link rel="refentry" href="class.boost.slot.html" title="Class template slot"><link rel="refentry" href="class.boost.signals.trackable.html" title="Class trackable"><link rel="refentry" href="class.boost.signals.connection.html" title="Class connection"><link rel="refentry" href="class.boost.signals.scoped_connection.html" title="Class scoped_connection"><link rel="refentry" href="id2532119-bb.html" title="Function template visit_each"><link rel="refentry" href="class.boost.last_value.html" title="Class template last_value"><link rel="refentry" href="id2354683-bb.html" title="Class last_value<void>"><link rel="chapter" href="variant.html" title="Boost.Variant"><link rel="refentry" href="BOOST_VARIANT_LIMIT_TYPES.html" title="Macro BOOST_VARIANT_LIMIT_TYPES"><link rel="refentry" href="BOOST_VARIANT_ENUM_PARAMS.html" title="Macro BOOST_VARIANT_ENUM_PARAMS"><link rel="refentry" href="BOOST_VARIANT_ENUM_SHIFTED_PARAMS.html" title="Macro BOOST_VARIANT_ENUM_SHIFTED_PARAMS"><link rel="refentry" href="BOOST_VARIANT_NO_REFERENCE_SUPPORT.html" title="Macro BOOST_VARIANT_NO_REFERENCE_SUPPORT"><link rel="refentry" href="BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT.html" title="Macro BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT"><link rel="refentry" href="BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT.html" title="Macro BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT"><link rel="refentry" href="class.boost.variant.html" title="Class template variant"><link rel="refentry" href="id2518553-bb.html" title="Function template swap"><link rel="refentry" href="id2524211-bb.html" title="Function template operator<<"><link rel="refentry" href="class.boost.make_variant_over.html" title="Class template make_variant_over"><link rel="refentry" href="class.boost.make_recursive_variant.html" title="Class template make_recursive_variant"><link rel="refentry" href="class.boost.make_recursive_variant_over.html" title="Class template make_recursive_variant_over"><link rel="refentry" href="class.boost.recursive_wrapper.html" title="Class template recursive_wrapper"><link rel="refentry" href="class.boost.is_recursive_wrapper.html" title="Class template is_recursive_wrapper"><link rel="refentry" href="class.boost.unwrap_recursive_wrapper.html" title="Class template unwrap_recursive_wrapper"><link rel="refentry" href="class.boost.apply_visitor_delayed_t.html" title="Class template apply_visitor_delayed_t"><link rel="refentry" href="id2557051-bb.html" title="Function apply_visitor"><link rel="refentry" href="class.boost.bad_get.html" title="Class bad_get"><link rel="refentry" href="id2493238-bb.html" title="Function get"><link rel="refentry" href="class.boost.bad_visit.html" title="Class bad_visit"><link rel="refentry" href="class.boost.static_visitor.html" title="Class template static_visitor"><link rel="refentry" href="class.boost.visitor_ptr_t.html" title="Class template visitor_ptr_t"><link rel="refentry" href="id2544445-bb.html" title="Function template visitor_ptr"><link rel="chapter" href="boostbook.html" title="The BoostBook Documentation Format"><link rel="refentry" href="boostbook.dtd.class-specialization.html" title="
- BoostBook element class-specialization"><link rel="refentry" href="boostbook.dtd.link-test.html" title="
- BoostBook element link-test"><link rel="refentry" href="boostbook.dtd.link-fail-test.html" title="
- BoostBook element link-fail-test"><link rel="refentry" href="boostbook.dtd.typedef.html" title="
- BoostBook element typedef"><link rel="refentry" href="boostbook.dtd.static-constant.html" title="
- BoostBook element static-constant"><link rel="refentry" href="boostbook.dtd.code.html" title="
- BoostBook element code"><link rel="refentry" href="boostbook.dtd.destructor.html" title="
- BoostBook element destructor"><link rel="refentry" href="boostbook.dtd.template-type-parameter.html" title="
- BoostBook element template-type-parameter"><link rel="refentry" href="boostbook.dtd.description.html" title="
- BoostBook element description"><link rel="refentry" href="boostbook.dtd.librarylist.html" title="
- BoostBook element librarylist"><link rel="refentry" href="boostbook.dtd.library-reference.html" title="
- BoostBook element library-reference"><link rel="refentry" href="boostbook.dtd.boostbook.html" title="
- BoostBook element boostbook"><link rel="refentry" href="boostbook.dtd.union.html" title="
- BoostBook element union"><link rel="refentry" href="boostbook.dtd.inherit.html" title="
- BoostBook element inherit"><link rel="refentry" href="boostbook.dtd.template-varargs.html" title="
- BoostBook element template-varargs"><link rel="refentry" href="boostbook.dtd.source.html" title="
- BoostBook element source"><link rel="refentry" href="boostbook.dtd.function.html" title="
- BoostBook element function"><link rel="refentry" href="boostbook.dtd.postconditions.html" title="
- BoostBook element postconditions"><link rel="refentry" href="boostbook.dtd.compile-test.html" title="
- BoostBook element compile-test"><link rel="refentry" href="boostbook.dtd.method.html" title="
- BoostBook element method"><link rel="refentry" href="boostbook.dtd.snippet.html" title="
- BoostBook element snippet"><link rel="refentry" href="boostbook.dtd.constructor.html" title="
- BoostBook element constructor"><link rel="refentry" href="boostbook.dtd.namespace.html" title="
- BoostBook element namespace"><link rel="refentry" href="boostbook.dtd.if-fails.html" title="
- BoostBook element if-fails"><link rel="refentry" href="boostbook.dtd.free-function-group.html" title="
- BoostBook element free-function-group"><link rel="refentry" href="boostbook.dtd.functionname.html" title="
- BoostBook element functionname"><link rel="refentry" href="boostbook.dtd.librarycategory.html" title="
- BoostBook element librarycategory"><link rel="refentry" href="boostbook.dtd.notes.html" title="
- BoostBook element notes"><link rel="refentry" href="boostbook.dtd.data-member.html" title="
- BoostBook element data-member"><link rel="refentry" href="boostbook.dtd.specialization.html" title="
- BoostBook element specialization"><link rel="refentry" href="boostbook.dtd.union-specialization.html" title="
- BoostBook element union-specialization"><link rel="refentry" href="boostbook.dtd.throws.html" title="
- BoostBook element throws"><link rel="refentry" href="boostbook.dtd.template-arg.html" title="
- BoostBook element template-arg"><link rel="refentry" href="boostbook.dtd.method-group.html" title="
- BoostBook element method-group"><link rel="refentry" href="boostbook.dtd.requirement.html" title="
- BoostBook element requirement"><link rel="refentry" href="boostbook.dtd.precondition.html" title="
- BoostBook element precondition"><link rel="refentry" href="boostbook.dtd.paramtype.html" title="
- BoostBook element paramtype"><link rel="refentry" href="boostbook.dtd.using-class.html" title="
- BoostBook element using-class"><link rel="refentry" href="boostbook.dtd.run-test.html" title="
- BoostBook element run-test"><link rel="refentry" href="boostbook.dtd.librarypurpose.html" title="
- BoostBook element librarypurpose"><link rel="refentry" href="boostbook.dtd.copy-assignment.html" title="
- BoostBook element copy-assignment"><link rel="refentry" href="boostbook.dtd.run-fail-test.html" title="
- BoostBook element run-fail-test"><link rel="refentry" href="boostbook.dtd.template.html" title="
- BoostBook element template"><link rel="refentry" href="boostbook.dtd.compile-fail-test.html" title="
- BoostBook element compile-fail-test"><link rel="refentry" href="boostbook.dtd.returns.html" title="
- BoostBook element returns"><link rel="refentry" href="boostbook.dtd.default.html" title="
- BoostBook element default"><link rel="refentry" href="boostbook.dtd.parameter.html" title="
- BoostBook element parameter"><link rel="refentry" href="boostbook.dtd.signature.html" title="
- BoostBook element signature"><link rel="refentry" href="boostbook.dtd.overloaded-function.html" title="
- BoostBook element overloaded-function"><link rel="refentry" href="boostbook.dtd.class.html" title="
- BoostBook element class"><link rel="refentry" href="boostbook.dtd.librarycategorydef.html" title="
- BoostBook element librarycategorydef"><link rel="refentry" href="boostbook.dtd.type.html" title="
- BoostBook element type"><link rel="refentry" href="boostbook.dtd.enumvalue.html" title="
- BoostBook element enumvalue"><link rel="refentry" href="boostbook.dtd.overloaded-method.html" title="
- BoostBook element overloaded-method"><link rel="refentry" href="boostbook.dtd.programlisting.html" title="
- BoostBook element programlisting"><link rel="refentry" href="boostbook.dtd.complexity.html" title="
- BoostBook element complexity"><link rel="refentry" href="boostbook.dtd.purpose.html" title="
- BoostBook element purpose"><link rel="refentry" href="boostbook.dtd.template-nontype-parameter.html" title="
- BoostBook element template-nontype-parameter"><link rel="refentry" href="boostbook.dtd.library.html" title="
- BoostBook element library"><link rel="refentry" href="boostbook.dtd.librarycategorylist.html" title="
- BoostBook element librarycategorylist"><link rel="refentry" href="boostbook.dtd.using-namespace.html" title="
- BoostBook element using-namespace"><link rel="refentry" href="boostbook.dtd.struct-specialization.html" title="
- BoostBook element struct-specialization"><link rel="refentry" href="boostbook.dtd.struct.html" title="
- BoostBook element struct"><link rel="refentry" href="boostbook.dtd.lib.html" title="
- BoostBook element lib"><link rel="refentry" href="boostbook.dtd.enum.html" title="
- BoostBook element enum"><link rel="refentry" href="boostbook.dtd.requires.html" title="
- BoostBook element requires"><link rel="refentry" href="boostbook.dtd.effects.html" title="
- BoostBook element effects"><link rel="refentry" href="boostbook.dtd.libraryname.html" title="
- BoostBook element libraryname"><link rel="refentry" href="boostbook.dtd.libraryinfo.html" title="
- BoostBook element libraryinfo"><link rel="refentry" href="boostbook.dtd.testsuite.html" title="
- BoostBook element testsuite"><link rel="refentry" href="boostbook.dtd.header.html" title="
- BoostBook element header"><link rel="refentry" href="boostbook.dtd.rationale.html" title="
- BoostBook element rationale"><link rel="refentry" href="Assignable.html" title="Concept Assignable"><link rel="refentry" href="InputIterator.html" title="Concept InputIterator"><link rel="refentry" href="OutputIterator.html" title="Concept OutputIterator"><link rel="refentry" href="ForwardIterator.html" title="Concept ForwardIterator"><link rel="refentry" href="BidirectionalIterator.html" title="Concept BidirectionalIterator"><link rel="refentry" href="RandomAccessIterator.html" title="Concept RandomAccessIterator"><link rel="refentry" href="DefaultConstructible.html" title="Concept DefaultConstructible"><link rel="refentry" href="CopyConstructible.html" title="Concept CopyConstructible"><link rel="refentry" href="EqualityComparable.html" title="Concept EqualityComparable"><link rel="refentry" href="LessThanComparable.html" title="Concept LessThanComparable"><link rel="refentry" href="SignedInteger.html" title="Concept SignedInteger"><link rel="section" href="RandomAccessIterator.html#id2553113" title="Description"><link rel="section" href="RandomAccessIterator.html#id2553129" title="Refinement of"><link rel="section" href="RandomAccessIterator.html#id2553151" title="Associated types"><link rel="section" href="RandomAccessIterator.html#id2553210" title="Notation"><link rel="section" href="RandomAccessIterator.html#id2553265" title="Type expressions"><link rel="section" href="RandomAccessIterator.html#id2553283" title="Valid expressions"><link rel="section" href="RandomAccessIterator.html#id2553665" title="Complexity"><link rel="section" href="RandomAccessIterator.html#id2553672" title="Models"><link rel="section" href="RandomAccessIterator.html#id2553718" title="See also"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" border="1" cellpadding="2" bgcolor="#007F7F"><tr><td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td><td><a href="../../index.htm"><font color="#FFFFFF" size="4" face="Arial">Home</font></a></td><td><a href="libraries.html"><font color="#FFFFFF" size="4" face="Arial">Libraries</font></a></td><td><a href="../../people/people.htm"><font color="#FFFFFF" size="4" face="Arial">People</font></a></td><td><a href="../../more/faq.htm"><font color="#FFFFFF" size="4" face="Arial">FAQ</font></a></td><td><a href="../../more/index.htm"><font color="#FFFFFF" size="4" face="Arial">More</font></a></td></tr></table><div class="refentry" lang="en"><a name="RandomAccessIterator"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Concept RandomAccessIterator</span></h2><p>RandomAccessIterator</p></div><div class="refsect1" lang="en"><h2>Description</h2><p>A random access iterator is an iterator that can read through
- a sequence of values. It can move in either direction through the
- sequence (by any amount in constant time), and can be either mutable
- (data pointed to by it can be changed) or not mutable.</p><p>An iterator represents a position in a sequence. Therefore,
- the iterator can point into the sequence (returning a value when
- dereferenced and being incrementable), or be off-the-end (and not
- dereferenceable or incrementable).</p></div><div class="refsect1" lang="en"><h2>Refinement of</h2><div class="itemizedlist"><ul type="disc"><li><p><a href="BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a></p></li><li><p><a href="LessThanComparable.html" title="Concept LessThanComparable">LessThanComparable</a></p></li></ul></div></div><div class="refsect1" lang="en"><h2>Associated types</h2><div class="itemizedlist"><ul type="disc"><li><p><span class="bold"><b>value_type</b></span></p><pre class="literallayout">std::iterator_traits<Iter>::value_type</pre><p>The value type of the iterator</p></li><li><p><span class="bold"><b>category</b></span></p><pre class="literallayout">std::iterator_traits<Iter>::iterator_category</pre><p>The category of the iterator</p></li><li><p><span class="bold"><b>difference_type</b></span></p><pre class="literallayout">std::iterator_traits<Iter>::difference_type</pre><p>The difference type of the iterator (measure of the number
- of steps between two iterators)</p></li></ul></div></div><div class="refsect1" lang="en"><h2>Notation</h2><div class="variablelist"><dl><dt><span class="term">Iter</span></dt><dd>A type playing the role of iterator-type in the <a href="RandomAccessIterator.html" title="Concept RandomAccessIterator">RandomAccessIterator</a> concept.</dd><dt><span class="term"><tt class="varname">i</tt>, </span><span class="term"><tt class="varname">j</tt></span></dt><dd>Objects of type Iter</dd><dt><span class="term"><tt class="varname">x</tt></span></dt><dd>Object of type value_type</dd><dt><span class="term"><tt class="varname">n</tt></span></dt><dd>Object of type difference_type</dd><dt><span class="term"><tt class="varname">int_off</tt></span></dt><dd>Object of type int</dd></dl></div></div><div class="refsect1" lang="en"><h2>Type expressions</h2><div class="variablelist"><dl><dt><span class="term">Category tag</span></dt><dd><p><span class="type">category</span> must be
- derived from <span class="type">std::random_access_iterator_tag</span>.
- </p></dd></dl></div></div><div class="refsect1" lang="en"><h2>Valid expressions</h2><div class="informaltable"><table border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Name</th><th>Expression</th><th>Type</th><th>Semantics</th></tr></thead><tbody><tr><td><p>Motion</p></td><td><p>i += n</p></td><td><p><span class="type">Iter &</span></p></td><td><p>Equivalent to applying <tt class="computeroutput">i++</tt><tt class="computeroutput">n</tt> times
- if <tt class="computeroutput">n</tt> is positive, applying <tt class="computeroutput">i--</tt><tt class="computeroutput">-n</tt> times if <tt class="computeroutput">n</tt> is negative, and to a null
- operation if <tt class="computeroutput">n</tt> is zero.</p></td></tr><tr><td><p>Motion (with integer offset)</p></td><td><p>i += int_off</p></td><td><p><span class="type">Iter &</span></p></td><td><p>Equivalent to applying <tt class="computeroutput">i++</tt><tt class="computeroutput">n</tt> times
- if <tt class="computeroutput">n</tt> is positive, applying <tt class="computeroutput">i--</tt><tt class="computeroutput">-n</tt> times if <tt class="computeroutput">n</tt> is negative, and to a null
- operation if <tt class="computeroutput">n</tt> is zero.</p></td></tr><tr><td><p>Subtractive motion</p></td><td><p>i -= n</p></td><td><p><span class="type">Iter &</span></p></td><td><p>Equivalent to <tt class="computeroutput">i+=(-n)</tt></p></td></tr><tr><td><p>Subtractive motion (with integer offset)</p></td><td><p>i -= int_off</p></td><td><p><span class="type">Iter &</span></p></td><td><p>Equivalent to <tt class="computeroutput">i+=(-n)</tt></p></td></tr><tr><td><p>Addition</p></td><td><p>i + n</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">{Iter j = i; j += n; return j;}</tt></p></td></tr><tr><td><p>Addition with integer</p></td><td><p>i + int_off</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">{Iter j = i; j += n; return j;}</tt></p></td></tr><tr><td><p>Addition (count first)</p></td><td><p>n + i</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">i + n</tt></p></td></tr><tr><td><p>Addition with integer (count first)</p></td><td><p>int_off + i</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">i + n</tt></p></td></tr><tr><td><p>Subtraction</p></td><td><p>i - n</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">i + (-n)</tt></p></td></tr><tr><td><p>Subtraction with integer</p></td><td><p>i - int_off</p></td><td><p><span class="type">Iter</span></p></td><td><p>Equivalent to <tt class="computeroutput">i + (-n)</tt></p></td></tr><tr><td><p>Distance</p></td><td><p>i - j</p></td><td><p><span class="type">difference_type</span></p></td><td><p>The number of times <tt class="computeroutput">i</tt> must be incremented (or
- decremented if the result is negative) to reach <tt class="computeroutput">j</tt>. Not
- defined if <tt class="computeroutput">j</tt> is not reachable from
- <tt class="computeroutput">i</tt>.</p></td></tr><tr><td><p>Element access</p></td><td><p>i[n]</p></td><td><p><span class="type">const-if-not-mutable value_type &</span></p></td><td><p>Equivalent to <tt class="computeroutput">*(i + n)</tt></p></td></tr><tr><td><p>Element access with integer index</p></td><td><p>i[int_off]</p></td><td><p><span class="type">const-if-not-mutable value_type &</span></p></td><td><p>Equivalent to <tt class="computeroutput">*(i + n)</tt></p></td></tr></tbody></table></div></div><div class="refsect1" lang="en"><h2>Complexity</h2><p>
- All iterator operations must take amortized constant time.
- </p></div><div class="refsect1" lang="en"><h2>Models</h2><div class="itemizedlist"><ul type="disc"><li><span class="simplelist"><span class="type">T *</span></span></li><li><span class="simplelist"><span class="type">std::vector<T>::iterator</span></span></li><li><span class="simplelist"><span class="type">std::vector<T>::const_iterator</span></span></li><li><span class="simplelist"><span class="type">std::deque<T>::iterator</span></span></li><li><span class="simplelist"><span class="type">std::deque<T>::const_iterator</span></span></li></ul></div></div><div class="refsect1" lang="en"><h2>See also</h2><div class="itemizedlist"><ul type="disc"><li><p><a href="LessThanComparable.html" title="Concept LessThanComparable">LessThanComparable</a></p></li></ul></div></div></div><table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr><td align="left"><small>Last revised: , at GMT</small></td><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></tr></table><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="BidirectionalIterator.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="index.html#concepts.reference"><img src="images/up.png" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="DefaultConstructible.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">Concept BidirectionalIterator </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> Concept DefaultConstructible</td></tr></table></div></body></html>
|