.
Const reverse iterator type X::const_reverse_iterator A Reverse Iterator adaptor whose base iterator type is the container's const iterator type. [1]
Notation

X A type that is a model of Reversible Container

a, b Object of type X

Valid expressions

In addition to the expressions defined in Forward Container, the following expressions must be valid.

Name Expression Return type
Beginning of range a.rbegin() reverse_iterator if a is mutable, const_reverse_iterator otherwise [1]
End of range a.rend() reverse_iterator if a is mutable, const_reverse_iterator otherwise [1]
Expression semantics

Semantics of an expression is defined only where it is not defined in Forward Container, or where there is additional information.

Name Expression Semantics Postcondition
Beginning of reverse range a.rbegin() Equivalent to X::reverse_iterator(a.end()). a.rbegin() is dereferenceable or past-the-end. It is past-the-end if and only if a.size() == 0.
End of reverse range a.rend() Equivalent to X::reverse_iterator(a.begin()). a.end() is past-the-end.
Complexity guarantees

The run-time complexity of rbegin() and rend() is amortized constant time.

Invariants
Valid range [a.rbegin(), a.rend()) is a valid range.
Equivalence of ranges The distance from a.begin() to a.end() is the same as the distance from a.rbegin() to a.rend() .
Models

• vector

• list

• deque

Notes

[1] A Container's iterator type and const iterator type may be the same type: a container need not provide mutable iterators. It follows from this that the reverse iterator type and the const reverse iterator type may also be the same.

See also

The Iterator overview, Bidirectional Iterator, Sequence

Random Access Container

Category: containers

Component type: concept

Description

A Random Access Container is a Reversible Container whose iterator type is a Random Access Iterator. It provides amortized constant time access to arbitrary elements.

Refinement of

Reversible Container

Associated types

No additional types beyond those defined in Reversible Container. However, the requirements for the iterator type are strengthened: it must be a Random Access Iterator.

Notation
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату
×