⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 front_insert_iterator.html

📁 VC书籍介绍C++的应用的TheOODesignProcess.zip 电子书好用的
💻 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=NupastFCY34AAHiGPwc">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupastFCY34AAHiGPwc"></a>
</p>
</noscript>





<BR Clear>
<H1>front_insert_iterator&lt;FrontInsertionSequence&gt;</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>Front_insert_iterator</tt> is an iterator adaptor that functions as an
<A href="OutputIterator.html">Output Iterator</A>: assignment through a <tt>front_insert_iterator</tt> inserts
an object before the first element of a <A href="FrontInsertionSequence.html">Front Insertion Sequence</A>. <A href="#1">[1]</A> <A href="#2">[2]</A>
<h3>Example</h3>
<pre>
<A href="List.html">list</A>&lt;int&gt; L;
L.push_front(3);
front_insert_iterator&lt;<A href="List.html">list</A>&lt;int&gt; &gt; ii(L);
*ii++ = 0;
*ii++ = 1;
*ii++ = 2;
<A href="copy.html">copy</A>(L.begin(), L.end(), <A href="ostream_iterator.html" tppabs="http://www.sgi.com/Technology/STL/ostream_iterator.shtml">ostream_iterator</A>&lt;int&gt;(cout, &quot; &quot;));
// The values that are printed are 2 1 0 3
</pre>
<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>FrontInsertionSequence</tt>
</TD>
<TD VAlign=top>
The type of <A href="FrontInsertionSequence.html">Front Insertion Sequence</A> into which values will be inserted.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</tr>
</table>
<h3>Model of</h3>
<A href="OutputIterator.html">Output Iterator</A>.  A front insert iterator's set of value types (as
defined in the <A href="OutputIterator.html">Output Iterator</A> requirements) consists of
a single type: <tt><A href="FrontInsertionSequence.html">FrontInsertionSequence</A>::value_type</tt>.
<h3>Type requirements</h3>
The template parameter <tt>FrontInsertionSequence</tt> must be a 
<A href="FrontInsertionSequence.html">Front Insertion Sequence</A>.
<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>front_insert_iterator(FrontInsertionSequence&amp;)</tt>
</TD>
<TD VAlign=top>
<tt>front_insert_iterator</tt>
</TD>
<TD VAlign=top>
See below.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>front_insert_iterator(const front_insert_iterator&amp;)</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>
<pre>
front_insert_iterator&amp; 
operator=(const front_insert_iterator&amp;)
</pre>
</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>front_insert_iterator&amp; operator*()</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Used to implement the <A href="OutputIterator.html">output iterator</A> expression <tt>*i = x</tt>. <A href="#3">[3]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
front_insert_iterator&amp; 
operator=(const FrontInsertionSequence::value_type&amp;)
</pre>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Used to implement the <A href="OutputIterator.html">output iterator</A> expression <tt>*i = x</tt>. <A href="#3">[3]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>front_insert_iterator&amp; operator++()</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Preincrement.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>front_insert_iterator&amp; operator++(int)</tt>
</TD>
<TD VAlign=top>
 <A href="OutputIterator.html">Output Iterator</A>
</TD>
<TD VAlign=top>
Postincrement.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
output_iterator_tag 
iterator_category(const front_insert_iterator&amp;)
</pre>
</TD>
<TD VAlign=top>
 <A href="iterator_tags.html">iterator tags</A>
</TD>
<TD VAlign=top>
Returns the iterator's category.
   This is a global function, not a member.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template&lt;class FrontInsertionSequence&gt;
front_insert_iterator&lt;FrontInsertionSequence&gt;
front_inserter(FrontInsertionSequence&amp; S)
</pre>
</TD>
<TD VAlign=top>
<tt>front_insert_iterator</tt>
</TD>
<TD VAlign=top>
See below.
</TD>
</tr>
</table>
<h3>New members.</h3>
These members are not defined 
in the <A href="OutputIterator.html">Output Iterator</A> requirements,
but are specific to <tt>front_insert_iterator</tt>.
<Table border>
<TR>
<TH>
Member
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>front_insert_iterator(FrontInsertionSequence&amp; S)</tt>
</TD>
<TD VAlign=top>
Constructs a <tt>front_insert_iterator</tt> that inserts objects
   before the first element of <tt>S</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template&lt;class FrontInsertionSequence&gt;
front_insert_iterator&lt;FrontInsertionSequence&gt;
front_inserter(FrontInsertionSequence&amp; S);
</pre>
</TD>
<TD VAlign=top>
Equivalent to <tt>front_insert_iterator&lt;FrontInsertionSequence&gt;(S)</tt>. <A href="#4">[4]</A>
   This is a global function, not a member function.
</TD>
</tr>
</table>
<h3>Notes</h3>
<P><A name="1">[1]</A>
Note the difference between assignment through a
<tt><A href="FrontInsertionSequence.html">FrontInsertionSequence</A>::iterator</tt> and assignment through an
<tt>front_insert_iterator&lt;<A href="FrontInsertionSequence.html">FrontInsertionSequence</A>&gt;</tt>.  If <tt>i</tt> is a valid
<tt><A href="FrontInsertionSequence.html">FrontInsertionSequence</A>::iterator</tt>, then it points to some particular
element in the <A href="FrontInsertionSequence.html">front insertion sequence</A>; the expression <tt>*i = t</tt> 
replaces that element with <tt>t</tt>, and does not change the total number
of elements in the sequence.  If <tt>ii</tt> is a valid
<tt>front_insert_iterator&lt;<A href="FrontInsertionSequence.html">FrontInsertionSequence</A>&gt;</tt>, however, then 
the expression <tt>*ii = t</tt> is equivalent, for some <A href="FrontInsertionSequence.html">FrontInsertionSequence</A>
<tt>seq</tt>, to the expression <tt>seq.push_front(t)</tt>.  That is, it does not overwrite
any of <tt>seq</tt>'s elements and it does change <tt>seq</tt>'s size.
<P><A name="2">[2]</A>
Note the difference between a <tt>front_insert_iterator</tt> and an
<tt><A href="insert_iterator.html">insert_iterator</A></tt>.  It may seem that a <tt>front_insert_iterator</tt> is
the same as an <tt><A href="insert_iterator.html">insert_iterator</A></tt> constructed with an insertion
point that is the beginning of a sequence.  In fact, though, there is
a very important difference: <b>every</b> assignment through a
<tt>front_insert_iterator</tt> corresponds to an insertion before the first
element of the sequence.  If you are inserting elements at the
beginning of a sequence using an <tt>insert_iterator</tt>, then the elements
will appear in the order in which they were inserted.  If, however,
you are inserting elements at the beginning of a sequence using a
<tt>front_insert_iterator</tt>, then the elements will appear in the reverse
of the order in which they were inserted.
<P><A name="3">[3]</A>
Note how assignment through an <tt>front_insert_iterator</tt> is implemented.
In general, unary <tt>operator*</tt> must be defined so that it returns a
proxy object, where the proxy object defines <tt>operator=</tt> to perform
the insert operation.  In this case, for the sake of simplicity, the
proxy object is the <tt>front_insert_iterator</tt> itself.  That is, <tt>*i</tt> simply
returns <tt>i</tt>, and <tt>*i = t</tt> is equivalent to <tt>i = t</tt>.  You should not,
however, rely on this behavior.  It is an implementation detail,
and it is not guaranteed to remain the same in future versions.
<P><A name="4">[4]</A>
This function exists solely for the sake of convenience:
since it is a non-member function, the template parameters may be
inferred and the type of the <tt>front_insert_iterator</tt> need not be declared
explicitly.  One easy way to reverse a range and insert it
at the beginning of a <A href="FrontInsertionSequence.html">Front Insertion Sequence</A> <tt>S</tt>, for example, is
<tt><A href="copy.html">copy</A>(first, last, front_inserter(S))</tt>.
<h3>See also</h3>
<A href="insert_iterator.html">insert_iterator</A>, <A href="back_insert_iterator.html" tppabs="http://www.sgi.com/Technology/STL/back_insert_iterator.shtml">back_insert_iterator</A>, <A href="OutputIterator.html" tppabs="http://www.sgi.com/Technology/STL/OutputIterator.shtml">Output Iterator</A>,
<A href="Sequence.html">Sequence</A>, <A href="FrontInsertionSequence.html" tppabs="http://www.sgi.com/Technology/STL/FrontInsertionSequence.shtml">Front Insertion Sequence</A>, <A href="Iterators.html" tppabs="http://www.sgi.com/Technology/STL/Iterators.shtml">Iterator overview</A>

<HR SIZE="6"> <FONT SIZE="-2"> Copyright &copy; 1996 Silicon Graphics, Inc.
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="index.html" >
STL</A></FONT></TD>

<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>&copy; Copyright 1997-1998 CodeGuru</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact : <A HREF="mailto:webmaster@codeguru.com">webmaster@codeguru.com</A>&nbsp;</FONT></DIV>
</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript" ><!--
var adurl = "/cgi-bin/doubleclick.cgi?";

if( self.adcategory )
	adurl += adcategory;
else
	adurl += "mfc";

if( self.parent.norefreshad )
	parent.norefreshad = false;
else if( validframes )
	parent.frames['ad'].location = adurl;



if( !validframes && nfrm == -1)
{
	var dclkPage = "www.codeguru.com/";
	if( self.adcategory )
		dclkPage += adcategory;
	else 
		dclkPage += "mfc";
//	var random = Math.random();
	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>');
}

// -->
</SCRIPT> 
<!-- SCRIPT LANGUAGE="JavaScript" SRC="/global/fscript.js">
//
</SCRIPT --> 

<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupastFCY34AAHiGPwc">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupastFCY34AAHiGPwc"></a>
</p>
</noscript>





</BODY>
</HTML>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -