X A type that is a model of Random Access Container

a, b Object of type X

T The value type of X

Valid expressions

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

Name Expression Type requirements Return type
Element access a[n] n is convertible to size_type reference if a is mutable, const_reference otherwise
Expression semantics

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

Name Expression Precondition Semantics
Element access a[n] 0 <= n < a.size() Returns the n th element from the beginning of the container.
Complexity guarantees

The run-time complexity of element access is amortized constant time.

Invariants
Element access The element returned by a[n] is the same as the one obtained by incrementing a.begin()n times and then dereferencing the resulting iterator.
Models

• vector

• deque

See also

The Iterator overview, Random Access Iterator, Sequence

Sequences

Sequence

Category: containers

Component type: concept

Description

A Sequence is a variable-sized Container whose elements are arranged in a strict linear order. It supports insertion and removal of elements.

Refinement of

Forward Container, Default Constructible

Associated types

None, except for those of Forward Container.

Notation

X A type that is a model of Sequence

a, b Object of type X

T The value type of X

t Object of type T

p, q Object of type X::iterator

n Object of a type convertible to X::size_type

Definitions

If a is a Sequence, then p is a valid iterator in a if it is a valid (nonsingular) iterator that is reachable from a.begin() .

If a is a Sequence, then [p, q) is a valid range in a if p and q are valid iterators in a and if q is reachable from p.

Valid expressions

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

Name Expression Type requirements Return type
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

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

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