Front Page / Sequences / Concepts / Associative Sequence |
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.
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 |
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. |