📄 algorith.html
字号:
<HTML><HEAD><TITLE><algorithm></TITLE></HEAD><BODY><H1><A NAME="<algorithm>"><CODE><algorithm></CODE></A></H1><HR><P><B><CODE><A HREF="#adjacent_find">adjacent_find</A>· <A HREF="#binary_search">binary_search</A>· <A HREF="#copy">copy</A>· <A HREF="#copy_backward">copy_backward</A>· <A HREF="#count">count</A>· <A HREF="#count_if">count_if</A>· <A HREF="#equal">equal</A>· <A HREF="#equal_range">equal_range</A>· <A HREF="#fill">fill</A>· <A HREF="#fill_n">fill_n</A>· <A HREF="#find">find</A>· <A HREF="#find_end">find_end</A>· <A HREF="#find_first_of">find_first_of</A>· <A HREF="#find_if">find_if</A>· <A HREF="#for_each">for_each</A>· <A HREF="#generate">generate</A>· <A HREF="#generate_n">generate_n</A>· <A HREF="#includes">includes</A>· <A HREF="#inplace_merge">inplace_merge</A>· <A HREF="#iter_swap">iter_swap</A>· <A HREF="#lexicographical_compare">lexicographical_compare</A>· <A HREF="#lower_bound">lower_bound</A>· <A HREF="#make_heap">make_heap</A>· <A HREF="#max">max</A>· <A HREF="#max_element">max_element</A>· <A HREF="#merge">merge</A>· <A HREF="#min">min</A>· <A HREF="#min_element">min_element</A>· <A HREF="#mismatch">mismatch</A>· <A HREF="#next_permutation">next_permutation</A>· <A HREF="#nth_element">nth_element</A>· <A HREF="#partial_sort">partial_sort</A>· <A HREF="#partial_sort_copy">partial_sort_copy</A>· <A HREF="#partition">partition</A>· <A HREF="#pop_heap">pop_heap</A>· <A HREF="#prev_permutation">prev_permutation</A>· <A HREF="#push_heap">push_heap</A>· <A HREF="#random_shuffle">random_shuffle</A>· <A HREF="#remove">remove</A>· <A HREF="#remove_copy">remove_copy</A>· <A HREF="#remove_copy_if">remove_copy_if</A>· <A HREF="#remove_if">remove_if</A>· <A HREF="#replace">replace</A>· <A HREF="#replace_copy">replace_copy</A>· <A HREF="#replace_copy_if">replace_copy_if</A>· <A HREF="#replace_if">replace_if</A>· <A HREF="#reverse">reverse</A>· <A HREF="#reverse_copy">reverse_copy</A>· <A HREF="#rotate">rotate</A>· <A HREF="#rotate_copy">rotate_copy</A>· <A HREF="#search">search</A>· <A HREF="#search_n">search_n</A>· <A HREF="#set_difference">set_difference</A>· <A HREF="#set_intersection">set_intersection</A>· <A HREF="#set_symmetric_difference">set_symmetric_difference</A>· <A HREF="#set_union">set_union</A>· <A HREF="#sort">sort</A>· <A HREF="#sort_heap">sort_heap</A>· <A HREF="#stable_partition">stable_partition</A>· <A HREF="#stable_sort">stable_sort</A>· <A HREF="#swap">swap</A>· <A HREF="#swap_ranges">swap_ranges</A>· <A HREF="#transform">transform</A>· <A HREF="#unique">unique</A>· <A HREF="#unique_copy">unique_copy</A>· <A HREF="#upper_bound">upper_bound</A></CODE></B></P><HR><P>Include the <A HREF="index.html#STL">STL</A>standard header <B><CODE><algorithm></CODE></B>to define numerous template functions that performuseful algorithms. The descriptions that followmake extensive use of common template parameter names(or prefixes) to indicate the least powerful categoryof iterator permitted as an actual argument type:</P><UL><LI><B><CODE><A HREF="lib_stl.html#OutIt">OutIt</A></CODE></B> --to indicate an output iterator</LI><LI><B><CODE><A HREF="lib_stl.html#InIt">InIt</A></CODE></B> --to indicate an input iterator</LI><LI><B><CODE><A HREF="lib_stl.html#FwdIt">FwdIt</A></CODE></B> --to indicate a forward iterator</LI><LI><B><CODE><A HREF="lib_stl.html#BidIt">BidIt</A></CODE></B> --to indicate a bidirectional iterator</LI><LI><B><CODE><A HREF="lib_stl.html#RanIt">RanIt</A></CODE></B> --to indicate a random-access iterator</LI></UL><P>The descriptions of these templates employ a number of<A HREF="lib_stl.html#Algorithm Conventions">conventions</A>common to all algorithms.</P><PRE>namespace std {template<class InIt, class Fn1> Fn1 <B><A HREF="#for_each">for_each</A></B>(InIt first, InIt last, Fn1 func);template<class InIt, class Ty> InIt <B><A HREF="#find">find</A></B>(InIt first, InIt last, const Ty& val);template<class InIt, class Pr> InIt <B><A HREF="#find_if">find_if</A></B>(InIt first, InIt last, Pr pred);template<class FwdIt1, class FwdIt2> FwdIt1 <B><A HREF="#find_end">find_end</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2);template<class FwdIt1, class FwdIt2, class Pr> FwdIt1 <B><A HREF="#find_end">find_end</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred);template<class FwdIt1, class FwdIt2> FwdIt1 <B><A HREF="#find_first_of">find_first_of</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2);template<class FwdIt1, class FwdIt2, class Pr> FwdIt1 <B><A HREF="#find_first_of">find_first_of</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred);template<class FwdIt> FwdIt <B><A HREF="#adjacent_find">adjacent_find</A></B>(FwdIt first, FwdIt last);template<class FwdIt, class Pr> FwdIt <B><A HREF="#adjacent_find">adjacent_find</A></B>(FwdIt first, FwdIt last, Pr pred);template<class InIt, class Ty, class Dist> typename iterator_traits<InIt>::difference_type <B><A HREF="#count">count</A></B>(InIt first, InIt last, const Ty& val);template<class InIt, class Pr, class Dist> typename iterator_traits<InIt>::difference_type <B><A HREF="#count_if">count_if</A></B>(InIt first, InIt last, Pr pred);template<class InIt1, class InIt2> pair<InIt1, InIt2> <B><A HREF="#mismatch">mismatch</A></B>(InIt1 first1, InIt1 last1, InIt2 first2);template<class InIt1, class InIt2, class Pr> pair<InIt1, InIt2> <B><A HREF="#mismatch">mismatch</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, Pr pred);template<class InIt1, class InIt2> bool <B><A HREF="#equal">equal</A></B>(InIt1 first1, InIt1 last1, InIt2 first2);template<class InIt1, class InIt2, class Pr> bool <B><A HREF="#equal">equal</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, Pr pred);template<class FwdIt1, class FwdIt2> FwdIt1 <B><A HREF="#search">search</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2);template<class FwdIt1, class FwdIt2, class Pr> FwdIt1 <B><A HREF="#search">search</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 first2, FwdIt2 last2, Pr pred);template<class FwdIt1, class Diff2, class Ty> FwdIt1 <B><A HREF="#search_n">search_n</A></B>(FwdIt1 first1, FwdIt1 last1, Diff2 count, const Ty& val);template<class FwdIt1, class Diff2, class Ty, class Pr> FwdIt1 <B><A HREF="#search_n">search_n</A></B>(FwdIt1 first1, FwdIt1 last1, Diff2 count, const Ty& val, Pr pred);template<class InIt, class OutIt> OutIt <B><A HREF="#copy">copy</A></B>(InIt first, InIt last, OutIt dest);template<class BidIt1, class BidIt2> BidIt2 <B><A HREF="#copy_backward">copy_backward</A></B>(BidIt1 first, BidIt1 last, BidIt2 dest);template<class Ty> void <B><A HREF="#swap">swap</A></B>(Ty& left, Ty& right);template<class FwdIt1, class FwdIt2> FwdIt2 <B><A HREF="#swap_ranges">swap_ranges</A></B>(FwdIt1 first1, FwdIt1 last1, FwdIt2 last2);template<class FwdIt1, class FwdIt2> void <B><A HREF="#iter_swap">iter_swap</A></B>(FwdIt1 left, FwdIt2 right);template<class InIt, class OutIt, class Fn1> OutIt <B><A HREF="#transform">transform</A></B>(InIt first, InIt last, OutIt dest, Fn1 func);template<class InIt1, class InIt2, class OutIt, class Fn2> OutIt <B><A HREF="#transform">transform</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, OutIt dest, Fn2 func);</PRE><PRE>template<class FwdIt, class Ty> void <B><A HREF="#replace">replace</A></B>(FwdIt first, FwdIt last, const Ty& oldval, const Ty& newval);template<class FwdIt, class Pr, class Ty> void <B><A HREF="#replace_if">replace_if</A></B>(FwdIt first, FwdIt last, Pr pred, const Ty& val);template<class InIt, class OutIt, class Ty> OutIt <B><A HREF="#replace_copy">replace_copy</A></B>(InIt first, InIt last, OutIt dest, const Ty& oldval, const Ty& newval);template<class InIt, class OutIt, class Pr, class Ty> OutIt <B><A HREF="#replace_copy_if">replace_copy_if</A></B>(InIt first, InIt last, OutIt dest, Pr pred, const Ty& val);template<class FwdIt, class Ty> void <B><A HREF="#fill">fill</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class OutIt, class Diff, class Ty> void <B><A HREF="#fill_n">fill_n</A></B>(OutIt first, Diff count, const Ty& val);template<class FwdIt, class Fn0> void <B><A HREF="#generate">generate</A></B>(FwdIt first, FwdIt last, Fn0 func);template<class OutIt, class Diff, class Fn0> void <B><A HREF="#generate_n">generate_n</A></B>(OutIt first, Diff count, Fn0 func);template<class FwdIt, class Ty> FwdIt <B><A HREF="#remove">remove</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Pr> FwdIt <B><A HREF="#remove_if">remove_if</A></B>(FwdIt first, FwdIt last, Pr pred);template<class InIt, class OutIt, class Ty> OutIt <B><A HREF="#remove_copy">remove_copy</A></B>(InIt first, InIt last, OutIt dest, const Ty& val);template<class InIt, class OutIt, class Pr> OutIt <B><A HREF="#remove_copy_if">remove_copy_if</A></B>(InIt first, InIt last, OutIt dest, Pr pred);template<class FwdIt> FwdIt <B><A HREF="#unique">unique</A></B>(FwdIt first, FwdIt last);template<class FwdIt, class Pr> FwdIt <B><A HREF="#unique">unique</A></B>(FwdIt first, FwdIt last, Pr pred);template<class InIt, class OutIt> OutIt <B><A HREF="#unique_copy">unique_copy</A></B>(InIt first, InIt last, OutIt dest);template<class InIt, class OutIt, class Pr> OutIt <B><A HREF="#unique_copy">unique_copy</A></B>(InIt first, InIt last, OutIt dest, Pr pred);template<class BidIt> void <B><A HREF="#reverse">reverse</A></B>(BidIt first, BidIt last);template<class BidIt, class OutIt> OutIt <B><A HREF="#reverse_copy">reverse_copy</A></B>(BidIt first, BidIt last, OutIt dest);template<class FwdIt> void <B><A HREF="#rotate">rotate</A></B>(FwdIt first, FwdIt mid, FwdIt last);template<class FwdIt, class OutIt> OutIt <B><A HREF="#rotate_copy">rotate_copy</A></B>(FwdIt first, FwdIt mid, FwdIt last, OutIt dest);template<class RanIt> void <B><A HREF="#random_shuffle">random_shuffle</A></B>(RanIt first, RanIt last);template<class RanIt, class Fn1> void <B><A HREF="#random_shuffle">random_shuffle</A></B>(RanIt first, RanIt last, Fn1& func);template<class BidIt, class Pr> BidIt <B><A HREF="#partition">partition</A></B>(BidIt first, BidIt last, Pr pred);template<class BidIt, class Pr> BidIt <B><A HREF="#stable_partition">stable_partition</A></B>(BidIt first, BidIt last, Pr pred);template<class RanIt> void <B><A HREF="#sort">sort</A></B>(RanIt first, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#sort">sort</A></B>(RanIt first, RanIt last, Pr pred);template<class BidIt> void <B><A HREF="#stable_sort">stable_sort</A></B>(BidIt first, BidIt last);template<class BidIt, class Pr> void <B><A HREF="#stable_sort">stable_sort</A></B>(BidIt first, BidIt last, Pr pred);template<class RanIt> void <B><A HREF="#partial_sort">partial_sort</A></B>(RanIt first, RanIt mid, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#partial_sort">partial_sort</A></B>(RanIt first, RanIt mid, RanIt last, Pr pred);template<class InIt, class RanIt> RanIt <B><A HREF="#partial_sort_copy">partial_sort_copy</A></B>(InIt first1, InIt last1, RanIt first2, RanIt last2);template<class InIt, class RanIt, class Pr> RanIt <B><A HREF="#partial_sort_copy">partial_sort_copy</A></B>(InIt first1, InIt last1, RanIt first2, RanIt last2, Pr pred);</PRE><PRE>template<class RanIt> void <B><A HREF="#nth_element">nth_element</A></B>(RanIt first, RanIt nth, RanIt last);template<class RanIt, class Pr> void <B><A HREF="#nth_element">nth_element</A></B>(RanIt first, RanIt nth, RanIt last, Pr pred);template<class FwdIt, class Ty> FwdIt <B><A HREF="#lower_bound">lower_bound</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> FwdIt <B><A HREF="#lower_bound">lower_bound</A></B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);template<class FwdIt, class Ty> FwdIt <B><A HREF="#upper_bound">upper_bound</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> FwdIt <B><A HREF="#upper_bound">upper_bound</A></B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);template<class FwdIt, class Ty> pair<FwdIt, FwdIt> <B><A HREF="#equal_range">equal_range</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> pair<FwdIt, FwdIt> <B><A HREF="#equal_range">equal_range</A></B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);template<class FwdIt, class Ty> bool <B><A HREF="#binary_search">binary_search</A></B>(FwdIt first, FwdIt last, const Ty& val);template<class FwdIt, class Ty, class Pr> bool <B><A HREF="#binary_search">binary_search</A></B>(FwdIt first, FwdIt last, const Ty& val, Pr pred);template<class InIt1, class InIt2, class OutIt> OutIt <B><A HREF="#merge">merge</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="#merge">merge</A></B>(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest, Pr pred);template<class BidIt> void <B><A HREF="#inplace_merge">inplace_merge</A></B>(BidIt first, BidIt mid, BidIt last);template<class BidIt, class Pr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -