📄 reversebidirectionaliterator.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>MFC Programmer's SourceBook : STL Programmer's Guide</TITLE>
<META name="description"
content="A freely available implementation
of the C++ Standard Template Library, including
hypertext documentation.">
<META name="keywords"
content="generic programming, STL, standard template library">
</HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
var adcategory = "cpp";
// -->
</SCRIPT>
<body background="../../fancyhome/back.gif" bgcolor="#FFFFFF" >
<SCRIPT LANGUAGE="JavaScript"><!--
var nfrm = location.href.indexOf("_nfrm_");
var validframes = (top.frames.length > 0 && top.frames['ad'] && top.frames['logo'] );
var random = Math.random();
if( !validframes && nfrm == -1 )
{
var dclkPage = "www.codeguru.com/";
if( self.adcategory )
dclkPage += adcategory;
else
dclkPage += "mfc";
document.write('<nolayer><center>');
document.write('<iframe src="http://ad.doubleclick.net/adi/' + dclkPage + ';ord='
+ random + '" width=470 height=62 marginwidth=0 marginheight=0 hspace=0 vspace=0 '
+ 'frameborder=0 scrolling=no bordercolor="#000000">');
document.write('<a href="http://ad.doubleclick.net/jump/' + dclkPage + ';ord='
+ random + '">');
document.write('<img src="http://ad.doubleclick.net/ad/' + dclkPage + ';ord='
+ random + '" height=60 width=468>' + '</a>');
document.write('</iframe>');
document.write('</center></nolayer>');
document.write('<layer src="http://ad.doubleclick.net/adl/' + dclkPage +
';ord=' + random + '"></layer>');
document.write('<ilayer visibility=hide width=468 height=83></ilayer>');
}
// top.location = "/show.cgi?" + adcategory + "=" + location.pathname;
// -->
</SCRIPT>
<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupavNFCY34AAHgkdrY">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupavNFCY34AAHgkdrY"></a>
</p>
</noscript>
<BR Clear>
<H1>reverse_bidirectional_iterator<BidirectionalIterator, T, Reference, Distance></H1>
<Table CellPadding=0 CellSpacing=0 width=100%>
<TR>
<TD Align=left><Img src = "iterators.gif" Alt="" WIDTH = "194" HEIGHT = "38" ></TD>
<TD Align=right><Img src = "type.gif" Alt="" WIDTH = "194" HEIGHT = "39" ></TD>
</TR>
<TR>
<TD Align=left><Img src = "adaptors.gif" Alt="" WIDTH = "194" HEIGHT = "38" ></TD>
<TD Align=right></TD>
</TR>
<TR>
<TD Align=left VAlign=top><b>Categories</b>: iterators, adaptors</TD>
<TD Align=right VAlign=top><b>Component type</b>: type</TD>
</TR>
</Table>
<h3>Description</h3>
<tt>Reverse_bidirectional_iterator</tt> is an iterator adaptor that enables
backwards traversal of a range. <tt>Operator++</tt> applied to an object of
class <tt>reverse_bidirectional_iterator<<A href="BidirectionalIterator.html">BidirectionalIterator</A>></tt>
means the same thing as
<tt>operator--</tt> applied to an object of class <tt><A href="BidirectionalIterator.html">BidirectionalIterator</A></tt>.
There are two different reverse iterator adaptors: the class
<tt>reverse_bidirectional_iterator</tt>
has a template argument that is a <A href="BidirectionalIterator.html">Bidirectional Iterator</A>,
and the class <tt><A href="ReverseIterator.html">reverse_iterator</A></tt> has a template argument that is a
<A href="RandomAccessIterator.html">Random Access Iterator</A>. <A href="#1">[1]</A>
<h3>Example</h3>
<pre>
template <class T>
void forw(const <A href="List.html">list</A><T>& L)
{
list<T>::iterator first = L.begin();
list<T>::iterator last = L.end();
while (first != last)
cout << *first++ << endl;
}
template <class T>
void rev(const <A href="List.html">list</A><T>& L)
{
typedef reverse_bidirectional_iterator<list<T>::iterator,
T,
list<T>::reference_type,
list<T>::difference_type>
reverse_iterator; <A href="#2">[2]</A>
reverse_iterator rfirst(L.end());
reverse_iterator rlast(L.begin());
while (rfirst != rlast)
cout << *rfirst++ << endl;
}
</pre>
<P>
In the function <tt>forw</tt>, the elements are printed in the order
<tt>*first</tt>, <tt>*(first+1)</tt>, ..., <tt>*(last-1)</tt>. In the function
<tt>rev</tt>, they are printed in the order <tt>*(last - 1)</tt>, <tt>*(last-2)</tt>, ...,
<tt>*first</tt>. <A href="#3">[3]</A>
<h3>Definition</h3>
Defined in <A href="iterator.h">iterator.h</A>.
<h3>Template parameters</h3>
<Table border>
<TR>
<TH>
Parameter
</TH>
<TH>
Description
</TH>
<TH>
Default
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>BidirectionalIterator</tt>
</TD>
<TD VAlign=top>
The base iterator class. Incrementing an object of class
<tt>reverse_bidirectional_iterator<BidirectionalIterator></tt> corresponds to decrementing
an object of class <tt>BidirectionalIterator</tt>.
</TD>
<TD VAlign=top>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>T</tt>
</TD>
<TD VAlign=top>
The reverse iterator's value type. This should always be the same
as the base iterator's value type.
</TD>
<TD VAlign=top>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>Reference</tt>
</TD>
<TD VAlign=top>
The reverse iterator's reference type. This should always be the same
as the base iterator's reference type.
</TD>
<TD VAlign=top>
<tt>T&</tt>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>Distance</tt>
</TD>
<TD VAlign=top>
The reverse iterator's distance type. This should always be the
same as the base iterator's distance type.
</TD>
<TD VAlign=top>
<tt>ptrdiff_t</tt>
</TD>
</tr>
</table>
<h3>Model of</h3>
<A href="BidirectionalIterator.html">Bidirectional Iterator</A>.
<h3>Type requirements</h3>
The base iterator type (that is, the template parameter <tt>BidirectionalIterator</tt>)
must be a <tt><A href="BidirectionalIterator.html">Bidirectional Iterator</A></tt>. The <tt>reverse_bidirectional_iterator</tt>'s value type,
reference type, and distance type (that is, the template parameters
<tt>T</tt>, <tt>Reference</tt>, and <tt>Distance</tt>, respectively) must be the same as the
base iterator's value type, reference type, and distance type.
<h3>Public base classes</h3>
None.
<h3>Members</h3>
<Table border>
<TR>
<TH>
Member
</TH>
<TH>
Where defined
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>self</tt>
</TD>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator</tt>
</TD>
<TD VAlign=top>
See below
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator()</tt>
</TD>
<TD VAlign=top>
<A href="trivial.html">Trivial Iterator</A>
</TD>
<TD VAlign=top>
The default constructor
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator(const reverse_bidirectional_iterator& x)</tt>
</TD>
<TD VAlign=top>
<A href="trivial.html">Trivial Iterator</A>
</TD>
<TD VAlign=top>
The copy constructor
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator& operator=(const reverse_bidirectional_iterator& x)</tt>
</TD>
<TD VAlign=top>
<A href="trivial.html">Trivial Iterator</A>
</TD>
<TD VAlign=top>
The assignment operator
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator(BidirectionalIterator x)</tt>
</TD>
<TD VAlign=top>
<tt>reverse_bidirectional_iterator</tt>
</TD>
<TD VAlign=top>
See below.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>BidirectionalIterator base()</tt>
</TD>
<TD VAlign=top>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -