Back to Arangodb

reverse_partition

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/reverse-partition.html

3.12.9.13.9 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Transformation Algorithms / reverse_partition |

reverse_partition

Synopsis

template<
      typename Seq
    , typename Pred
    , typename In1 =_unspecified_, typename In2 =_unspecified_>
struct[reverse\_partition](./reverse-partition.html){
    typedef_unspecified_type;
};

Description

Returns a pair of sequences together containing all elements in the range [begin<Seq>::type, end<Seq>::type) split into two groups based on the predicate Pred. reverse_partition is a synonym for reverse_stable_partition.

[Note: This wording applies to a no-inserter version(s) of the algorithm. See the Expression semantics subsection for a precise specification of the algorithm's details in all cases — end note]

#include <[boost/mpl/partition.hpp](../../../../boost/mpl/partition.hpp)>

Model of

Reversible Algorithm

Parameters

ParameterRequirementDescription
SeqForward SequenceAn original sequence.
PredUnary Lambda ExpressionA partitioning predicate.
In1, In2InserterOutput inserters.

Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Reversible Algorithm.

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

typedef[reverse\_partition](./reverse-partition.html)<s,pred,in1,in2>::type r;

| Return type: |

A pair.

| | Semantics: |

Equivalent to

typedef[reverse\_stable\_partition](./reverse-stable-partition.html)<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\_](./bool.html)<(N::value % 2)> {};

typedef[partition](./partition.html)<[range\_c](./range-c.html)<int,0,10>
    , is_odd<[\_1](./placeholders.html)>
    ,[back\_inserter](./back-inserter.html)<[vector](./vector.html)<> >
    ,[back\_inserter](./back-inserter.html)<[vector](./vector.html)<> >
    >::type r;[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)< r::first,[vector\_c](./vector-c.html)<int,9,7,5,3,1> > ));[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)< r::second,[vector\_c](./vector-c.html)<int,8,6,4,2,0> > ));

See also

Transformation Algorithms, Reversible Algorithm, partition, reverse_stable_partition, sort

| Prev Next | Back Along | Up Home | Full TOC |

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) |