All pastes #979572 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2008-04-10 13:24 UTC
rendered paste body
// sort in Java// library (Collections) version written Jan 00 by Ulrich Stern//** This copy courtesy of http://verify.stanford.edu/uli/java_cpp.html//**  Added Timer() codeimport java.util.*;public class udasort {  static class Range {    int lb;    int ub;    Range(int l, int u) {      lb = l;  ub = u;    }    public String toString() {      return "[" + lb + "," + ub + "]";    }  }  // compare lower bound  static class LBComparator implements Comparator {    public int compare(Object o1, Object o2) {      return ((Range)o1).lb - ((Range)o2).lb;    }  }  // compare upper bound  static class UBComparator implements Comparator {    public int compare(Object o1, Object o2) {      return ((Range)o1).ub - ((Range)o2).ub;    }  }        public static void main(String[] args) {    int N = Integer.parseInt(args[0]);    long start = System.currentTimeMillis();     List a = new ArrayList(N);    for (int i=0; i<N; i++)      a.add(i, new Range(i*7%1000, i*13%1000));    Collections.sort(a, new LBComparator());    Collections.sort(a, new UBComparator());    System.out.println(((Range)a.get(0)).toString() + ((Range)a.get(N-1)).toString());    long end = System.currentTimeMillis();     System.out.println("Time: " + (end - start) + " ms");   }}