📄 for_5773.htm
字号:
<HTML><TITLE>Forward Iterators</TITLE><BODY>
<A HREF="ref.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the Class Reference home page.</STRONG></P>
<P>©Copyright 1996 Rogue Wave Software</P>
<H2>Forward Iterators</H2>
<HR><PRE> Iterator</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>A forward-moving iterator that can both read and write.</P>
<H3>Contents</H3>
<UL>
<A HREF="#Description"><LI>Description</LI></A>
<A HREF="#Key to Iterator Requirements"><LI>Key to Iterator Requirements</LI></A>
<A HREF="#Requirements for Forward Iterators"><LI>Requirements for Forward Iterators</LI></A>
<A HREF="#See Also"><LI>See Also</LI></A>
</UL>
<A NAME="Description"><H3>Description</H3></A>
<HR><STRONG><P>For a complete discussion of iterators, see the <A HREF="Ite_5295.htm"><B><I>Iterators</B></I></A> section of this reference.</P>
<P>Iterators are a generalization of pointers that allow a C++ program to uniformly interact with different data structures. Forward iterators are forward moving, and have the ability to both read and write data. These iterators satisfy the requirements listed below.</P></STRONG><HR>
<A NAME="Key to Iterator Requirements"><H3>Key to Iterator Requirements</H3></A>
<P>The following key pertains to the iterator requirements listed below: </P>
<CENTER><TABLE CELLSPACING=3 CELLPADDING=3>
<TR VALIGN=top>
<TD><SAMP>a </SAMP>and<SAMP> b</SAMP></TD>
<TD>values of type <SAMP>X</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>n</SAMP></TD>
<TD>value of <SAMP>distance</SAMP> type</TD></TR>
<TR VALIGN=top>
<TD><SAMP>u, Distance, tmp </SAMP>and<SAMP> m</SAMP></TD>
<TD>identifiers</TD></TR>
<TR VALIGN=top>
<TD><SAMP>r</SAMP></TD>
<TD>value of type <SAMP>X&</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>t</SAMP></TD>
<TD>value of type <SAMP>T</SAMP></TD></TR>
</TABLE></CENTER>
<A NAME="Requirements for Forward Iterators"><H3>Requirements for Forward Iterators</H3></A>
<P>The following expressions must be valid for forward iterators:</P>
<CENTER><TABLE CELLSPACING=3 CELLPADDING=3>
<TR VALIGN=top>
<TD><SAMP>X u</SAMP></TD>
<TD><SAMP>u</SAMP> might have a singular value</TD></TR>
<TR VALIGN=top>
<TD><SAMP>X()</SAMP></TD>
<TD><SAMP>X()</SAMP> might be singular</TD></TR>
<TR VALIGN=top>
<TD><SAMP>X(a)</SAMP></TD>
<TD>copy constructor, <SAMP>a == X(a)</SAMP>.</TD></TR>
<TR VALIGN=top>
<TD><SAMP>X u(a)</SAMP></TD>
<TD>copy constructor, <SAMP>u == a</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>X u = a</SAMP></TD>
<TD>assignment, <SAMP>u == a</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>a == b, a != b</SAMP></TD>
<TD>return value convertible to <SAMP>bool</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>*a</SAMP></TD>
<TD>return value convertible to <SAMP>T&</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>a->m</SAMP></TD>
<TD>equivalent to <SAMP>(*a).m</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>++r</SAMP></TD>
<TD>returns <SAMP>X&</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>r++</SAMP></TD>
<TD>return value convertible to const <SAMP>X&</SAMP></TD></TR>
<TR VALIGN=top>
<TD><SAMP>*r++</SAMP></TD>
<TD>returns <SAMP>T&</SAMP></TD></TR>
</TABLE></CENTER>
<P>Forward iterators have the condition that <SAMP>a == b</SAMP> implies <SAMP>*a == *b</SAMP>.</P>
<P>There are no restrictions on the number of passes an algorithm may make through the structure.</P>
<A NAME="See Also"><H3>See Also</H3></A>
<P><A HREF="Ite_5295.htm"><B><I>Iterators</B></I></A>, <A HREF="Ins_1844.htm"><B><I>Insert Iterators</B></I></A>, <A HREF="Bid_7861.htm"><B><I>Bidirectional Iterators</B></I></A></P>
<HR>
<A HREF="for_7707.htm"><IMG SRC="images/prev.gif"></A> <A HREF="ref.htm#contents"><IMG SRC="images/toc.gif"></A> <A HREF="fro_0713.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -