3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/reversible-algorithm.html
| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Concepts / Reversible Algorithm |
A Reversible Algorithm is a member of a pair of transformation algorithms that iterate over their input sequence(s) in opposite directions. For each reversible algorithm x there exists a counterpart algorithm reverse_x, that exhibits the exact semantics of x except that the elements of its input sequence argument(s) are processed in the reverse order.
In the following table and subsequent specifications, x is a placeholder token for the actual Reversible Algorithm's name, _s_1,_s_2,..._s_n are Forward Sequences, and in is an Inserter.
| Expression | Type | Complexity |
|---|---|---|
| x<_s_1,_s_2,..._s_n, ...>::type | Forward Sequence | Unspecified. |
| x<_s_1,_s_2,..._s_n, ... in>::type | Any type | Unspecified. |
| reverse_x<_s_1,_s_2,..._s_n, ...>::type | Forward Sequence | Unspecified. |
| reverse_x<_s_1,_s_2,..._s_n, ... in>::type | Any type | Unspecified. |
typedef x<_s_1,_s_2,..._s_n,...>::type t;
| Precondition: |
_s_1 is an Extensible Sequence.
| | Semantics: |
t is equivalent to
x<_s_1,_s_2,..._s_n,...
,[back\_inserter](./back-inserter.html)<[clear](./clear.html)<_s_1>::type >
>::type
if has_push_back<_s_1>::value == true and
reverse_x<_s_1,_s_2,..._s_n,...
,[front\_inserter](./front-inserter.html)<[clear](./clear.html)<_s_1>::type >
>::type
otherwise.
|
typedef x<_s_1,_s_2,..._s_n,...in>::type t;
| Semantics: | t is the result of an x invocation with arguments _s_1,_s_2,... _s_n,...in. |
typedef reverse_x<_s_1,_s_2,..._s_n,... >::type t;
| Precondition: |
_s_1 is an Extensible Sequence.
| | Semantics: |
t is equivalent to
x<_s_1,_s_2,..._s_n,...
,[front\_inserter](./front-inserter.html)<[clear](./clear.html)<_s_1>::type >
>::type
if has_push_front<_s_1>::value == true and
reverse_x<_s_1,_s_2,..._s_n,...
,[back\_inserter](./back-inserter.html)<[clear](./clear.html)<_s_1>::type >
>::type
otherwise.
|
typedef reverse_x<_s_1,_s_2,..._s_n,... in>::type t;
| Semantics: | t is the result of a reverse_x invocation with arguments _s_1,_s_2,..._s_n,...in. |
typedef[transform](./transform.html)<[range\_c](./range-c.html)<int,0,10>
,[plus](./plus.html)<[\_1](./placeholders.html),[int\_](./int.html)<7> >
,[back\_inserter](./back-inserter.html)< vector0<> >
>::type r1;
typedef[transform](./transform.html)< r1,[minus](./minus.html)<[\_1](./placeholders.html),[int\_](./int.html)<2> > >::type r2;
typedef[reverse\_transform](./reverse-transform.html)<
r2
,[minus](./minus.html)<[\_1](./placeholders.html),5>
,[front\_inserter](./front-inserter.html)< vector0<> >
>::type r3;[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)<r1,[range\_c](./range-c.html)<int,7,17> > ));[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)<r2,[range\_c](./range-c.html)<int,5,15> > ));[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)<r3,[range\_c](./range-c.html)<int,0,10> > ));
Transformation Algorithms, Inserter
| 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) |