标签:ret each class iter turn dom fun ict template
sort
//版本一 template <class RandomAccessIterator> void sort(RandomAccessIterator first,RandomAccessIterator last); //版本二 template <class RandomAccessIterator,class StrictWeakOrdering) void sort(RandomAccessIterator first,RandomAccessIterator last,StrictWeakOrdering cmp);
stable_sort
//版本一 template <class RandomAccessIterator> void stable_sort(RandomAccessIterator first,RandomAccessIterator last); //版本二 template <class RandomAccessIterator,class StrictWeakOrdering) void stable_sort(RandomAccessIterator first,RandomAccessIterator last,StrictWeakOrdering cmp);
#include <iostream> #include <vector> #include <algorithm> using namespace std; class F { public: bool operator()(int i,int j) { return (i%10)>=(j%10); } }; int main() { vector<int> v{2,1,-1,5,6,3}; sort(v.begin(),v.end(),F()); for_each(v.begin(),v.end(),[](int i) { cout<<i<<" "; }); cout<<endl; return 0; }
标签:ret each class iter turn dom fun ict template
原文地址:https://www.cnblogs.com/tianzeng/p/10390562.html