随笔分类 -  C/C++

摘要:inplace_mergeCombines the elements from two consecutive sorted ranges into a single sorted range, where the ordering criterion may be specified by a binary predicate.template<class BidirectionalIterator> void inplace_merge( BidirectionalIterator _First, BidirectionalIterator _Middle, ... 阅读全文
posted @ 2013-03-11 16:31 freewater 阅读(285) 评论(0) 推荐(0) 编辑
摘要:sortArranges the elements in a specified range into a nondescending order or according to an ordering criterion specified by a binary predicate.template<class RandomAccessIterator> void sort( RandomAccessIterator first, RandomAccessIterator last );template<class RandomAccessIterator, ... 阅读全文
posted @ 2013-03-11 16:21 freewater 阅读(251) 评论(0) 推荐(0) 编辑
摘要:random_shuffleRearranges a sequence of N elements in a range into one of N! possible arrangements selected at random.template<class RandomAccessIterator> void random_shuffle( RandomAccessIterator _First, RandomAccessIterator _Last ); template<class RandomAccessIterator, class Rand... 阅读全文
posted @ 2013-03-11 16:02 freewater 阅读(601) 评论(0) 推荐(0) 编辑
摘要:next_permutationReorders the elements in a range so that the original ordering is replaced by the lexicographically next greater permutation if it exists, where the sense of next may be specified with a binary predicate.template<class BidirectionalIterator> bool next_permutation( Bidirectio... 阅读全文
posted @ 2013-03-11 15:59 freewater 阅读(196) 评论(0) 推荐(0) 编辑
摘要:uniqueRemoves duplicate elements that are adjacent to each other in a specified range.template<class ForwardIterator> ForwardIterator unique( ForwardIterator _First, ForwardIterator _Last );template<class ForwardIterator, class Predicate> ForwardIterator unique( ForwardIterator... 阅读全文
posted @ 2013-03-11 11:29 freewater 阅读(339) 评论(0) 推荐(0) 编辑
摘要:transformApplies a specified function object to each element in a source range or to a pair of elements from two source ranges and copies the return values of the function object into a destination range.template<class InputIterator, class OutputIterator, class UnaryFunction> OutputIterator tr 阅读全文
posted @ 2013-03-11 11:23 freewater 阅读(331) 评论(0) 推荐(0) 编辑
摘要:rotateExchanges the elements in two adjacent ranges.template<class ForwardIterator> void rotate( ForwardIterator _First, ForwardIterator _Middle, ForwardIterator _Last );rotate_copyExchanges the elements in two adjacent ranges within a source range and copies the result to ... 阅读全文
posted @ 2013-03-11 11:15 freewater 阅读(236) 评论(0) 推荐(0) 编辑
摘要:reverseReverses the order of the elements within a range.template<class BidirectionalIterator> void reverse( BidirectionalIterator _First, BidirectionalIterator _Last );reverse_copyReverses the order of the elements within a source range while copying them into a destination range... 阅读全文
posted @ 2013-03-11 11:13 freewater 阅读(237) 评论(0) 推荐(0) 编辑
摘要:replaceExamines each element in a range and replaces it if it matches a specified value.template<class ForwardIterator, class Type> void replace( ForwardIterator _First, ForwardIterator _Last, const Type& _OldVal, const Type& _NewVal );replace_ifExamines each element ... 阅读全文
posted @ 2013-03-11 11:10 freewater 阅读(492) 评论(0) 推荐(0) 编辑
摘要:removeEliminates a specified value from a given range without disturbing the order of the remaining elements and returning the end of a new range free of the specified value.template<class ForwardIterator, class Type> ForwardIterator remove( ForwardIterator _First, ForwardIterator _L... 阅读全文
posted @ 2013-03-11 11:05 freewater 阅读(542) 评论(0) 推荐(0) 编辑
摘要:partitionClassifies elements in a range into two disjoint sets, with those elements satisfying a unary predicate preceding those that fail to satisfy it.template<class BidirectionalIterator, class Predicate> BidirectionalIterator partition( BidirectionalIterator _First, BidirectionalIte... 阅读全文
posted @ 2013-03-11 10:22 freewater 阅读(422) 评论(0) 推荐(0) 编辑
摘要:mergeCombines all of the elements from two sorted source ranges into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.template<class InputIterator1, class InputIterator2, class OutputIterator> OutputIterator merge( InputIterator1 _First... 阅读全文
posted @ 2013-03-11 10:19 freewater 阅读(316) 评论(0) 推荐(0) 编辑
摘要:汇总打印集合的方法1. for_eachtemplate<class T>struct display{ void operator()(const T& val){ cout<<val<<' '; }};int main(){ vector<int> vec(10); iota(vec.begin(),vec.end(),1); random_shuffle(vec.begin(),vec.end()); for_each(vec.begin(),vec.end(),display<int>()); cout 阅读全文
posted @ 2013-03-11 09:58 freewater 阅读(219) 评论(0) 推荐(0) 编辑
摘要:for_eachApplies a specified function object to each element in a forward order within a range and returns the function object.template<class InputIterator, class Function> Function for_each( InputIterator _First, InputIterator _Last, Function _Func ); 阅读全文
posted @ 2013-03-11 09:48 freewater 阅读(148) 评论(0) 推荐(0) 编辑
摘要:includesTests whether one sorted range contains all the elements contained in a second sorted range, where the ordering or equivalence criterion between elements may be specified by a binary predicate.template<class InputIterator1, class InputIterator2> bool includes( InputIterator1 _First1... 阅读全文
posted @ 2013-03-11 09:43 freewater 阅读(287) 评论(0) 推荐(0) 编辑
摘要:countReturns the number of elements in a range whose values match a specified value.template<class InputIterator, class Type> typename iterator_traits<InputIterator>::difference_type count( InputIterator _First, InputIterator _Last, const Type& _Val );count_ifReturns the number ... 阅读全文
posted @ 2013-03-07 16:23 freewater 阅读(226) 评论(0) 推荐(0) 编辑
摘要:adjacent_findSearches for two adjacent elements that are either equal or satisfy a specified condition.即,找出第一组满足条件的相邻元素。template<class ForwardIterator> ForwardIterator adjacent_find( ForwardIterator _First, ForwardIterator _Last );template<class ForwardIterator , class BinaryPredicate... 阅读全文
posted @ 2013-03-07 16:19 freewater 阅读(178) 评论(0) 推荐(0) 编辑
摘要:make_heapConverts elements from a specified range into a heap in which the first element is the largest and for which a sorting criterion may be specified with a binary predicate.template<class RandomAccessIterator> void make_heap( RandomAccessIterator _First, RandomAccessIterator _Last... 阅读全文
posted @ 2013-03-07 15:34 freewater 阅读(428) 评论(0) 推荐(0) 编辑
摘要:本节的四个算法所接受的set,必须是有序区间(sorted range),元素值可以重复出现。也就是说,他们可以接受STL的set/multiset容器作为输入区间。set_unionUnites all of the elements that belong to at least one of two sorted source ranges into a single, sorted destination range, where the ordering criterion may be specified by a binary predicate.template<clas 阅读全文
posted @ 2013-03-07 15:26 freewater 阅读(619) 评论(0) 推荐(0) 编辑
摘要:二分查找binary_searchTests whether there is an element in a sorted range that is equal to a specified value or that is equivalent to it in a sense specified by a binary predicate.template<class ForwardIterator, class Type> bool binary_search( ForwardIterator _First, ForwardIterator _Last, ... 阅读全文
posted @ 2013-03-07 15:15 freewater 阅读(501) 评论(0) 推荐(0) 编辑