2004-11-28 03:35:12 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2010-08-09 20:07:24 +00:00
< meta name = "generator" content = "Docutils 0.7: http://docutils.sourceforge.net/" / >
2004-11-28 03:35:12 +00:00
< title > The MPL Reference Manual: Associative Sequence< / title >
< link rel = "stylesheet" href = "../style.css" type = "text/css" / >
< / head >
< body class = "docframe refmanual" >
2009-08-17 11:30:52 +00:00
< table class = "header" > < tr class = "header" > < td class = "header-group navigation-bar" > < span class = "navigation-group" > < a href = "./back-extensible-sequence.html" class = "navigation-link" > Prev< / a > < a href = "./extensible-associative-sequence.html" class = "navigation-link" > Next< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./back-extensible-sequence.html" class = "navigation-link" > Back< / a > < a href = "./extensible-associative-sequence.html" class = "navigation-link" > Along< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./concepts.html" class = "navigation-link" > Up< / a > < a href = "../refmanual.html" class = "navigation-link" > Home< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC< / a > < / span > < / td >
2004-11-28 03:35:12 +00:00
< td class = "header-group page-location" > < a href = "../refmanual.html" class = "navigation-link" > Front Page< / a > / < a href = "./sequences.html" class = "navigation-link" > Sequences< / a > / < a href = "./concepts.html" class = "navigation-link" > Concepts< / a > / < a href = "./associative-sequence.html" class = "navigation-link" > Associative Sequence< / a > < / td >
< / tr > < / table > < div class = "header-separator" > < / div >
< div class = "section" id = "associative-sequence" >
2010-08-09 20:07:24 +00:00
< h1 > < a class = "toc-backref" href = "./concepts.html#id1401" > Associative Sequence< / a > < / h1 >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id29" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#description" name = "description" > Description< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > An < a class = "reference internal" href = "./associative-sequence.html" > Associative Sequence< / a > is a < a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > 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,
< em > type identity< / em > is used to impose an equivalence relation on keys, and the
order in which sequence elements are traversed during iteration is left
2004-11-28 03:35:12 +00:00
unspecified.< / p >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id30" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#definitions" name = "definitions" > Definitions< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< ul class = "simple" id = "value-part" >
2021-12-02 03:37:28 +00:00
< li > < span id = "key-part" > < / span > A < em > key< / em > is a part of the element type used to identify and retrieve
2004-11-28 03:35:12 +00:00
the element within the sequence.< / li >
2009-08-17 11:30:52 +00:00
< li > A < em > value< / em > is a part of the element type retrievied from the sequence
2004-11-28 03:35:12 +00:00
by its key.< / li >
< / ul >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id31" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#expression-requirements" name = "expression-requirements" > Expression requirements< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > In the following table and subsequent specifications, < tt class = "literal" > < span class = "pre" > s< / span > < / tt > is an < a class = "reference internal" href = "./associative-sequence.html" > Associative Sequence< / a > ,
2004-11-28 03:35:12 +00:00
< tt class = "literal" > < span class = "pre" > x< / span > < / tt > is a sequence element, and < tt class = "literal" > < span class = "pre" > k< / span > < / tt > and < tt class = "literal" > < span class = "pre" > def< / span > < / tt > are arbitrary types.< / p >
2009-08-17 11:30:52 +00:00
< p > In addition to the requirements defined in < a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > ,
2004-11-28 03:35:12 +00:00
the following must be met:< / p >
2009-08-17 11:30:52 +00:00
< table border = "1" class = "docutils table" >
2004-11-28 03:35:12 +00:00
< colgroup >
< col width = "33%" / >
< col width = "38%" / >
< col width = "29%" / >
< / colgroup >
< thead valign = "bottom" >
2009-08-17 11:30:52 +00:00
< tr > < th class = "head" > Expression< / th >
< th class = "head" > Type< / th >
< th class = "head" > Complexity< / th >
2004-11-28 03:35:12 +00:00
< / tr >
< / thead >
< tbody valign = "top" >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./has-key.html" class = "identifier" > has_key< / a > < s,k> ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > Boolean < a class = "reference internal" href = "./integral-constant.html" > Integral Constant< / a > < / td >
2004-11-28 03:35:12 +00:00
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./count.html" class = "identifier" > count< / a > < s,k> ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > < a class = "reference internal" href = "./integral-constant.html" > Integral Constant< / a > < / td >
2004-11-28 03:35:12 +00:00
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./order.html" class = "identifier" > order< / a > < s,k> ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > < a class = "reference internal" href = "./integral-constant.html" > Integral Constant< / a > or < tt class = "literal" > < span class = "pre" > < a href = "./void.html" class = "identifier" > void_< / a > < / span > < / tt > < / td >
2004-11-28 03:35:12 +00:00
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./at.html" class = "identifier" > at< / a > < s,k> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./at.html" class = "identifier" > at< / a > < s,k,def> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./key-type.html" class = "identifier" > key_type< / a > < s,x> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Amortized constant time< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./value-type.html" class = "identifier" > value_type< / a > < s,x> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Amortized constant time< / td >
< / tr >
< / tbody >
< / table >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id32" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#expression-semantics" name = "expression-semantics" > Expression semantics< / a > < / h3 >
< p > The semantics of an expression are defined only
2009-08-17 11:30:52 +00:00
where they differ from, or are not defined in < a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > .< / p >
< table border = "1" class = "docutils table" >
2004-11-28 03:35:12 +00:00
< colgroup >
< col width = "33%" / >
< col width = "67%" / >
< / colgroup >
< thead valign = "bottom" >
2009-08-17 11:30:52 +00:00
< tr > < th class = "head" > Expression< / th >
< th class = "head" > Semantics< / th >
2004-11-28 03:35:12 +00:00
< / tr >
< / thead >
< tbody valign = "top" >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./has-key.html" class = "identifier" > has_key< / a > < s,k> ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > A boolean < a class = "reference internal" href = "./integral-constant.html" > Integral Constant< / a > < tt class = "literal" > < span class = "pre" > c< / span > < / tt > such that
2004-11-28 03:35:12 +00:00
< tt class = "literal" > < span class = "pre" > c::value< / span > < span class = "pre" > ==< / span > < span class = "pre" > true< / span > < / tt > if and only if there is one or more
2009-08-17 11:30:52 +00:00
elements with the key < tt class = "literal" > < span class = "pre" > k< / span > < / tt > in < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ; see < a class = "reference internal" href = "./has-key.html" > has_key< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./count.html" class = "identifier" > count< / a > < s,k> ::type< / span > < / tt > < / td >
< td > The number of elements with the key < tt class = "literal" > < span class = "pre" > k< / span > < / tt > in < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ;
2009-08-17 11:30:52 +00:00
see < a class = "reference internal" href = "./count.html" > count< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./order.html" class = "identifier" > order< / a > < s,k> ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > A unique unsigned < a class = "reference internal" href = "./integral-constant.html" > Integral Constant< / a > associated
with the key < tt class = "literal" > < span class = "pre" > k< / span > < / tt > in the sequence < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ; see < a class = "reference internal" href = "./order.html" > order< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr > < td > < pre class = "first last literal-block" >
< a href = "./at.html" class = "identifier" > at< / a > < s,k> ::type
< a href = "./at.html" class = "identifier" > at< / a > < s,k,def> ::type
< / pre >
< / td >
< td > The first element associated with the key < tt class = "literal" > < span class = "pre" > k< / span > < / tt >
2009-08-17 11:30:52 +00:00
in the sequence < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ; see < a class = "reference internal" href = "./at.html" > at< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./key-type.html" class = "identifier" > key_type< / a > < s,x> ::type< / span > < / tt > < / td >
< td > The key part of the element < tt class = "literal" > < span class = "pre" > x< / span > < / tt > that would be
2009-08-17 11:30:52 +00:00
used to identify < tt class = "literal" > < span class = "pre" > x< / span > < / tt > in < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ; see < a class = "reference internal" href = "./key-type.html" > key_type< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > < a href = "./value-type.html" class = "identifier" > value_type< / a > < s,x> ::type< / span > < / tt > < / td >
< td > The value part of the element < tt class = "literal" > < span class = "pre" > x< / span > < / tt > that would be
2009-08-17 11:30:52 +00:00
used for < tt class = "literal" > < span class = "pre" > x< / span > < / tt > in < tt class = "literal" > < span class = "pre" > s< / span > < / tt > ; see < a class = "reference internal" href = "./value-type.html" > value_type< / a > .< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< / tbody >
< / table >
<!-- Invariants
- - - - - - - - - -
2009-08-17 11:30:52 +00:00
For any associative sequence ``s`` the following invariants always hold:
2004-11-28 03:35:12 +00:00
* ??? -->
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id33" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#models" name = "models" > Models< / a > < / h3 >
< ul class = "simple" >
2009-08-17 11:30:52 +00:00
< li > < a class = "reference internal" href = "./set.html" > set< / a > < / li >
< li > < a class = "reference internal" href = "./map.html" > map< / a > < / li >
2004-11-28 03:35:12 +00:00
< / ul >
<!-- * |multiset| -->
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id34" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#see-also" name = "see-also" > See also< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > < a class = "reference internal" href = "./sequences.html" > Sequences< / a > , < a class = "reference internal" href = "./extensible-associative-sequence.html" > Extensible Associative Sequence< / a > , < a class = "reference internal" href = "./has-key.html" > has_key< / a > , < a class = "reference internal" href = "./count.html" > count< / a > , < a class = "reference internal" href = "./order.html" > order< / a > , < a class = "reference internal" href = "./at.html" > at< / a > , < a class = "reference internal" href = "./key-type.html" > key_type< / a > , < a class = "reference internal" href = "./value-type.html" > value_type< / a > < / p >
2004-11-28 03:35:12 +00:00
<!-- Sequences/Concepts//Extensible Associative Sequence |80 -->
< / div >
< / div >
< div class = "footer-separator" > < / div >
2009-08-17 11:30:52 +00:00
< table class = "footer" > < tr class = "footer" > < td class = "header-group navigation-bar" > < span class = "navigation-group" > < a href = "./back-extensible-sequence.html" class = "navigation-link" > Prev< / a > < a href = "./extensible-associative-sequence.html" class = "navigation-link" > Next< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./back-extensible-sequence.html" class = "navigation-link" > Back< / a > < a href = "./extensible-associative-sequence.html" class = "navigation-link" > Along< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./concepts.html" class = "navigation-link" > Up< / a > < a href = "../refmanual.html" class = "navigation-link" > Home< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC< / a > < / span > < / td >
< td > < div class = "copyright-footer" > < div class = "copyright" > Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams< / div >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a class = "reference external" href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt< / a > )< / div > < / td > < / tr > < / table > < / body >
2004-11-28 03:35:12 +00:00
< / html >