stlab.adobe.com Adobe Systems Incorporated

RandomAccessContainer

containers.gif
concept.gif
Category: containers Component type: concept

Description

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

Refinement of

ReversibleContainer

Associated types

No additional types beyond those defined in ReversibleContainer. However, the requirements for the iterator type are strengthened: it must be a RandomAccessIterator.

Notation

X A type that is a model of Random Access Container
a, b Object of type X
T The value type of X

Definitions

Valid expressions

In addition to the expressions defined in ReversibleContainer, 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 ReversibleContainer, or where there is additional information.

Name Expression Precondition Semantics Postcondition
Element access a[n] 0 <= n < a.size() Returns the nth 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

Notes

See also

The Iterators, RandomAccessIterator, Sequence

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google