Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/src/refmanual/partition.rst @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.6 KB

partition

Synopsis

template<
      typename Seq
    , typename Pred
    , typename In1 = |unspecified|
    , typename In2 = |unspecified|
    >
struct partition
{
    typedef |unspecified| type;
};

Description

Returns a pair of sequences together containing all elements in the range |begin/end<Seq>| split into two groups based on the predicate Pred. partition is a synonym for |stable_partition|.

|transformation algorithm disclaimer|

Parameters

Parameter Requirement Description
Seq |Forward Sequence| An original sequence.
Pred Unary |Lambda Expression| A partitioning predicate.
In1, In2 |Inserter| Output inserters.

Expression semantics

|Semantics disclaimer...| |Reversible Algorithm|.

For any |Forward Sequence| s, an unary |Lambda Expression| pred, and |Inserter|s in1 and in2:

typedef partition<s,pred,in1,in2>::type r;
Return type:

A |pair|.

Semantics:

Equivalent to

typedef stable_partition<s,pred,in1,in2>::type r;

Complexity

Linear. Exactly size<s>::value applications of pred, and size<s>::value of summarized in1::operation / in2::operation applications.

Example

template< typename N > struct is_odd : bool_<(N::value % 2)> {};
typedef partition<
      range_c<int,0,10>
    , is_odd<_1>
    , back_inserter< vector<> >
    , back_inserter< vector<> >
    >::type r;
BOOST_MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > ));
BOOST_MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > ));

Docutils System Messages

?????????????????????
Note: See TracBrowser for help on using the repository browser.