.. Sequences/Classes//map |50 map === Description ----------- ``map`` is a |variadic|, `associative`__, `extensible`__ sequence of type pairs that supports constant-time insertion and removal of elements, and testing for membership. A ``map`` may contain at most one element for each key. __ `Associative Sequence`_ __ `Extensible Associative Sequence`_ Header ------ +-------------------+-------------------------------------------------------+ | Sequence form | Header | +===================+=======================================================+ | Variadic | ``#include `` | +-------------------+-------------------------------------------------------+ | Numbered | ``#include `` | +-------------------+-------------------------------------------------------+ Model of -------- * |Variadic Sequence| * |Associative Sequence| * |Extensible Associative Sequence| Expression semantics -------------------- |In the following table...| ``m`` is an instance of ``map``, ``pos`` is an iterator into ``m``, ``x`` and |p1...pn| are ``pair``\ s, and ``k`` is an arbitrary type. +---------------------------------------+-----------------------------------------------------------+ | Expression | Semantics | +=======================================+===========================================================+ | .. parsed-literal:: | ``map`` of elements |p1...pn|; see | | | |Variadic Sequence|. | | map<|p1...pn|> | | | map\ *n*\ <|p1...pn|> | | +---------------------------------------+-----------------------------------------------------------+ | .. parsed-literal:: | Identical to ``map``\ *n*\ ``<``\ |p1...pn|\ ``>``; | | | see |Variadic Sequence|. | | map<|p1...pn|>::type | | | map\ *n*\ <|p1...pn|>::type | | +---------------------------------------+-----------------------------------------------------------+ | ``begin::type`` | An iterator pointing to the beginning of ``m``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``end::type`` | An iterator pointing to the end of ``m``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``size::type`` | The size of ``m``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``empty::type`` | |true if and only if| ``m`` is empty; see | | | |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``front::type`` | The first element in ``m``; see | | | |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``has_key::type`` | Queries the presence of elements with the key ``k`` in | | | ``m``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``count::type`` | The number of elements with the key ``k`` in ``m``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``order::type`` | A unique unsigned |Integral Constant| associated with | | | the key ``k`` in ``m``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | .. parsed-literal:: | The element associated with the key ``k`` in | | | ``m``; see |Associative Sequence|. | | at::type | | | at::type | | +---------------------------------------+-----------------------------------------------------------+ | ``key_type::type`` | Identical to ``x::first``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``value_type::type`` | Identical to ``x::second``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``insert::type`` | A new ``map``, ``t``, equivalent to ``m`` except that | | | :: | | | | | | at< t, key_type::type >::type | | | | | | is identical to ``value_type::type``. | +---------------------------------------+-----------------------------------------------------------+ | ``insert::type`` | Equivalent to ``insert::type``; ``pos`` is ignored. | +---------------------------------------+-----------------------------------------------------------+ | ``erase_key::type`` | A new ``map``, ``t``, equivalent to ``m`` except that | | | ``has_key::value == false``. | +---------------------------------------+-----------------------------------------------------------+ | ``erase::type`` | Equivalent to ``erase::type >::type``. | +---------------------------------------+-----------------------------------------------------------+ | ``clear::type`` | An empty ``map``; see |clear|. | +---------------------------------------+-----------------------------------------------------------+ Example ------- .. parsed-literal:: typedef map< pair , pair , pair,char[17]> , pair > m; BOOST_MPL_ASSERT_RELATION( size::value, ==, 4 ); BOOST_MPL_ASSERT_NOT(( empty )); BOOST_MPL_ASSERT(( is_same< at::type, unsigned > )); BOOST_MPL_ASSERT(( is_same< at >::type, char[17] > )); BOOST_MPL_ASSERT(( is_same< at::type, bool > )); BOOST_MPL_ASSERT(( is_same< at::type, void\_ > )); See also -------- |Sequences|, |Variadic Sequence|, |Associative Sequence|, |Extensible Associative Sequence|, |set|, |vector| .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)