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

📄 copy_n.html

📁 ISO_C++:C++_STL开发文档
💻 HTML
字号:
<HTML><!--  -- Copyright (c) 1996-1999  -- Silicon Graphics Computer Systems, Inc.  --  -- Permission to use, copy, modify, distribute and sell this software  -- and its documentation for any purpose is hereby granted without fee,  -- provided that the above copyright notice appears in all copies and  -- that both that copyright notice and this permission notice appear  -- in supporting documentation.  Silicon Graphics makes no  -- representations about the suitability of this software for any  -- purpose.  It is provided "as is" without express or implied warranty.  --  -- Copyright (c) 1994  -- Hewlett-Packard Company  --  -- Permission to use, copy, modify, distribute and sell this software  -- and its documentation for any purpose is hereby granted without fee,  -- provided that the above copyright notice appears in all copies and  -- that both that copyright notice and this permission notice appear  -- in supporting documentation.  Hewlett-Packard Company makes no  -- representations about the suitability of this software for any  -- purpose.  It is provided "as is" without express or implied warranty.  --  --><Head><Title>copy_n</Title><!-- Generated by htmldoc --></HEAD><BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 	ALINK="#ff0000"> <IMG SRC="CorpID.gif"      ALT="SGI" HEIGHT="43" WIDTH="151"> <!--end header--><BR Clear><H1>copy_n</H1><Table CellPadding=0 CellSpacing=0 width=100%><TR><TD Align=left><Img src = "algorithms.gif" Alt=""   WIDTH = "194"  HEIGHT = "38" ></TD><TD Align=right><Img src = "function.gif" Alt=""   WIDTH = "194"  HEIGHT = "38" ></TD></TR><TR><TD Align=left VAlign=top><b>Category</b>: algorithms</TD><TD Align=right VAlign=top><b>Component type</b>: function</TD></TR></Table><h3>Prototype</h3><pre>template &lt;class <A href="InputIterator.html">InputIterator</A>, class Size, class <A href="OutputIterator.html">OutputIterator</A>&gt;OutputIterator copy_n(InputIterator first, Size count,                       OutputIterator result);</pre>                   <h3>Description</h3><tt>Copy_n</tt> copies elements from the range <tt>[first, first + n)</tt> to therange <tt>[result, result + n)</tt>.  That is, it performs the assignments<tt>*result = *first</tt>, <tt>*(result + 1) = *(first + 1)</tt>, and so on.Generally, for every integer <tt>i</tt> from <tt>0</tt> up to (but not including)<tt>n</tt>, <tt>copy_n</tt> performs the assignment <tt>*(result + i) = *(first + i)</tt>.Assignments are performed in forward order, <i>i.e.</i> in order ofincreasing <tt>n</tt>. <A href="#1">[1]</A><P>The return value is <tt>result + n</tt>.<h3>Definition</h3>Defined in the standard header <A href="algorithm">algorithm</A>, and in the nonstandardbackward-compatibility header <A href="algo.h">algo.h</A>.  This function is an SGIextension; it is not part of the C++ standard.<h3>Requirements on types</h3><UL><LI>InputIterator is a model of <A href="InputIterator.html">Input Iterator</A>.<LI>OutputIterator is a model of <A href="OutputIterator.html">Output Iterator</A>.<LI><tt>Size</tt> is an integral type.<LI>InputIterator's value type is convertible to a type in   OutputIterator's set of value types.</UL><h3>Preconditions</h3><UL><LI><tt>n &gt;= 0</tt>.<LI><tt>[first, first + n)</tt> is a valid range.<LI><tt>result</tt> is not an iterator within the range <tt>[first, first + n)</tt>.<LI><tt>[result, result + n)</tt> is a valid range.</UL><h3>Complexity</h3>Linear.  Exactly <tt>n</tt> assignments are performed.<h3>Example</h3><pre><A href="Vector.html">vector</A>&lt;int&gt; V(5);<A href="iota.html">iota</A>(V.begin(), V.end(), 1);<A href="List.html">list</A>&lt;int&gt; L(V.size());copy_n(V.begin(), V.size(), L.begin());assert(<A href="equal.html">equal</A>(V.begin(), V.end(), L.begin()));</pre><h3>Notes</h3><P><A name="1">[1]</A><tt>Copy_n</tt> is almost, but not quite, redundant.  If <tt>first</tt> is an <A href="InputIterator.html">input iterator</A>, as opposed to a <A href="ForwardIterator.html">forward iterator</A>, then the <tt>copy_n</tt> operation can't be expressed in terms of <tt><A href="copy.html">copy</A></tt>.<h3>See also</h3><tt><A href="copy.html">copy</A></tt>, <tt><A href="copy_backward.html">copy_backward</A></tt><!--start footer--> <HR SIZE="6"><A href="http://www.sgi.com/"><IMG SRC="surf.gif" HEIGHT="54" WIDTH="54"         ALT="[Silicon Surf]"></A><A HREF="index.html"><IMG SRC="stl_home.gif"         HEIGHT="54" WIDTH="54" ALT="[STL Home]"></A><BR><FONT SIZE="-2"><A href="http://www.sgi.com/Misc/sgi_info.html" TARGET="_top">Copyright &copy; 1999 Silicon Graphics, Inc.</A> All Rights Reserved.</FONT><FONT SIZE="-3"><a href="http://www.sgi.com/Misc/external.list.html" TARGET="_top">TrademarkInformation</A></FONT><P></BODY></HTML> 

⌨️ 快捷键说明

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