随笔分类 - 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, ...
阅读全文
摘要: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, ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:汇总打印集合的方法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
阅读全文
摘要: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 );
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:本节的四个算法所接受的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
阅读全文
摘要:二分查找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, ...
阅读全文