C++ 概念: RandomAccessIterator
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
一个
RandomAccessIterator是一个可移动的BidirectionalIterator指向任何元素在固定的时间.Original:
A
RandomAccessIterator is a BidirectionalIterator that can be moved to point to any element in constant time.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
一个标准的指针是一个类型,满足这个概念的一个例子.
Original:
A standard pointer is an example of a type that satisfies this concept.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 要求
除上述要求外,类型
ItRandomAccessIterator,实例a,b,i和rIt必须:Original:
In addition to the above requirement, for a type
It to be an RandomAccessIterator, instances a, b, i, and r of It must:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Expression | Return | Equivalent expression | Notes |
|---|---|---|---|
| r += n | It& | if(n>=0) while(n--) ++r; |
|
| i + n | It | It temp = i; return temp += n; |
|
| n + i | It | i + n | |
| r -= n | It& | return r += -n; | |
| i - n | It | It temp = i; return temp -= n; |
|
| n - i | It | i - n | |
| b - a | difference |
n |
returns n such that a+n==b
|
| i[n] | convertible to reference |
*(i + n) | |
| a < b | contextually convertible to bool | b - a > 0 | Strict total ordering relation:
|
| a > b | contextually convertible to bool | b < a | Total ordering relation opposite to a < b |
| a >= b | contextually convertible to bool | !(a < b) | |
| a <= b | contextually convertible to bool | !(a > b) |
[编辑] 表注意事项
It是实现这一概念的类型Original:Itis the type implementing this conceptThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.T是类型std::iterator_traits<It>::value_typeOriginal:Tis the type std::iterator_traits<It>::value_typeThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.reference是类型std::iterator_traits<It>::referenceOriginal:referenceis the type std::iterator_traits<It>::referenceThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.difference是类型std::iterator_traits<It>::difference_typeOriginal:differenceis the type std::iterator_traits<It>::difference_typeThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.i,a,b类型的对象It或const ItOriginal:i,a,bare objects of typeItorconst ItThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.r是一个值类型It&Original:ris a value of typeIt&The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.n是的整数类型differenceOriginal:nis an integer of typedifferenceThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
上述规则意味着RandomAccessIterator的实现
LessThanComparable.Original:
The above rules imply that RandomAccessIterator also implements
LessThanComparable.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
一个
mutable RandomAccessiterator是一个BidirectionalIterator,另外满足OutputIterator要求的.Original:
A
mutable RandomAccessiterator is a BidirectionalIterator that additionally satisfies the OutputIterator requirements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.