1.. Iterators/Concepts//Random Access Iterator |30 2 3Random Access Iterator 4====================== 5 6Description 7----------- 8 9A |Random Access Iterator| is a |Bidirectional Iterator| that provides 10constant-time guarantees on moving the iterator an arbitrary number of positions 11forward or backward and for measuring the distance to another iterator in the 12same sequence. 13 14Refinement of 15------------- 16 17|Bidirectional Iterator| 18 19 20Expression requirements 21----------------------- 22 23In addition to the requirements defined in |Bidirectional Iterator|, 24the following requirements must be met. 25 26+---------------------------+-------------------------------------------+---------------------------+ 27| Expression | Type | Complexity | 28+===========================+===========================================+===========================+ 29| ``next<i>::type`` | |Random Access Iterator| | Amortized constant time | 30+---------------------------+-------------------------------------------+---------------------------+ 31| ``prior<i>::type`` | |Random Access Iterator| | Amortized constant time | 32+---------------------------+-------------------------------------------+---------------------------+ 33| ``i::category`` | |Integral Constant|, convertible | Constant time | 34| | to ``random_access_iterator_tag`` | | 35+---------------------------+-------------------------------------------+---------------------------+ 36| ``advance<i,n>::type`` | |Random Access Iterator| | Amortized constant time | 37+---------------------------+-------------------------------------------+---------------------------+ 38| ``distance<i,j>::type`` | |Integral Constant| | Amortized constant time | 39+---------------------------+-------------------------------------------+---------------------------+ 40 41 42Expression semantics 43-------------------- 44 45.. parsed-literal:: 46 47 typedef advance<i,n>::type j; 48 49:Semantics: 50 See ``advance`` specification 51 52 53.. .......................................................................... 54 55.. parsed-literal:: 56 57 typedef distance<i,j>::type n; 58 59:Semantics: 60 See ``distance`` specification 61 62 63Invariants 64---------- 65 66For any random access iterators ``i`` and ``j`` the following invariants always 67hold: 68 69* If ``advance<i,n>::type`` is well-defined, then 70 ``advance< advance<i,n>::type, negate<n>::type >::type`` is a null operation. 71 72 73See also 74-------- 75 76|Iterators|, |Bidirectional Iterator|, |Random Access Sequence|, |advance|, |distance| 77 78 79.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 80 Distributed under the Boost Software License, Version 1.0. (See accompanying 81 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 82