• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Associative Sequence</title>
5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../index.html" title="Chapter 1. Fusion 2.2">
8<link rel="up" href="../concepts.html" title="Concepts">
9<link rel="prev" href="random_access_sequence.html" title="Random Access Sequence">
10<link rel="next" href="unbounded_sequence.html" title="Unbounded Sequence">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="random_access_sequence.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unbounded_sequence.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="fusion.sequence.concepts.associative_sequence"></a><a class="link" href="associative_sequence.html" title="Associative Sequence">Associative
28        Sequence</a>
29</h4></div></div></div>
30<h6>
31<a name="fusion.sequence.concepts.associative_sequence.h0"></a>
32          <span class="phrase"><a name="fusion.sequence.concepts.associative_sequence.description"></a></span><a class="link" href="associative_sequence.html#fusion.sequence.concepts.associative_sequence.description">Description</a>
33        </h6>
34<p>
35          An Associative Sequence allows efficient retrieval of elements based on
36          keys. Like associative sequences in <a href="http://www.boost.org/libs/mpl" target="_top">MPL</a>,
37          and unlike associative containers in <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" target="_top">STL</a>,
38          Fusion associative sequences have no implied ordering relation. Instead,
39          type identity is used to impose an equivalence relation on keys. Keys are
40          not checked for uniqueness.
41        </p>
42<div class="variablelist">
43<p class="title"><b>Notation</b></p>
44<dl class="variablelist">
45<dt><span class="term"><code class="computeroutput"><span class="identifier">s</span></code></span></dt>
46<dd><p>
47                An Associative Sequence
48              </p></dd>
49<dt><span class="term"><code class="computeroutput"><span class="identifier">S</span></code></span></dt>
50<dd><p>
51                An Associative Sequence type
52              </p></dd>
53<dt><span class="term"><code class="computeroutput"><span class="identifier">K</span></code></span></dt>
54<dd><p>
55                An arbitrary <span class="emphasis"><em>key</em></span> type
56              </p></dd>
57<dt><span class="term"><code class="computeroutput"><span class="identifier">o</span></code></span></dt>
58<dd><p>
59                An arbitrary object
60              </p></dd>
61<dt><span class="term"><code class="computeroutput"><span class="identifier">e</span></code></span></dt>
62<dd><p>
63                A Sequence element
64              </p></dd>
65</dl>
66</div>
67<h6>
68<a name="fusion.sequence.concepts.associative_sequence.h1"></a>
69          <span class="phrase"><a name="fusion.sequence.concepts.associative_sequence.valid_expressions"></a></span><a class="link" href="associative_sequence.html#fusion.sequence.concepts.associative_sequence.valid_expressions">Valid
70          Expressions</a>
71        </h6>
72<p>
73          For any Associative Sequence the following expressions must be valid:
74        </p>
75<div class="informaltable"><table class="table">
76<colgroup>
77<col>
78<col>
79<col>
80<col>
81</colgroup>
82<thead><tr>
83<th>
84                  <p>
85                    Expression
86                  </p>
87                </th>
88<th>
89                  <p>
90                    Return type
91                  </p>
92                </th>
93<th>
94                  <p>
95                    Type Requirements
96                  </p>
97                </th>
98<th>
99                  <p>
100                    Runtime Complexity
101                  </p>
102                </th>
103</tr></thead>
104<tbody>
105<tr>
106<td>
107                  <p>
108                    <code class="computeroutput"><a class="link" href="../intrinsic/functions/has_key.html" title="has_key"><code class="computeroutput"><span class="identifier">has_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span></code>
109                  </p>
110                </td>
111<td>
112                  <p>
113                    <a href="http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html" target="_top">MPL
114                    Boolean Constant</a>. Convertible to bool.
115                  </p>
116                </td>
117<td>
118                </td>
119<td>
120                  <p>
121                    Constant
122                  </p>
123                </td>
124</tr>
125<tr>
126<td>
127                  <p>
128                    <code class="computeroutput"><a class="link" href="../intrinsic/functions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span></code>
129                  </p>
130                </td>
131<td>
132                  <p>
133                    Any type
134                  </p>
135                </td>
136<td>
137                </td>
138<td>
139                  <p>
140                    Constant
141                  </p>
142                </td>
143</tr>
144<tr>
145<td>
146                  <p>
147                    <code class="computeroutput"><a class="link" href="../intrinsic/functions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span>
148                    <span class="special">=</span> <span class="identifier">o</span></code>
149                  </p>
150                </td>
151<td>
152                  <p>
153                    Any type
154                  </p>
155                </td>
156<td>
157                  <p>
158                    <code class="computeroutput"><span class="identifier">s</span></code> is mutable
159                    and <code class="computeroutput"><span class="identifier">e</span> <span class="special">=</span>
160                    <span class="identifier">o</span></code>, where <code class="computeroutput"><span class="identifier">e</span></code> is the first element in the
161                    sequence, is a valid expression.
162                  </p>
163                </td>
164<td>
165                  <p>
166                    Constant
167                  </p>
168                </td>
169</tr>
170</tbody>
171</table></div>
172<h6>
173<a name="fusion.sequence.concepts.associative_sequence.h2"></a>
174          <span class="phrase"><a name="fusion.sequence.concepts.associative_sequence.result_type_expressions"></a></span><a class="link" href="associative_sequence.html#fusion.sequence.concepts.associative_sequence.result_type_expressions">Result
175          Type Expressions</a>
176        </h6>
177<div class="informaltable"><table class="table">
178<colgroup>
179<col>
180<col>
181</colgroup>
182<thead><tr>
183<th>
184                  <p>
185                    Expression
186                  </p>
187                </th>
188<th>
189                  <p>
190                    Compile Time Complexity
191                  </p>
192                </th>
193</tr></thead>
194<tbody>
195<tr>
196<td>
197                  <p>
198                    <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/has_key.html" title="has_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">has_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span>
199                    <span class="identifier">K</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
200                  </p>
201                </td>
202<td>
203                  <p>
204                    Amortized constant time
205                  </p>
206                </td>
207</tr>
208<tr>
209<td>
210                  <p>
211                    <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span>
212                    <span class="identifier">K</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
213                  </p>
214                </td>
215<td>
216                  <p>
217                    Amortized constant time
218                  </p>
219                </td>
220</tr>
221<tr>
222<td>
223                  <p>
224                    <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/value_at_key.html" title="value_at_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">value_at_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span> <span class="identifier">K</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
225                  </p>
226                </td>
227<td>
228                  <p>
229                    Amortized constant time
230                  </p>
231                </td>
232</tr>
233</tbody>
234</table></div>
235<div class="note"><table border="0" summary="Note">
236<tr>
237<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
238<th align="left">Note</th>
239</tr>
240<tr><td align="left" valign="top"><p>
241            <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span> <span class="identifier">K</span><span class="special">&gt;</span></code>
242            returns the actual type returned by <code class="computeroutput"><a class="link" href="../intrinsic/functions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span></code>.
243            In most cases, this is a reference. Hence, there is no way to know the
244            exact element type using <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span> <span class="identifier">K</span><span class="special">&gt;</span></code>.The
245            element at <code class="computeroutput"><span class="identifier">K</span></code> may actually
246            be a reference to begin with. For this purpose, you can use <code class="computeroutput"><a class="link" href="../intrinsic/metafunctions/value_at_key.html" title="value_at_key"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">value_at_key</span></code></a><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span> <span class="identifier">K</span><span class="special">&gt;</span></code>.
247          </p></td></tr>
248</table></div>
249<h6>
250<a name="fusion.sequence.concepts.associative_sequence.h3"></a>
251          <span class="phrase"><a name="fusion.sequence.concepts.associative_sequence.expression_semantics"></a></span><a class="link" href="associative_sequence.html#fusion.sequence.concepts.associative_sequence.expression_semantics">Expression
252          Semantics</a>
253        </h6>
254<div class="informaltable"><table class="table">
255<colgroup>
256<col>
257<col>
258</colgroup>
259<thead><tr>
260<th>
261                  <p>
262                    Expression
263                  </p>
264                </th>
265<th>
266                  <p>
267                    Semantics
268                  </p>
269                </th>
270</tr></thead>
271<tbody>
272<tr>
273<td>
274                  <p>
275                    <code class="computeroutput"><a class="link" href="../intrinsic/functions/has_key.html" title="has_key"><code class="computeroutput"><span class="identifier">has_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span></code>
276                  </p>
277                </td>
278<td>
279                  <p>
280                    A boolean Integral Constant <code class="computeroutput"><span class="identifier">c</span></code>
281                    such that <code class="computeroutput"><span class="identifier">c</span><span class="special">::</span><span class="identifier">value</span> <span class="special">==</span>
282                    <span class="keyword">true</span></code> if and only if there
283                    is one or more elements with the key <code class="computeroutput"><span class="identifier">k</span></code>
284                    in <code class="computeroutput"><span class="identifier">s</span></code>; see <a class="link" href="../intrinsic/functions/has_key.html" title="has_key"><code class="computeroutput"><span class="identifier">has_key</span></code></a>.
285                  </p>
286                </td>
287</tr>
288<tr>
289<td>
290                  <p>
291                    <code class="computeroutput"><a class="link" href="../intrinsic/functions/at_key.html" title="at_key"><code class="computeroutput"><span class="identifier">at_key</span></code></a><span class="special">&lt;</span><span class="identifier">K</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">)</span></code>
292                  </p>
293                </td>
294<td>
295                  <p>
296                    The element associated with the key <code class="computeroutput"><span class="identifier">K</span></code>
297                    in the sequence <code class="computeroutput"><span class="identifier">s</span></code>;
298                    see <a class="link" href="../intrinsic/functions/at.html" title="at"><code class="computeroutput"><span class="identifier">at</span></code></a>.
299                  </p>
300                </td>
301</tr>
302</tbody>
303</table></div>
304<h6>
305<a name="fusion.sequence.concepts.associative_sequence.h4"></a>
306          <span class="phrase"><a name="fusion.sequence.concepts.associative_sequence.models"></a></span><a class="link" href="associative_sequence.html#fusion.sequence.concepts.associative_sequence.models">Models</a>
307        </h6>
308<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
309<li class="listitem">
310              <a class="link" href="../../container/set.html" title="set"><code class="computeroutput"><span class="identifier">set</span></code></a>
311            </li>
312<li class="listitem">
313              <a class="link" href="../../container/map.html" title="map"><code class="computeroutput"><span class="identifier">map</span></code></a>
314            </li>
315<li class="listitem">
316              <a class="link" href="../../view/filter_view.html" title="filter_view"><code class="computeroutput"><span class="identifier">filter_view</span></code></a>
317              (where adapted sequence is an <a class="link" href="associative_sequence.html" title="Associative Sequence">Associative
318              Sequence</a> and a <a class="link" href="forward_sequence.html" title="Forward Sequence">Forward
319              Sequence</a>)
320            </li>
321<li class="listitem">
322              <a class="link" href="../../view/iterator_range.html" title="iterator_range"><code class="computeroutput"><span class="identifier">iterator_range</span></code></a>
323              (where adapted iterators are <a class="link" href="../../iterator/concepts/associative_iterator.html" title="Associative Iterator">Associative
324              Iterator</a>s)
325            </li>
326<li class="listitem">
327              <a class="link" href="../../view/joint_view.html" title="joint_view"><code class="computeroutput"><span class="identifier">joint_view</span></code></a>
328              (where adapted sequences are <a class="link" href="associative_sequence.html" title="Associative Sequence">Associative
329              Sequence</a>s and <a class="link" href="forward_sequence.html" title="Forward Sequence">Forward
330              Sequence</a>s)
331            </li>
332<li class="listitem">
333              <a class="link" href="../../view/reverse_view.html" title="reverse_view"><code class="computeroutput"><span class="identifier">reverse_view</span></code></a>
334              (where adapted sequence is an <a class="link" href="associative_sequence.html" title="Associative Sequence">Associative
335              Sequence</a> and a <a class="link" href="bidirectional_sequence.html" title="Bidirectional Sequence">Bidirectional
336              Sequence</a>)
337            </li>
338</ul></div>
339</div>
340<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
341<td align="left"></td>
342<td align="right"><div class="copyright-footer">Copyright © 2001-2006, 2011, 2012 Joel de Guzman,
343      Dan Marsden, Tobias Schwinger<p>
344        Distributed under the Boost Software License, Version 1.0. (See accompanying
345        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
346      </p>
347</div></td>
348</tr></table>
349<hr>
350<div class="spirit-nav">
351<a accesskey="p" href="random_access_sequence.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unbounded_sequence.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
352</div>
353</body>
354</html>
355