<!doctype html public "-//ietf//dtd html//en"> <html><head><title>boost::mpl::Bidirectional Iterator</title> <link rel="stylesheet" href="./mpl_wiki.css"> </head><body bgcolor="white"> <h1><a href="./Table_of_Contents.html"><img src="./mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>Bidirectional Iterator</h1><h3>Description</h3> <p> A Bidirectional Iterator is a <a href="./Forward_Iterator.html">Forward Iterator</a> that provides a way to obtain the previous element in a sequence. <p> <p> <h3>Refinement of</h3> <p> <a href="./Forward_Iterator.html">Forward Iterator</a> <p> <h3>Definitions</h3> <ul> <li>a bidirectional iterator <code>i</code> is <em>decrementable</em> if there is a "previous" iterator, that is, if <code>i::prior</code> expression is well-defined; iterators pointing to the first element of the sequence are not decrementable. </ul> <p> <h3>Valid expressions</h3> <p> Bidirectional Iterator both defines a new expression and refines the one described in <a href="./Forward_Iterator.html">Forward Iterator</a>. <p> <table border="1"> <tr><th> Expression </th><th> Expression type </th></tr> <tr><td><code>typename i::next</code></td><td>A model of <a href="./Bidirectional_Iterator.html">Bidirectional Iterator</a> </td></tr> <tr><td><code>typename i::prior</code></td><td>A model of <a href="./Bidirectional_Iterator.html">Bidirectional Iterator</a> </td></tr> </table> <p> <h3>Expression semantics</h3> <p> Semantics of an expression is defined only where it is not defined in <a href="./Forward_Iterator.html">Forward Iterator</a>. <p> <table border="1"> <tr><th> Expression </th><th> Complexity </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr> <tr><td><code>typename i::prior</code></td><td>Amortized constant time</td><td><code>i</code> is decrementable</td><td><code>i::prior</code> is an iterator pointing to the previous element of the sequence</td><td><code>i::prior</code> is dereferencable and incrementable </td></tr> </table> <p> <h3>Invariants</h3> <p> For any bidirectional iterators <code>i</code> and <code>j</code> the following invariants always hold: <p> <ul> <li>if <code>i</code> is incrementable, then <code>i::next::prior</code> is a null operation; similarly, if <code>i</code> is decrementable, <code>i::prior::next</code> is a null operation. </ul> <p> <h3>See also</h3> <p> <a href="./Bidirectional_Sequence.html">Bidirectional Sequence</a>, <a href="./Forward_Iterator.html">Forward Iterator</a>, <a href="./Random_Access_Iterator.html">Random Access Iterator</a> <p><hr> <a href="./Table_of_Contents.html">Table of Contents</a><br>Last edited July 15, 2002 11:33 am</body></html>