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

📄 algorith.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<CODE>[first, last - 1)</CODE> must designate an existing heap,also ordered by <CODE>operator&lt;</CODE>. Thus, <CODE>first !=last</CODE> must be true and <CODE>*(last - 1)</CODE> is theelement to add to (push on) the heap.</P><P>The function evaluates the ordering predicate<CODE>X &lt; Y</CODE> at most<CODE>ceil(log(last - first))</CODE> times.</P><P>The second template function behaves the same, except thatit replaces <CODE>operator&lt;(X, Y)</CODE> with<CODE>pred(X, Y)</CODE>.</P><H2><A NAME="random_shuffle"><CODE>random_shuffle</CODE></A></H2><PRE>template&lt;class RanIt&gt;    void <B>random_shuffle</B>(RanIt first, RanIt last);template&lt;class RanIt, class Fn1&gt;    void <B>random_shuffle</B>(RanIt first, RanIt last, Fn1&amp; func);</PRE><P>The first template function evaluates<CODE><A HREF="#swap">swap</A>(*(first + N), *(first + M))</CODE> once foreach <CODE>N</CODE> in the range <CODE>[1, last - first)</CODE>,where <CODE>M</CODE> is a value from some uniform random distributionover the range <CODE>[0, N]</CODE>.Thus, the function randomly shufflesthe order of elements in the sequence.</P><P>The function evaluates <CODE>M</CODE> and calls <CODE>swap</CODE>exactly <CODE>last - first - 1</CODE> times.</P><P>The second template function behaves the same, except that<CODE>M</CODE> is <CODE>(Diff)func((Diff)N)</CODE>, where<CODE>Diff</CODE> is the type<CODE><A HREF="iterator.html#iterator_traits">iterator_traits</A>&lt;RanIt&gt;::<A HREF="iterator.html#iterator_traits::difference_type">difference_type</A></CODE>.</P><H2><A NAME="remove"><CODE>remove</CODE></A></H2><PRE>template&lt;class FwdIt, class Ty&gt;    FwdIt <B>remove</B>(FwdIt first, FwdIt last, const Ty&amp; val);</PRE><P>The template function effectively assigns <CODE>first</CODE> to<CODE>X</CODE>, then executes the statement:</P><PRE>if (!(*(first + N) == val))    *X++ = *(first + N);</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.It then returns <CODE>X</CODE>.Thus, the function removes from the resulting sequence all elements forwhich the predicate <CODE>*(first + N) == val</CODE> is true,without altering the relative order of remaining elements,and returns the iterator value that designates the end of theresulting sequence.</P><H2><A NAME="remove_copy"><CODE>remove_copy</CODE></A></H2><PRE>template&lt;class InIt, class OutIt, class Ty&gt;    OutIt <B>remove_copy</B>(InIt first, InIt last, OutIt dest,        const Ty&amp; val);</PRE><P>The template function effectively executes the statement:</P><PRE>if (!(*(first + N) == val))    *dest++ = *(first + N);</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.It then returns <CODE>dest</CODE>.Thus, the function removes from the resulting sequence all elements forwhich the predicate <CODE>*(first + N) == val</CODE> is true,without altering the relative order of remaining elements,and returns the iterator value that designates the end of theresulting sequence.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>.</P><H2><A NAME="remove_copy_if"><CODE>remove_copy_if</CODE></A></H2><PRE>template&lt;class InIt, class OutIt, class Pr&gt;    OutIt <B>remove_copy_if</B>(InIt first, InIt last, OutIt dest,        Pr pred);</PRE><P>The template function effectively executes the statement:</P><PRE>if (!pred(*(first + N)))    *dest++ = *(first + N);</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>. It then returns <CODE>dest</CODE>.Thus, the function removes from the resulting sequence all elements forwhich the predicate <CODE>pred(*(first + N))</CODE> is true,without altering the relative order of remaining elements,and returns the iterator value that designates the end of theresulting sequence.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>.</P><H2><A NAME="remove_if"><CODE>remove_if</CODE></A></H2><PRE>template&lt;class FwdIt, class Pr&gt;    FwdIt <B>remove_if</B>(FwdIt first, FwdIt last, Pr pred);</PRE><P>The template function effectively assigns <CODE>first</CODE> to<CODE>X</CODE>, then executes the statement:</P><PRE>if (!pred(*(first + N)))    *X++ = *(first + N);</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>. It then returns <CODE>X</CODE>.Thus, the function removes from the resulting sequence all elements forwhich the predicate <CODE>pred(*(first + N))</CODE> is true,without altering the relative order of remaining elements,and returns the iterator value that designates the end of theresulting sequence.</P><H2><A NAME="replace"><CODE>replace</CODE></A></H2><PRE>template&lt;class FwdIt, class Ty&gt;    void <B>replace</B>(FwdIt first, FwdIt last,        const Ty&amp; oldval, const Ty&amp; newval);</PRE><P>The template function executes the statement:</P><PRE>if (*(first + N) == oldval)    *(first + N) = newval;</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.</P><H2><A NAME="replace_copy"><CODE>replace_copy</CODE></A></H2><PRE>template&lt;class InIt, class OutIt, class Ty&gt;    OutIt <B>replace_copy</B>(InIt first, InIt last, OutIt dest,        const Ty&amp; oldval, const Ty&amp; newval);</PRE><P>The template function executes the statement:</P><PRE>if (*(first + N) == oldval)    *(dest + N) = newval;else    *(dest + N) = *(first + N)</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands. The function returns the iterator value thatdesignates the end of the resulting sequence.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>.</P><H2><A NAME="replace_copy_if"><CODE>replace_copy_if</CODE></A></H2><PRE>template&lt;class InIt, class OutIt, class Pr, class Ty&gt;    OutIt <B>replace_copy_if</B>(InIt first, InIt last, OutIt dest,        Pr pred, const Ty&amp; val);</PRE><P>The template function executes the statement:</P><PRE>if (pred(*(first + N)))    *(dest + N) = val;else    *(dest + N) = *(first + N)</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>. The function returns the iteratorvalue that designates the end of the resulting sequence.</P><H2><A NAME="replace_if"><CODE>replace_if</CODE></A></H2><PRE>template&lt;class FwdIt, class Pr, class Ty&gt;    void <B>replace_if</B>(FwdIt first, FwdIt last,        Pr pred, const Ty&amp; val);</PRE><P>The template function executes the statement:</P><PRE>if (pred(*(first + N)))    *(first + N) = val;</PRE><P>once for each <CODE>N</CODE> in the range<CODE>[0, last - first)</CODE>.</P><H2><A NAME="reverse"><CODE>reverse</CODE></A></H2><PRE>template&lt;class BidIt&gt;    void <B>reverse</B>(BidIt first, BidIt last);</PRE><P>The template function evaluates<CODE><A HREF="#swap">swap</A>(*(first + N), *(last - 1 - N)</CODE> once foreach <CODE>N</CODE> in the range <CODE>[0, (last - first) / 2)</CODE>.Thus, the function reverses the order of elements in the sequence.</P><H2><A NAME="reverse_copy"><CODE>reverse_copy</CODE></A></H2><PRE>template&lt;class BidIt, class OutIt&gt;    OutIt <B>reverse_copy</B>(BidIt first, BidIt last, OutIt dest);</PRE><P>The template function evaluates<CODE>*(dest + N) = *(last - 1 - N)</CODE> once foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>.It then returns <CODE>dest + (last - first)</CODE>.Thus, the function reverses the order of elements in the sequencethat it copies.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>.</P><H2><A NAME="rotate"><CODE>rotate</CODE></A></H2><PRE>template&lt;class FwdIt&gt;    void <B>rotate</B>(FwdIt first, FwdIt mid, FwdIt last);</PRE><P>The template function leaves the value originally stored in<CODE>*(first + (N + (mid - first)) % (last - first))</CODE>subsequently stored in <CODE>*(first + N)</CODE> foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>.Thus, if a ``left'' shift by one element leaves the elementoriginally stored in <CODE>*(first + (N + 1) % (last - first))</CODE>subsequently stored in <CODE>*(first + N)</CODE>, then the functioncan be said to rotate the sequence either left by<CODE>mid - first</CODE> elements or right by <CODE>last - mid</CODE>elements. Both <CODE>[first, mid)</CODE> and <CODE>[mid, last)</CODE>must be valid ranges. The function swaps at most <CODE>last - first</CODE>pairs of elements.</P><H2><A NAME="rotate_copy"><CODE>rotate_copy</CODE></A></H2><PRE>template&lt;class FwdIt, class OutIt&gt;    OutIt <B>rotate_copy</B>(FwdIt first, FwdIt mid,        FwdIt last, OutIt dest);</PRE><P>The template function evaluates<CODE>*(dest + N) = *(first + (N + (mid - first)) % (last - first))</CODE>once for each <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>.Thus, if a ``left'' shift by one element leaves the elementoriginally stored in <CODE>*(first + (N + 1) % (last - first))</CODE>subsequently stored in <CODE>*(first + N)</CODE>, then the functioncan be said to rotate the sequence either left by<CODE>mid - first</CODE> elements or right by <CODE>last - mid</CODE>elements as it copies.Both <CODE>[first, mid)</CODE> and <CODE>[mid, last)</CODE>must be valid ranges. The function returns the iterator valuethat designates the end of the resulting sequence.</P><P>If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,the range <CODE>[dest, dest + (last - first))</CODE> must notoverlap the range <CODE>[first, last)</CODE>.</P><H2><A NAME="search"><CODE>search</CODE></A></H2><PRE>template&lt;class FwdIt1, class FwdIt2&gt;    FwdIt1 <B>search</B>(FwdIt1 first1, FwdIt1 last1,        FwdIt2 first2, FwdIt2 last2);template&lt;class FwdIt1, class FwdIt2, class Pr&gt;    FwdIt1 <B>search</B>(FwdIt1 first1, FwdIt1 last1,        FwdIt2 first2, FwdIt2 last2, Pr pred);</PRE><P>The first template function determines the lowest value of<CODE>N</CODE> in the range <CODE>[0,(last1 - first1) - (last2 - first2))</CODE> such thatfor each <CODE>M</CODE> in the range <CODE>[0, last2 - first2)</CODE>,the predicate <CODE>*(first1 + N + M) == *(first2 + M)</CODE> is true.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.It then returns <CODE>first1 + N</CODE>.If no such value exists, the function 

⌨️ 快捷键说明

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