Back to Arangodb

reverse_unique

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

3.12.9.14.2 KB
Original Source

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

reverse_unique

Synopsis

template<
      typename Seq
    , typename Pred
    , typename In =_unspecified_>
struct[reverse\_unique](./reverse-unique.html){
    typedef_unspecified_type;
};

Description

Returns a sequence of the initial elements of every subrange of the reversed original sequence Seq whose elements are all the same.

[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/unique.hpp](../../../../boost/mpl/unique.hpp)>

Model of

Reversible Algorithm

Parameters

ParameterRequirementDescription
SequenceForward SequenceAn original sequence.
PredBinary Lambda ExpressionAn equivalence relation.
InInserterAn inserter.

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, a binary Lambda Expression pred, and an Inserter in:

typedef[reverse\_unique](./reverse-unique.html)<s,pred,in>::type r;

| Return type: |

A type.

| | Semantics: |

If size<s>::value <= 1, then equivalent to

typedef[reverse\_copy](./reverse-copy.html)<s,in>::type r;

otherwise equivalent to

typedef[lambda](./lambda.html)<pred>::type p;
typedef[lambda](./lambda.html)<in::operation>::type in_op;
typedef[apply\_wrap](./apply-wrap.html)2<
      in_op
    , in::state
    ,[front](./front.html)<types>::type
    >::type in_state;

typedef[reverse\_fold](./reverse-fold.html)<
      s
    ,[pair](./pair.html)< in_state,[front](./front.html)<s>::type >
    ,[eval\_if](./eval-if.html)<[apply\_wrap](./apply-wrap.html)2<p, second<[\_1](./placeholders.html)>,[\_2](./placeholders.html)>
        ,[identity](./identity.html)< first<[\_1](./placeholders.html)> >
        ,[apply\_wrap](./apply-wrap.html)2<in_op, first<[\_1](./placeholders.html)>,[\_2](./placeholders.html)>
        >
    >::type::first r;

|

Complexity

Linear. Performs exactly size<s>::value - 1 applications of pred, and at most size<s>::value insertions.

Example

typedef[vector](./vector.html)<int,float,float,char,int,int,int,double> types;
typedef[vector](./vector.html)<double,int,char,float,int> expected;
typedef[reverse\_unique](./reverse-unique.html)< types, is_same<[\_1](./placeholders.html),[\_2](./placeholders.html)> >::type result;[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)< result,expected > ));

See also

Transformation Algorithms, Reversible Algorithm, unique, reverse_remove, reverse_copy_if, replace_if

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