All pastes #980364 Raw Edit

Someone

public cpp v1 · immutable
·published 2008-04-10 23:22 UTC
rendered paste body
// sort in C++// library (STL) version written Jan 00 by Amit Patel//** This copy courtesy of http://verify.stanford.edu/uli/java_cpp.html//**  Added Timer() code#include <ctime>#include <cstdlib>#include <algorithm>#include <iostream>#include <vector>using namespace std;class Range {  int lb, ub;public:  Range() {}  Range(int l, int u): lb(l), ub(u) {}  int getLB() const { return lb; }  int getUB() const { return ub; }  friend ostream& operator <<(ostream& out, const Range& r) {    return out << '[' << r.lb << ',' << r.ub << ']';  }};struct LBComparator {  bool operator() (const Range& a, const Range& b) const {    return a.getLB() < b.getLB();  }};struct UBComparator {  bool operator() (const Range& a, const Range& b) const {    return a.getUB() < b.getUB();  }};int main(int argc, char *argv[]) {  int N = ((argc == 2) ? atoi(argv[1]) : 1);  clock_t start=clock();  vector<Range> a(N);  for(int i=0; i<N; i++)    a[i] = Range(i*7%1000, i*13%1000);  sort(a.begin(), a.end(), LBComparator());  sort(a.begin(), a.end(), UBComparator());  cout << a[0] << a[N-1] << endl;   clock_t endt=clock();  std::cout <<"Time: " << double(endt-start)/CLOCKS_PER_SEC * 1000 << " ms\n";}