上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页

2019年2月19日

最大值最小值(max,max_element)

摘要: min 如果比不出大小就返回第一个引数 //版本一:调用operator< template <class LessThanComparable> const LessThanComparable& min(const LessThanComparable &a,const LessThanComp 阅读全文

posted @ 2019-02-19 21:48 tianzeng 阅读(500) 评论(0) 推荐(0) 编辑

基本算法(equal,fill,iter_swap,generate,generate_n,copy,mismatch)

摘要: euqal 比较两个序列是否相等,相等返回true,不相等返回false template <class _InputIter1, class _InputIter2>//版本1 inline bool equal(_InputIter1 __first1, _InputIter1 __last1, 阅读全文

posted @ 2019-02-19 21:34 tianzeng 阅读(162) 评论(0) 推荐(0) 编辑

2019年2月18日

适配器(Adapter)

摘要: 将一个Class的接口转换成另一个Class的接口,使原本因接口不兼容而不能合作的Class可以一起运作。分为:迭代器适配器(Iterator Adpater)、容器适配器(Contaier Adpater)、仿函数配接器。 应用于迭代器 Insert Iterator 它的作用是将一般迭代器的赋值 阅读全文

posted @ 2019-02-18 13:18 tianzeng 阅读(705) 评论(0) 推荐(0) 编辑

2019年2月17日

set相关算法(includes,set_union,set_intersection,set_difference)

摘要: includes S1内含S2的一个子集合,如果元素在s2出现n次,在S1出现m次,若n>m则会返回false //版本一:用operator <比较元素 template <class InputerIterator1,class InputerIterator2> bool includes(I 阅读全文

posted @ 2019-02-17 20:08 tianzeng 阅读(248) 评论(0) 推荐(0) 编辑

合并两个sorted ranges(merge和inplace_merge)

摘要: merge //版本一:用operator <比较元素 template <class InputerIterator1,class InputerIterator2,class OutputIterator> OutputIterator merge(InputerIterator1 first1 阅读全文

posted @ 2019-02-17 18:53 tianzeng 阅读(279) 评论(0) 推荐(0) 编辑

二分查找法(binary_search,lower_bound,upper_bound,equal_range)

摘要: binary_search(二分查找) //版本一:调用operator<进行比较 template <class ForwardIterator,class StrictWeaklyCompareable> bool binary_search(ForwardIterator first,Forw 阅读全文

posted @ 2019-02-17 14:37 tianzeng 阅读(245) 评论(0) 推荐(0) 编辑

对某个区间操作(sort,stable_sort,parital_sort,parital_sort_copy,nth_element,is_sorted)

摘要: sort 参数为随机迭代器,只有vector和deque使用sort算法;在介绍SGI的快排之前先介绍以下几种排序。 insertion sort 直接插入排序。 template<class RandomAccessIterator> void __insertion_sort(RandomAcc 阅读全文

posted @ 2019-02-17 11:41 tianzeng 阅读(356) 评论(0) 推荐(0) 编辑

2019年2月16日

数值算法(accumluate,inner_product,partial_sum,adjacent_difference,power,itoa)

摘要: accumulate template <class InputIterator,class T> T accumulate(InputIterator first, InputIterator last, T init) { for (; first != last; first++) { ini 阅读全文

posted @ 2019-02-16 19:46 tianzeng 阅读(381) 评论(0) 推荐(0) 编辑

2019年2月15日

随机重拍与抽样(random_shuffle,random_sample,random_sample_n)

摘要: random_shuffle 随机重排[first,last)中的数据,有N!中可能,N=last-first,此算法会产生一种均匀分布,任何特定排列顺序被选中的几率为1/N!,版本二是一种特别的function object,当被引数传进来,传递方式是by reference,而不是by valu 阅读全文

posted @ 2019-02-15 22:17 tianzeng 阅读(1193) 评论(0) 推荐(0) 编辑

分割(partition,stable_partition)

摘要: 将数组中的元素分为两部分,第一部分[first,middle)中的每个元素都是pred(i)为true,第二部分[middle,last)中的每个元素都是pred(i)为false 返回值为middle partition执行速度很快,除非要求稳定性使用stable_partition,否则使用pa 阅读全文

posted @ 2019-02-15 21:40 tianzeng 阅读(423) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页

导航