| Home | Libraries | People | FAQ | More

#### Associative Sequence

###### Description

An Associative Sequence allows efficient retrieval of elements based on keys. Like associative sequences in MPL, and unlike associative containers in STL, Fusion associative sequences have no implied 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 addition, unlike STL, Associative Sequences have mutable iterators. This is due to the fact that there is no associated ordering relation and the runtime value of the keys themselves do not have any effect on the associativity of the sequence.

Notation

`s`

  An Associative Sequence

`S`

  An Associative Sequence type

`K`

  An arbitrary key type

`o`

  An arbitrary object

`e`

  A Sequence element

###### Valid Expressions

For any Associative Sequence the following expressions must be valid:

Expression | Return type | Type Requirements | Runtime Complexity
--- | --- | --- | ---
``has_key`<K>(s)` | MPL Boolean Constant. Convertible to bool. |  | Constant
``at_key`<K>(s)` | Any type |  | Constant
``at_key`<K>(s) = o` | Any type | `s` is mutable and `e = o`, where `e` is the first element in the sequence, is a valid expression. | Constant

###### Result Type Expressions

Expression | Compile Time Complexity
--- | ---
``result_of::has_key`<S, K>::type` | Amortized constant time
``result_of::at_key`<S, K>::type` | Amortized constant time
``result_of::value_at_key`<S, K>::type` | Amortized constant time

###### Expression Semantics

Expression | Semantics
--- | ---
``has_key`<K>(s)` | 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`.
``at_key`<K>(s)` | The element associated with the key `K` in the sequence `s`; see `at`.

###### Models

- `set`
- `map`