.. Sequences/Classes//set |40 set === Description ----------- ``set`` is a |variadic|, `associative`__, `extensible`__ sequence of types that supports constant-time insertion and removal of elements, and testing for membership. A ``set`` 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, ``s`` is an instance of ``set``, ``pos`` is an iterator into ``s``, and ``x``, ``k``, and |t1...tn| are arbitrary types. +---------------------------------------+-----------------------------------------------------------+ | Expression | Semantics | +=======================================+===========================================================+ | .. parsed-literal:: | ``set`` of elements |t1...tn|; see | | | |Variadic Sequence|. | | set<|t1...tn|> | | | set\ *n*\ <|t1...tn|> | | +---------------------------------------+-----------------------------------------------------------+ | .. parsed-literal:: | Identical to ``set``\ *n*\ ``<``\ |t1...tn|\ ``>``; | | | see |Variadic Sequence|. | | set<|t1...tn|>::type | | | set\ *n*\ <|t1...tn|>::type | | +---------------------------------------+-----------------------------------------------------------+ | ``begin::type`` | An iterator pointing to the beginning of ``s``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``end::type`` | An iterator pointing to the end of ``s``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``size::type`` | The size of ``s``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``empty::type`` | |true if and only if| ``s`` is empty; see | | | |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``front::type`` | The first element in ``s``; see | | | |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``has_key::type`` | |true if and only if| there is one or more elements | | | with the key ``k`` in ``s``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``count::type`` | The number of elements with the key ``k`` in ``s``; | | | see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``order::type`` | A unique unsigned |Integral Constant| associated with | | | the key ``k`` in ``s``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | .. parsed-literal:: | The element associated with the key ``k`` in | | | ``s``; see |Associative Sequence|. | | at::type | | | at::type | | +---------------------------------------+-----------------------------------------------------------+ | ``key_type::type`` | Identical to ``x``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``value_type::type`` | Identical to ``x``; see |Associative Sequence|. | +---------------------------------------+-----------------------------------------------------------+ | ``insert::type`` | A new ``set`` equivalent to ``s`` 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 ``set`` equivalent to ``s`` except that | | | ``has_key::value == false``. | +---------------------------------------+-----------------------------------------------------------+ | ``erase::type`` | Equivalent to ``erase::type >::type``. | +---------------------------------------+-----------------------------------------------------------+ | ``clear::type`` | An empty ``set``; see |clear|. | +---------------------------------------+-----------------------------------------------------------+ Example ------- .. parsed-literal:: typedef set< int,long,double,int_<5> > s; BOOST_MPL_ASSERT_RELATION( size::value, ==, 4 ); BOOST_MPL_ASSERT_NOT(( empty )); BOOST_MPL_ASSERT(( is_same< at::type, int > )); BOOST_MPL_ASSERT(( is_same< at::type, long > )); BOOST_MPL_ASSERT(( is_same< at >::type, int_<5> > )); BOOST_MPL_ASSERT(( is_same< at::type, void\_ > )); See also -------- |Sequences|, |Variadic Sequence|, |Associative Sequence|, |Extensible Associative Sequence|, |set_c|, |map|, |vector|