STL 算法
STL 算法的一些演示例子及一些细节解释
coderguang
个人主页:www.royalchen.com
展开
-
STL algorithm算法集合
algorithm意为"演算法",是C++的标准模版库(STL)中最重要的头文件之一,提供了大量基于迭代器的非成员模版函数。编程语言C++类 别C++标准库头文件#include 命名空间using namespace std;目录转载 2014-09-26 20:45:05 · 2581 阅读 · 0 评论 -
STL algorithm算法unique,unique_copy(58)
unique原型:删除指定范围中的所有连续重复元素,仅仅留下每组等值元素中的第一个元素原创 2014-09-26 20:40:03 · 1946 阅读 · 0 评论 -
STL algorithm算法transform(57)
transform原型:std::transformunary operation(1)template OutputIterator transform (InputIterator first1, InputIterator last1, OutputIterator result, Un原创 2014-09-26 19:29:15 · 1416 阅读 · 0 评论 -
STL algorithm算法swap,swap_ranges(56)
swap原型:std::swapC++98C++11header// moved from to in C++11non-array (1)template void swap (T& a, T& b) noexcept (is_nothrow_move_constructible::v原创 2014-09-26 10:51:47 · 1514 阅读 · 0 评论 -
STL algorithm算法sort,stable_sort(55)
sort原型:std::sortdefault (1)template void sort (RandomAccessIterator first, RandomAccessIterator last);custom (2)template void sort (RandomAccessIterator firs原创 2014-09-26 10:24:35 · 1965 阅读 · 1 评论 -
STL algorithm算法set_symmetric_difference,set_union(54)
set_symmetric_difference原型:std::set_symmetric_differencedefault (1)template OutputIterator set_symmetric_difference (InputIterator1 first1, InputIterator1 last1,原创 2014-09-26 10:10:52 · 1972 阅读 · 0 评论 -
STL algorithm算法set_difference,set_intersection(53)
set_difference原型:std::set_differencedefault (1)template OutputIterator set_difference (InputIterator1 first1, InputIterator1 last1, InputItera原创 2014-09-26 09:46:04 · 2728 阅读 · 0 评论 -
STL algorithm算法search,search_n(52)
search原型:std::searchequality (1)template ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, Forwar原创 2014-09-26 09:27:50 · 1699 阅读 · 0 评论 -
STL algorithm算法rotate,rotate_copy(51)
rotate原型:std::rotateC++98C++11template ForwardIterator rotate (ForwardIterator first, ForwardIterator middle, ForwardIterator last);该函数是循环移原创 2014-09-26 08:31:46 · 2278 阅读 · 0 评论 -
STL algorithm算法reverse,reverse_copy(50)
reverse原型:std::reversetemplate void reverse (BidirectionalIterator first, BidirectionalIterator last);反转范围内的元素。行为类似于:template void reverse (BidirectionalIterator first, BidirectionalItera原创 2014-09-25 11:07:33 · 1758 阅读 · 0 评论 -
STL algorithm算法replace,replace_if和replace_copy,replace_copy_if(49)
replace原型:std::replacetemplate void replace (ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);将范围内的某个值替换成一个新值。行为类似于:template原创 2014-09-25 10:53:12 · 2307 阅读 · 0 评论 -
STL algorithm算法remove_copy,remove_copy_if(48)
remove_copy原型:std::remove_copytemplate OutputIterator remove_copy (InputIterator first, InputIterator last, OutputIterator result, const T& val);该函数是将范围[first,las原创 2014-09-25 10:15:50 · 1824 阅读 · 0 评论 -
STL algorithm算法remonve,remove_if(47)
rmove原型:std::removetemplate ForwardIterator remove (ForwardIterator first, ForwardIterator last, const T& val);查找的得到第一个元素的位置,然后从此位置开始遍历容器,将后面的元素依次前移,跳过和value相同值的元素,也就是说,所有和value相同原创 2014-09-25 09:55:46 · 2021 阅读 · 0 评论 -
STL algorithm算法shuffle , random_shuffle(46)
shuffle原型:template void shuffle (RandomAccessIterator first, RandomAccessIterator last, URNG&& g);原创 2014-09-22 16:54:57 · 4246 阅读 · 0 评论 -
STL algorithm算法pop_heap,push_heap(45)
pop_heap原型:std::pop_heapdefault (1)template void pop_heap (RandomAccessIterator first, RandomAccessIterator last);custom (2)template void pop_heap (RandomAcc原创 2014-09-22 16:14:31 · 2813 阅读 · 0 评论 -
STL algorithm算法partition_point,stable_partition(44)
partition_point原型:std::partition_pointtemplate ForwardIterator partition_point (ForwardIterator first, ForwardIterator last, UnaryPredicate pred);该函原创 2014-09-22 15:26:44 · 1877 阅读 · 0 评论 -
STL algorithm算法partition, partition_copy(43)
partition原型:td::partitionC++98C++11template ForwardIterator partition (ForwardIterator first, ForwardIterator last, UnaryPredicate pred);原创 2014-09-22 14:58:56 · 2730 阅读 · 0 评论 -
STL algorithm算法partial_sort,partial_sort_copy(42)
partial_sort原型:std::partial_sortdefault (1)template void partial_sort (RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last)原创 2014-09-22 14:30:53 · 2585 阅读 · 0 评论 -
STL algorithm算法nth_elements(41)
nth_element原型:std::nth_elementdefault (1)template void nth_element (RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);原创 2014-09-22 10:26:19 · 1374 阅读 · 0 评论 -
STL algorithm算法none_of(40)
none_of原型:std::none_oftemplate bool none_of (InputIterator first, InputIterator last, UnaryPredicate pred);该函数是当范围内的元素均原创 2014-09-19 10:18:15 · 1402 阅读 · 0 评论 -
STL algorithm算法next_permutation,prev_permutation(39)
next_permutation原型:std::next_permutationdefault (1)template bool next_permutation (BidirectionalIterator first, BidirectionalIterator last);原创 2014-09-19 10:08:51 · 1352 阅读 · 0 评论 -
STL algorithm算法mov,move_backward(38)
move原型:std::movetemplate OutputIterator move (InputIterator first, InputIterator last, OutputIterator result);该函数是将指定范围内的元素移动到从result开始的位置。move之后,[first,last)范围内的元素去留的具体实现由编译器决定。原创 2014-09-19 09:47:37 · 1798 阅读 · 0 评论 -
STL algorithm算法mismatch(37)
mismatch原型:std::mismatchequality (1)template pair mismatch (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);predicate (2)t原创 2014-09-19 09:16:29 · 1722 阅读 · 0 评论 -
STL algorithm算法minmax,minmax_element(36)
minmax原型:std::minmaxC++11C++14default (1)template pair minmax (const T& a, const T& b);custom (2)template pair minmax (const T& a, const T& b原创 2014-09-18 01:29:07 · 7402 阅读 · 3 评论 -
STL algorithm算法min,min_element(35)
min原型:std::minC++98C++11C++14default (1)template const T& min (const T& a, const T& b);custom (2)template const T& min (const T& a, const T& b,原创 2014-09-17 19:26:27 · 8709 阅读 · 0 评论 -
STL algorithm算法merge(34)
merge原型:std::mergedefault (1)template OutputIterator merge (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,原创 2014-09-17 19:01:00 · 5366 阅读 · 0 评论 -
STL algorithm源码:stl_algo.h
// Algorithm implementation -*- C++ -*-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,// 2010, 2011// Free Software Foundation, Inc.//// This file is part of the GNU ISO C原创 2014-09-17 18:51:15 · 6671 阅读 · 0 评论 -
STL algorithm算法max,max_elements(33)
max原型:原创 2014-09-17 18:26:29 · 14609 阅读 · 0 评论 -
STL algorithm算法make_heap和sort_heap(32)
make_heap原型:std::make_heapdefault (1)template void make_heap (RandomAccessIterator first, RandomAccessIterator last);custom (2)template void make_heap (Rando原创 2014-09-17 17:29:13 · 10262 阅读 · 0 评论 -
STL algorithm算法lower_bound和upper_bound(31)
lower_bound原型:function templatestd::lower_bounddefault (1)template ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last,原创 2014-09-17 11:04:13 · 7745 阅读 · 0 评论 -
STL algorithm算法lexicographical_compare(30)
lexicographical_compare原型:std::lexicographical_comparedefault (1)template bool lexicographical_compare (InputIterator1 first1, InputIterator1 last1,原创 2014-09-17 10:28:04 · 6153 阅读 · 0 评论 -
STL algorihtm算法iter_swap(29)
iter_swap原型:std::iter_swaptemplate void iter_swap (ForwardIterator1 a, ForwardIterator2 b);原创 2014-09-17 10:04:44 · 4641 阅读 · 0 评论 -
STL algorithm算法is_sorted和is_sorted_until(28)
is_sort的原型:::is_sorteddefault (1)template bool is_sorted (ForwardIterator first, ForwardIterator last);custom (2)template bool is_sorted (ForwardIterator fir原创 2014-09-17 09:53:42 · 7488 阅读 · 0 评论 -
STL algorithm算法is_permutation(27)
is_permutation原型:std::is_permutationequality (1)template bool is_permutation (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2原创 2014-09-17 09:28:04 · 6539 阅读 · 0 评论 -
STL algorithm算法is_partitioned(26)
is_partitioned原型:原创 2014-09-16 22:16:01 · 5446 阅读 · 0 评论 -
STL algorithm算法is_heap和is_heap_until(25)
is_heap原型:std::is_heapdefault (1)template bool is_heap (RandomAccessIterator first, RandomAccessIterator last);custom (2)template bool is_heap (RandomAccessI原创 2014-09-16 16:02:04 · 5824 阅读 · 0 评论 -
STL algorithm算法inplace_merge(24)
inplace_merge原型:std::inplace_mergedefault (1)template void inplace_merge (BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterato原创 2014-09-16 14:43:45 · 6492 阅读 · 0 评论 -
STL algorithm算法for_each(21)
原文地址:http://www.cplusplus.com/reference/algorithm/for_each/function templatestd::for_eachtemplate Function for_each (InputIterator first, InputIterator last, Function fn);A原创 2014-09-13 14:27:05 · 4902 阅读 · 0 评论 -
STL algorithm算法includes(23)
includes原型:std::includestemplate bool includes ( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2 );template bool includes (原创 2014-09-16 14:18:34 · 5596 阅读 · 0 评论 -
STL algorithm算法generate和generate_n(22)
今后的stl算法部分就不贴cpluplus的原文了,简要的介绍为主。generate原型:std::generatetemplate void generate (ForwardIterator first, ForwardIterator last, Generator gen);该函数是使用gen函数产生的值填充范围内元素的值。其行为类似如原创 2014-09-13 15:01:27 · 5965 阅读 · 0 评论