Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <algorithm>
- class obj
- {
- public:
- obj():v_(10000){}
- obj(const obj&o):a_(o.a_),v_(o.v_){}
- void set(int a){a_=a;}
- int get() const {return a_;}
- private:
- int a_;
- std::vector<int> v_;
- };
- inline bool asc(const obj& a, const obj& b)
- {
- return (a.get()<b.get());
- }
- inline bool desc(const obj& a, const obj& b)
- {
- return (a.get()>b.get());
- }
- int main()
- {
- const size_t size=10000;
- std::vector<obj> v(size);
- for (int i=0; i<size; ++i)
- v[i].set(i);
- for (int i=0; i<20; i++)
- {
- std::sort(v.begin(),v.end(),asc);
- std::sort(v.begin(),v.end(),desc);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement