2019年2月19日

移除元素(remove,remove_if...unique...)

摘要: remove 因为本算法作用的是iterator,所以并不会改变Container大小,会返回一个新的iterator new_last,是的first到new_last中的元素都不等于value,左端元素的相对位置不变 template <class ForwardIterator,class T 阅读全文

posted @ 2019-02-19 23:29 tianzeng 阅读(284) 评论(0) 推荐(0)

替换元素(replace,replace_if,replace_copy,replace_copy_if)

摘要: replace 审阅range中的每个元素,把old_value替换为new_value template <class ForwardIterator,class T> void replace(ForwardIterator first,ForwardIterator last,const T& 阅读全文

posted @ 2019-02-19 22:59 tianzeng 阅读(329) 评论(0) 推荐(0)

transform、for_each

摘要: transform 与for_each类似可搭配function object对range内的元素进行操作,但for_each不关心function object的返回值,但transform会把操作后的range输出到另一个range,可以被就地来更改序列,允许first和result相等,但ou 阅读全文

posted @ 2019-02-19 22:37 tianzeng 阅读(200) 评论(0) 推荐(0)

互换元素(swap,swap_ranges)

摘要: swap template <class Assignable> void swap(Assignable &a,Assignable &b); iter_swap template <class ForwardIterator1,class ForwardIterator2> inline voi 阅读全文

posted @ 2019-02-19 22:06 tianzeng 阅读(248) 评论(0) 推荐(0)

最大值最小值(max,max_element)

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

posted @ 2019-02-19 21:48 tianzeng 阅读(542) 评论(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 阅读(177) 评论(0) 推荐(0)

导航