2004-11-28 03:35:12 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2010-08-09 20:07:24 +00:00
< meta name = "generator" content = "Docutils 0.7: http://docutils.sourceforge.net/" / >
2004-11-28 03:35:12 +00:00
< title > The MPL Reference Manual: Reversible Algorithm< / title >
< link rel = "stylesheet" href = "../style.css" type = "text/css" / >
< / head >
< body class = "docframe refmanual" >
< table class = "header" > < tr class = "header" > < td class = "header-group navigation-bar" > < span class = "navigation-group" > < a href = "./inserter.html" class = "navigation-link" > Prev< / a > < a href = "./inserters.html" class = "navigation-link" > Next< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./inserter.html" class = "navigation-link" > Back< / a > Along< / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./algorithms-concepts.html" class = "navigation-link" > Up< / a > < a href = "../refmanual.html" class = "navigation-link" > Home< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC< / a > < / span > < / td >
< td class = "header-group page-location" > < a href = "../refmanual.html" class = "navigation-link" > Front Page< / a > / < a href = "./algorithms.html" class = "navigation-link" > Algorithms< / a > / < a href = "./algorithms-concepts.html" class = "navigation-link" > Concepts< / a > / < a href = "./reversible-algorithm.html" class = "navigation-link" > Reversible Algorithm< / a > < / td >
< / tr > < / table > < div class = "header-separator" > < / div >
< div class = "section" id = "reversible-algorithm" >
2010-08-09 20:07:24 +00:00
< h1 > < a class = "toc-backref" href = "./algorithms-concepts.html#id1463" > Reversible Algorithm< / a > < / h1 >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id459" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#description" name = "description" > Description< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > A < a class = "reference internal" href = "./reversible-algorithm.html" > Reversible Algorithm< / a > is a member of a pair of
transformation algorithms that iterate over their input sequence(s)
in opposite directions. For each reversible
algorithm < tt class = "literal" > < span class = "pre" > x< / span > < / tt > there exists a < em > counterpart< / em > algorithm < tt class = "literal" > < span class = "pre" > reverse_x< / span > < / tt > ,
that exhibits the exact semantics of < tt class = "literal" > < span class = "pre" > x< / span > < / tt > except that the elements
of its input sequence argument(s) are processed in the reverse
2004-11-28 03:35:12 +00:00
order.< / p >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id460" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#expression-requirements" name = "expression-requirements" > Expression requirements< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > In the following table and subsequent specifications, < tt class = "literal" > < span class = "pre" > x< / span > < / tt > is a placeholder token for the actual
< a class = "reference internal" href = "./reversible-algorithm.html" > Reversible Algorithm< / a > 's name, < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > are
< a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > s, and < tt class = "literal" > < span class = "pre" > in< / span > < / tt > is an < a class = "reference internal" href = "./inserter.html" > Inserter< / a > .< / p >
< table border = "1" class = "docutils table" >
2004-11-28 03:35:12 +00:00
< colgroup >
< col width = "48%" / >
< col width = "28%" / >
< col width = "23%" / >
< / colgroup >
< thead valign = "bottom" >
2009-08-17 11:30:52 +00:00
< tr > < th class = "head" > Expression< / th >
< th class = "head" > Type< / th >
< th class = "head" > Complexity< / th >
2004-11-28 03:35:12 +00:00
< / tr >
< / thead >
< tbody valign = "top" >
< tr > < td > < tt class = "literal" > < span class = "pre" > x< < / span > < / tt > < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > , ...< tt class = "literal" > < span class = "pre" > > ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > < a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > < / td >
2004-11-28 03:35:12 +00:00
< td > Unspecified.< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > x< < / span > < / tt > < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > , ... < tt class = "literal" > < span class = "pre" > in> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Unspecified.< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > reverse_x< < / span > < / tt > < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > , ...< tt class = "literal" > < span class = "pre" > > ::type< / span > < / tt > < / td >
2009-08-17 11:30:52 +00:00
< td > < a class = "reference internal" href = "./forward-sequence.html" > Forward Sequence< / a > < / td >
2004-11-28 03:35:12 +00:00
< td > Unspecified.< / td >
< / tr >
< tr > < td > < tt class = "literal" > < span class = "pre" > reverse_x< < / span > < / tt > < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > , ... < tt class = "literal" > < span class = "pre" > in> ::type< / span > < / tt > < / td >
< td > Any type< / td >
< td > Unspecified.< / td >
< / tr >
< / tbody >
< / table >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id461" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#expression-semantics" name = "expression-semantics" > Expression semantics< / a > < / h3 >
< pre class = "literal-block" >
typedef x< < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...> ::type t;
< / pre >
2009-08-17 11:30:52 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-11-28 03:35:12 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
2009-08-17 11:30:52 +00:00
< tr class = "field" > < th class = "field-name" > Precondition:< / th > < td class = "field-body" > < p class = "first" > < em > s< / em > < sub > 1< / sub > is an < a class = "reference internal" href = "./extensible-sequence.html" > Extensible Sequence< / a > .< / p >
< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr class = "field" > < th class = "field-name" > Semantics:< / th > < td class = "field-body" > < p class = "first" > < tt class = "literal" > < span class = "pre" > t< / span > < / tt > is equivalent to< / p >
< pre class = "literal-block" >
x<
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...
2009-08-17 11:30:52 +00:00
, < a href = "./back-inserter.html" class = "identifier" > back_inserter< / a > < < a href = "./clear.html" class = "identifier" > clear< / a > < < em > s< / em > < sub > 1< / sub > > ::type >
2004-11-28 03:35:12 +00:00
> ::type
< / pre >
< p > if < tt class = "literal" > < span class = "pre" > has_push_back< < / span > < / tt > < em > s< / em > < sub > 1< / sub > < tt class = "literal" > < span class = "pre" > > ::value< / span > < span class = "pre" > ==< / span > < span class = "pre" > true< / span > < / tt > and< / p >
< pre class = "literal-block" >
reverse_x<
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...
2009-08-17 11:30:52 +00:00
, < a href = "./front-inserter.html" class = "identifier" > front_inserter< / a > < < a href = "./clear.html" class = "identifier" > clear< / a > < < em > s< / em > < sub > 1< / sub > > ::type >
2004-11-28 03:35:12 +00:00
> ::type
< / pre >
< p class = "last" > otherwise.< / p >
< / td >
< / tr >
< / tbody >
< / table >
<!-- .......................................................................... -->
< pre class = "literal-block" >
typedef x< < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...in> ::type t;
< / pre >
2009-08-17 11:30:52 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-11-28 03:35:12 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
2009-08-17 11:30:52 +00:00
< tr class = "field" > < th class = "field-name" > Semantics:< / th > < td class = "field-body" > < tt class = "literal" > < span class = "pre" > t< / span > < / tt > is the result of an < tt class = "literal" > < span class = "pre" > x< / span > < / tt > invocation with arguments
2004-11-28 03:35:12 +00:00
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,... < em > s< / em > < sub > n< / sub > ,...< tt class = "literal" > < span class = "pre" > in< / span > < / tt > .< / td >
< / tr >
< / tbody >
< / table >
<!-- .......................................................................... -->
< pre class = "literal-block" >
typedef reverse_x< < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,... < em > s< / em > < sub > n< / sub > ,... > ::type t;
< / pre >
2009-08-17 11:30:52 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-11-28 03:35:12 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
2009-08-17 11:30:52 +00:00
< tr class = "field" > < th class = "field-name" > Precondition:< / th > < td class = "field-body" > < p class = "first" > < em > s< / em > < sub > 1< / sub > is an < a class = "reference internal" href = "./extensible-sequence.html" > Extensible Sequence< / a > .< / p >
< / td >
2004-11-28 03:35:12 +00:00
< / tr >
< tr class = "field" > < th class = "field-name" > Semantics:< / th > < td class = "field-body" > < p class = "first" > < tt class = "literal" > < span class = "pre" > t< / span > < / tt > is equivalent to< / p >
< pre class = "literal-block" >
x<
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...
2009-08-17 11:30:52 +00:00
, < a href = "./front-inserter.html" class = "identifier" > front_inserter< / a > < < a href = "./clear.html" class = "identifier" > clear< / a > < < em > s< / em > < sub > 1< / sub > > ::type >
2004-11-28 03:35:12 +00:00
> ::type
< / pre >
< p > if < tt class = "literal" > < span class = "pre" > has_push_front< < / span > < / tt > < em > s< / em > < sub > 1< / sub > < tt class = "literal" > < span class = "pre" > > ::value< / span > < span class = "pre" > ==< / span > < span class = "pre" > true< / span > < / tt > and< / p >
< pre class = "literal-block" >
reverse_x<
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...
2009-08-17 11:30:52 +00:00
, < a href = "./back-inserter.html" class = "identifier" > back_inserter< / a > < < a href = "./clear.html" class = "identifier" > clear< / a > < < em > s< / em > < sub > 1< / sub > > ::type >
2004-11-28 03:35:12 +00:00
> ::type
< / pre >
< p class = "last" > otherwise.< / p >
< / td >
< / tr >
< / tbody >
< / table >
<!-- .......................................................................... -->
< pre class = "literal-block" >
typedef reverse_x< < em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,... in> ::type t;
< / pre >
2009-08-17 11:30:52 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-11-28 03:35:12 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
2009-08-17 11:30:52 +00:00
< tr class = "field" > < th class = "field-name" > Semantics:< / th > < td class = "field-body" > < tt class = "literal" > < span class = "pre" > t< / span > < / tt > is the result of a < tt class = "literal" > < span class = "pre" > reverse_x< / span > < / tt > invocation with arguments
2004-11-28 03:35:12 +00:00
< em > s< / em > < sub > 1< / sub > ,< em > s< / em > < sub > 2< / sub > ,...< em > s< / em > < sub > n< / sub > ,...< tt class = "literal" > < span class = "pre" > in< / span > < / tt > .< / td >
< / tr >
< / tbody >
< / table >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id462" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#example" name = "example" > Example< / a > < / h3 >
< pre class = "literal-block" >
2009-08-17 11:30:52 +00:00
typedef < a href = "./transform.html" class = "identifier" > transform< / a > <
2004-11-28 03:35:12 +00:00
< a href = "./range-c.html" class = "identifier" > range_c< / a > < int,0,10>
2009-08-17 11:30:52 +00:00
, < a href = "./plus.html" class = "identifier" > plus< / a > < < a href = "./placeholders.html" class = "identifier" > _1< / a > ,< a href = "./int.html" class = "identifier" > int_< / a > < 7> >
, < a href = "./back-inserter.html" class = "identifier" > back_inserter< / a > < vector0< > >
2004-11-28 03:35:12 +00:00
> ::type r1;
2009-08-17 11:30:52 +00:00
typedef < a href = "./transform.html" class = "identifier" > transform< / a > < r1, < a href = "./minus.html" class = "identifier" > minus< / a > < < a href = "./placeholders.html" class = "identifier" > _1< / a > ,< a href = "./int.html" class = "identifier" > int_< / a > < 2> > > ::type r2;
typedef < a href = "./reverse-transform.html" class = "identifier" > reverse_transform< / a > <
2004-11-28 03:35:12 +00:00
r2
2009-08-17 11:30:52 +00:00
, < a href = "./minus.html" class = "identifier" > minus< / a > < < a href = "./placeholders.html" class = "identifier" > _1< / a > ,5>
, < a href = "./front-inserter.html" class = "identifier" > front_inserter< / a > < vector0< > >
2004-11-28 03:35:12 +00:00
> ::type r3;
< a href = "./assert.html" class = "identifier" > BOOST_MPL_ASSERT< / a > (( < a href = "./equal.html" class = "identifier" > equal< / a > < r1, < a href = "./range-c.html" class = "identifier" > range_c< / a > < int,7,17> > ));
< a href = "./assert.html" class = "identifier" > BOOST_MPL_ASSERT< / a > (( < a href = "./equal.html" class = "identifier" > equal< / a > < r2, < a href = "./range-c.html" class = "identifier" > range_c< / a > < int,5,15> > ));
< a href = "./assert.html" class = "identifier" > BOOST_MPL_ASSERT< / a > (( < a href = "./equal.html" class = "identifier" > equal< / a > < r3, < a href = "./range-c.html" class = "identifier" > range_c< / a > < int,0,10> > ));
< / pre >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id463" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#models" name = "models" > Models< / a > < / h3 >
< ul class = "simple" >
2009-08-17 11:30:52 +00:00
< li > < a class = "reference internal" href = "./transform.html" > transform< / a > < / li >
< li > < a class = "reference internal" href = "./remove.html" > remove< / a > < / li >
< li > < a class = "reference internal" href = "./replace.html" > replace< / a > < / li >
2004-11-28 03:35:12 +00:00
< / ul >
< / div >
2009-08-17 11:30:52 +00:00
< div class = "section" id = "id464" >
2004-11-28 03:35:12 +00:00
< h3 > < a class = "subsection-title" href = "#see-also" name = "see-also" > See also< / a > < / h3 >
2009-08-17 11:30:52 +00:00
< p > < a class = "reference internal" href = "./transformation-algorithms.html" > Transformation Algorithms< / a > , < a class = "reference internal" href = "./inserter.html" > Inserter< / a > < / p >
2004-11-28 03:35:12 +00:00
< / div >
< / div >
< div class = "footer-separator" > < / div >
< table class = "footer" > < tr class = "footer" > < td class = "header-group navigation-bar" > < span class = "navigation-group" > < a href = "./inserter.html" class = "navigation-link" > Prev< / a > < a href = "./inserters.html" class = "navigation-link" > Next< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./inserter.html" class = "navigation-link" > Back< / a > Along< / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./algorithms-concepts.html" class = "navigation-link" > Up< / a > < a href = "../refmanual.html" class = "navigation-link" > Home< / a > < / span > < span class = "navigation-group-separator" > | < / span > < span class = "navigation-group" > < a href = "./refmanual_toc.html" class = "navigation-link" > Full TOC< / a > < / span > < / td >
2009-08-17 11:30:52 +00:00
< td > < div class = "copyright-footer" > < div class = "copyright" > Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams< / div >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a class = "reference external" href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt< / a > )< / div > < / td > < / tr > < / table > < / body >
2004-11-28 03:35:12 +00:00
< / html >