1 .. Algorithms/Concepts//Reversible Algorithm
9 A |Reversible Algorithm| is a member of a pair of
10 transformation algorithms that iterate over their input sequence(s)
11 in opposite directions. For each reversible
12 algorithm ``x`` there exists a *counterpart* algorithm ``reverse_x``,
13 that exhibits the exact semantics of ``x`` except that the elements
14 of its input sequence argument(s) are processed in the reverse
18 Expression requirements
19 -----------------------
21 .. |s1...sn| replace:: *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`
23 .. |s1...sn>::type| replace:: |s1...sn|, ...\ ``>::type``
24 .. |s1...sn,in>::type| replace:: |s1...sn|, ... ``in>::type``
26 |In the following table...| ``x`` is a placeholder token for the actual
27 |Reversible Algorithm|'s name, |s1...sn| are
28 |Forward Sequence|\ s, and ``in`` is an |Inserter|.
30 +---------------------------------------+-----------------------+-------------------+
31 | Expression | Type | Complexity |
32 +=======================================+=======================+===================+
33 |``x<``\ |s1...sn>::type| | |Forward Sequence| | Unspecified. |
34 +---------------------------------------+-----------------------+-------------------+
35 |``x<``\ |s1...sn,in>::type| | Any type | Unspecified. |
36 +---------------------------------------+-----------------------+-------------------+
37 |``reverse_x<``\ |s1...sn>::type| | |Forward Sequence| | Unspecified. |
38 +---------------------------------------+-----------------------+-------------------+
39 |``reverse_x<``\ |s1...sn,in>::type| | Any type | Unspecified. |
40 +---------------------------------------+-----------------------+-------------------+
48 typedef x<\ *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...>::type t;
51 *s*\ :sub:`1` is an |Extensible Sequence|.
54 ``t`` is equivalent to
59 *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...
60 , back_inserter< clear<\ *s*\ :sub:`1`>::type >
63 if ``has_push_back<``\ *s*\ :sub:`1`\ ``>::value == true`` and
68 *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...
69 , front_inserter< clear<\ *s*\ :sub:`1`>::type >
74 .. ..........................................................................
79 typedef x<\ *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...\ in>::type t;
82 ``t`` is the result of an ``x`` invocation with arguments
83 *s*\ :sub:`1`,\ *s*\ :sub:`2`,... \ *s*\ :sub:`n`,...\ ``in``.
86 .. ..........................................................................
91 typedef reverse_x<\ *s*\ :sub:`1`,\ *s*\ :sub:`2`,... \ *s*\ :sub:`n`,... >::type t;
94 *s*\ :sub:`1` is an |Extensible Sequence|.
97 ``t`` is equivalent to
102 *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...
103 , front_inserter< clear<\ *s*\ :sub:`1`>::type >
106 if ``has_push_front<``\ *s*\ :sub:`1`\ ``>::value == true`` and
111 *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...
112 , back_inserter< clear<\ *s*\ :sub:`1`>::type >
118 .. ..........................................................................
122 typedef reverse_x<\ *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,... in>::type t;
125 ``t`` is the result of a ``reverse_x`` invocation with arguments
126 *s*\ :sub:`1`,\ *s*\ :sub:`2`,...\ *s*\ :sub:`n`,...\ ``in``.
137 , back_inserter< vector0<> >
140 typedef transform< r1, minus<_1,int_<2> > >::type r2;
141 typedef reverse_transform<
144 , front_inserter< vector0<> >
147 BOOST_MPL_ASSERT(( equal<r1, range_c<int,7,17> > ));
148 BOOST_MPL_ASSERT(( equal<r2, range_c<int,5,15> > ));
149 BOOST_MPL_ASSERT(( equal<r3, range_c<int,0,10> > ));
162 |Transformation Algorithms|, |Inserter|
165 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
166 Distributed under the Boost Software License, Version 1.0. (See accompanying
167 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)