Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
Front Page / Sequences / Concepts / Associative Sequence

Associative Sequence

Description

An Associative Sequence is a Forward Sequence that allows efficient retrieval of elements based on keys. Unlike associative containers in the C++ Standard Library, MPL associative sequences have no associated ordering relation. Instead, type identity is used to impose an equivalence relation on keys, and the order in which sequence elements are traversed during iteration is left unspecified.

Definitions

Expression requirements

In the following table and subsequent specifications, s is an Associative Sequence, x is a sequence element, and k and def are arbitrary types.

In addition to the requirements defined in Forward Sequence, the following must be met:

Expression Type Complexity
has_key<s,k>::type Boolean Integral Constant Amortized constant time
count<s,k>::type Integral Constant Amortized constant time
order<s,k>::type Integral Constant or void_ Amortized constant time
at<s,k>::type Any type Amortized constant time
at<s,k,def>::type Any type Amortized constant time
key_type<s,x>::type Any type Amortized constant time
value_type<s,x>::type Any type Amortized constant time

Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Forward Sequence.

Expression Semantics
has_key<s,k>::type A boolean Integral Constant c such that c::value == true if and only if there is one or more elements with the key k in s; see has_key.
count<s,k>::type The number of elements with the key k in s; see count.
order<s,k>::type A unique unsigned Integral Constant associated with the key k in the sequence s; see order.
at<s,k>::type
at<s,k,def>::type
The first element associated with the key k in the sequence s; see at.
key_type<s,x>::type The key part of the element x that would be used to identify x in s; see key_type.
value_type<s,x>::type The value part of the element x that would be used for x in s; see value_type.

Models

See also

Sequences, Extensible Associative Sequence, has_key, count, order, at, key_type, value_type