📄 algorith.html
字号:
void <B><A HREF="#inplace_merge">inplace_merge</A></B>(BidIt first, BidIt mid, BidIt last, Pr pred);template<class InIt1, class InIt2> bool <B><A HREF="#includes">includes</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2);template<class InIt1, class InIt2, class Pr> bool <B><A HREF="#includes">includes</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, Pr pred);template<class InIt1, class InIt2, class OutIt> OutIt <B><A HREF="#set_union">set_union</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest);template<class InIt1, class InIt2, class OutIt, class Pr> OutIt <B><A HREF="#set_union">set_union</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred);template<class InIt1, class InIt2, class OutIt> OutIt <B><A HREF="#set_intersection">set_intersection</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest);template<class InIt1, class InIt2, class OutIt, class Pr> OutIt <B><A HREF="#set_intersection">set_intersection</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred);template<class InIt1, class InIt2, class OutIt> OutIt <B><A HREF="#set_difference">set_difference</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest);template<class InIt1, class InIt2, class OutIt, class Pr> OutIt <B><A HREF="#set_difference">set_difference</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred);template<class InIt1, class InIt2, class OutIt> OutIt <B><A HREF="#set_symmetric_difference">set_symmetric_difference</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest);template<class InIt1, class InIt2, class OutIt, class Pr> OutIt <B><A HREF="#set_symmetric_difference">set_symmetric_difference</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred);template<class RanIt> void <B><A HREF="#push_heap">push_heap</A></B>(RanIt first, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#push_heap">push_heap</A></B>(RanIt first, RanIt last, Pr pred);template<class RanIt> void <B><A HREF="#pop_heap">pop_heap</A></B>(RanIt first, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#pop_heap">pop_heap</A></B>(RanIt first, RanIt last, Pr pred);template<class RanIt> void <B><A HREF="#make_heap">make_heap</A></B>(RanIt first, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#make_heap">make_heap</A></B>(RanIt first, RanIt last, Pr pred);template<class RanIt> void <B><A HREF="#sort_heap">sort_heap</A></B>(RanIt first, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#sort_heap">sort_heap</A></B>(RanIt first, RanIt last, Pr pred);template<class Ty> const Ty& <B><A HREF="#max">max</A></B>(const Ty& left, const Ty& right);template<class Ty, class Pr> const Ty& <B><A HREF="#max">max</A></B>(const Ty& left, const Ty& right, Pr pred);template<class Ty> const Ty& <B><A HREF="#min">min</A></B>(const Ty& left, const Ty& right);template<class Ty, class Pr> const Ty& <B><A HREF="#min">min</A></B>(const Ty& left, const Ty& right, Pr pred);template<class FwdIt> FwdIt <B><A HREF="#max_element">max_element</A></B>(FwdIt first, FwdIt last);template<class FwdIt, class Pr> FwdIt <B><A HREF="#max_element">max_element</A></B>(FwdIt first, FwdIt last, Pr pred);template<class FwdIt> FwdIt <B><A HREF="#min_element">min_element</A></B>(FwdIt first, FwdIt last);template<class FwdIt, class Pr> FwdIt <B><A HREF="#min_element">min_element</A></B>(FwdIt first, FwdIt last, Pr pred);template<class InIt1, class InIt2> bool <B><A HREF="#lexicographical_compare">lexicographical_compare</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2);template<class InIt1, class InIt2, class Pr> bool <B><A HREF="#lexicographical_compare">lexicographical_compare</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, Pr pred);template<class BidIt> bool <B><A HREF="#next_permutation">next_permutation</A></B>(BidIt first, BidIt last);template<class BidIt, class Pr> bool <B><A HREF="#next_permutation">next_permutation</A></B>(BidIt first, BidIt last, Pr pred);template<class BidIt> bool <B><A HREF="#prev_permutation">prev_permutation</A></B>(BidIt first, BidIt last);template<class BidIt, class Pr> bool <B><A HREF="#prev_permutation">prev_permutation</A></B>(BidIt first, BidIt last, Pr pred); };</PRE><H2><A NAME="adjacent_find"><CODE>adjacent_find</CODE></A></H2><PRE>template<class FwdIt> FwdIt <B>adjacent_find</B>(FwdIt first, FwdIt last);template<class FwdIt, class Pr> FwdIt <B>adjacent_find</B>(FwdIt first, FwdIt last, Pr pred);</PRE><P>The first template function determines the lowest <CODE>N</CODE>in the range <CODE>[0, last - first)</CODE> for which<CODE>N + 1 < last - first</CODE> and the predicate<CODE>*(first + N) == *(first + N + 1)</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>first + N</CODE>.If no such value exists, the function returns <CODE>last</CODE>.If the sequence contains fewer than two elements, the functionnever evaluates the predicate. Otherwise, if it returns<CODE>last</CODE>, it evaluates the predicate exactly<CODE>last - first - 1</CODE> times. Otherwise,it evaluates the predicate exactly <CODE>N + 1</CODE> times.</P><P>The second template function behaves the same, except thatthe predicate is <CODE>pred(*(first + N), *(first + N + 1))</CODE>.</P><H2><A NAME="binary_search"><CODE>binary_search</CODE></A></H2><PRE>template<class FwdIt, class Ty> bool <B>binary_search</B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> bool <B>binary_search</B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);</PRE><P>The first template function determines whethera value of <CODE>N</CODE> existsin the range <CODE>[0, last - first)</CODE> for which<CODE>*(first + N)</CODE> has<A HREF="lib_stl.html#equivalent ordering">equivalent ordering</A>to <CODE>val</CODE>, where the elements designated by iteratorsin the range <CODE>[first, last)</CODE> form a sequence<A HREF="lib_stl.html#sequence ordering">ordered by</A> <CODE>operator<</CODE>.If so, the function returns true.If no such value exists, it returns false.</P><P>Yhe function evaluates the ordering predicate <CODE>X < Y</CODE> at most<CODE>ceil(log(last - first)) + 2</CODE> times.</P><P>The second template function behaves the same, except thatit replaces <CODE>operator<(X, Y)</CODE> with<CODE>pred(X, Y)</CODE>.</P><H2><A NAME="copy"><CODE>copy</CODE></A></H2><PRE>template<class InIt, class OutIt> OutIt <B>copy</B>(InIt first, InIt last, OutIt dest);</PRE><P>The template function evaluates <CODE>*(dest + N) = *(first + N))</CODE>once for each <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>,for strictly increasing values of <CODE>N</CODE> beginning withthe lowest value. It then returns <CODE>dest + N</CODE>.If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,<CODE>dest</CODE> must not be in the range <CODE>[first, last)</CODE>.</P><H2><A NAME="copy_backward"><CODE>copy_backward</CODE></A></H2><PRE>template<class BidIt1, class BidIt2> BidIt2 <B>copy_backward</B>(BidIt1 first, BidIt1 last, BidIt2 dest);</PRE><P>The template function evaluates<CODE>*(dest - N - 1) = *(last - N - 1))</CODE> once foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>,for strictly oncreasing values of <CODE>N</CODE> beginning withthe lowest value. It then returns <CODE>dest - (last - first)</CODE>.If <CODE>dest</CODE> and <CODE>first</CODE> designate regions of storage,<CODE>dest</CODE> must not be in the range <CODE>[first, last)</CODE>.</P><H2><A NAME="count"><CODE>count</CODE></A></H2><PRE>template<class InIt, class Ty> typename iterator_traits<InIt>::difference_type <B>count</B>(InIt first, InIt last, const Ty& val);</PRE><P>The template function sets a count <CODE>count</CODE> to zero. It thenexecutes <CODE>++count</CODE> foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>for which the predicate <CODE>*(first + N) == val</CODE> is true.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.The function returns <CODE>count</CODE>.It evaluates the predicate exactly <CODE>last - first</CODE> times.</P><H2><A NAME="count_if"><CODE>count_if</CODE></A></H2><PRE>template<class InIt, class Pr, class Dist> typename iterator_traits<InIt>::difference_type <B>count_if</B>(InIt first, InIt last, Pr pred);</PRE><P>The template function sets a count <CODE>count</CODE> to zero. It thenexecutes <CODE>++count</CODE> foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>for which the predicate <CODE>pred(*(first + N))</CODE> is true.The function returns <CODE>count</CODE>.It evaluates the predicate exactly <CODE>last - first</CODE> times.</P><H2><A NAME="equal"><CODE>equal</CODE></A></H2><PRE>template<class InIt1, class InIt2> bool <B>equal</B>(InIt1 first1, InIt1 last1, InIt2 first2);template<class InIt1, class InIt2, class Pr> bool <B>equal</B>(InIt1 first1, InIt1 last1, InIt2 first2, Pr pred);</PRE><P>The first template function returns true only if, foreach <CODE>N</CODE> in the range <CODE>[0, last1 - first1)</CODE>,the predicate <CODE>*(first1 + N) == *(first2 + N)</CODE> is true.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.The function evaluates the predicate at most oncefor each <CODE>N</CODE>.</P><P>The second template function behaves the same, except thatthe predicate is <CODE>pred(*(first1 + N), *(first2 + N))</CODE>.</P><H2><A NAME="equal_range"><CODE>equal_range</CODE></A></H2><PRE>template<class FwdIt, class Ty> pair<FwdIt, FwdIt> <B>equal_range</B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> pair<FwdIt, FwdIt> <B>equal_range</B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);</PRE><P>The first template function effectively returns<CODE><A HREF="utility.html#pair">pair</A>(<A HREF="#lower_bound">lower_bound</A>(first, last, val),<A HREF="#upper_bound">upper_bound</A>(first, last, val))</CODE>,where the elements designated by iteratorsin the range <CODE>[first, last)</CODE> form a sequence<A HREF="lib_stl.html#sequence ordering">ordered by</A> <CODE>operator<</CODE>.Thus, the function determines the largest range of positionsover which <CODE>val</CODE> can be inserted in the sequenceand still preserve its ordering.</P><P>The function evaluates the ordering predicate <CODE>X < Y</CODE> at most<CODE>ceil(2 * log(last - first)) + 1</CODE>.</P><P>The second template function behaves the same, except thatit replaces <CODE>operator<(X, Y)</CODE> with<CODE>pred(X, Y)</CODE>.</P><H2><A NAME="fill"><CODE>fill</CODE></A></H2><PRE>template<class FwdIt, class Ty> void <B>fill</B>(FwdIt first, FwdIt last, const Ty& val);</PRE><P>The template function evaluates <CODE>*(first + N) = val</CODE> once foreach <CODE>N</CODE> in the range <CODE>[0, last - first)</CODE>.</P><H2><A NAME="fill_n"><CODE>fill_n</CODE></A></H2><PRE>template<class OutIt, class Diff, class Ty> void <B>fill_n</B>(OutIt first, Diff count, const Ty& val);</PRE><P>The template function evaluates <CODE>*(first + N) = val</CODE> once foreach <CODE>N</CODE> in the range <CODE>[0, count)</CODE>.</P><H2><A NAME="find"><CODE>find</CODE></A></H2><PRE>template<class InIt, class Ty> InIt <B>find</B>(InIt first, InIt last, const Ty& val);</PRE><P>The template function determines the lowest value of <CODE>N</CODE>in the range <CODE>[0, last - first)</CODE> for which the predicate<CODE>*(first + N) == val</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>first + N</CODE>.If no such value exists, the function returns <CODE>last</CODE>.It evaluates the predicate at most oncefor each <CODE>N</CODE>.</P><H2><A NAME="find_end"><CODE>find_end</CODE></A></H2><PRE>template<class FwdIt1, class FwdIt2> FwdIt1 <B>find_end</B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2);template<class FwdIt1, class FwdIt2, class Pr> FwdIt1 <B>find_end</B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred);</PRE><P>The first template function determines the highest value of<CODE>N</CODE> in the range <CODE>[0,last1 - first1 - (last2 - first2))</CODE>such that for each <CODE>M</CODE> in the range<CODE>[0, last2 - first2)</CODE>,the predicate <CODE>*(first1 + N + M) == *(first2 + N + M)</CODE> is true.Here, <CODE>operator==</CODE> must perform a<A HREF="lib_stl.html#pairwise comparison">pairwise comparison</A>between its operands.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -