@Override public int compare(Object o, Object o1) { return ((Double) o).compareTo((Double) o1); } };
@Override public int compare(Object o, Object o1) { return ((Double) o).compareTo((Double) o1); } };
@Override public int compare(final Double d1, final Double d2) { if (d1 == null ^ d2 == null) { return d1 == null ? -1 : 1; // either of one is null. } else if (d1 == null) return 0; // both are null return d1.compareTo(d2); // natural ordering. }
@Override public int compare(Integer o1, Integer o2) { return ((Double)means[o1]).compareTo(means[o2]); } });
public class District implements Comparable<District>{ String zipcode; Double populationDensity; public int compareTo(District other) { return populationDensity.compareTo(other.populationDensity); } }
@Override public int compare(String str1, String str2) { try { Double num1 = Double.parseDouble(str1); Double num2 = Double.parseDouble(str2); return num1.compareTo(num2); } catch (NumberFormatException e) { logger.error("NumberFormatException when parse doul family number.str1:" + str1 + " str2:" + str2); return 0; } } };
@Override public int compare(Number2ObjectPair o1, Number2ObjectPair o2) { return new Double(o1.a.doubleValue()).compareTo(new Double(o2.a.doubleValue())); } }
@Override public int compare(Number2ObjectPair o1, Number2ObjectPair o2) { return new Double(o2.a.doubleValue()).compareTo(new Double(o1.a.doubleValue())); } }
public int compare(Object arg0, Object arg1) { Double key1 = Double.valueOf(((Map.Entry) arg0).getValue().toString()); Double key2 = Double.valueOf(((Map.Entry) arg1).getValue().toString()); return -key1.compareTo(key2); } });
@Override public int compare(final double[] a, final double[] b) { Double d1 = a[0]; Double d2 = b[0]; return d1.compareTo(d2); } });
@Override public int compare(Object aObj, Object bObj) { if (aObj instanceof Double && bObj instanceof Double) { Double a = (Double) aObj; Double b = (Double) bObj; return a.compareTo(b); } return super.compare(aObj, bObj); }
@Override public int compare(Number a, Number b) { return ((Double) a.doubleValue()).compareTo(b.doubleValue()); }
SortedSet<Map.Entry<String, Double>> sortedset = new TreeSet<Map.Entry<String, Double>>( new Comparator<Map.Entry<String, Double>>() { @Override public int compare(Map.Entry<String, Double> e1, Map.Entry<String, Double> e2) { return e1.getValue().compareTo(e2.getValue()); } }); sortedset.addAll(myMap.entrySet());
@Override public int compareTo( PositionData o ) { return f().compareTo( o.f() ); }
@Override public int compare(String o1, String o2) { Double d1 = Double.parseDouble(o1); Double d2 = Double.parseDouble(o2); return d1.compareTo(d2); } }));
public void testCompare() { for (double x : VALUES) { for (double y : VALUES) { // note: spec requires only that the sign is the same assertEquals(x + ", " + y, Double.valueOf(x).compareTo(y), Doubles.compare(x, y)); } } }
@Override public int compare(String o1, String o2) { try { Double d1 = Double.parseDouble(o1); Double d2 = Double.parseDouble(o2); return d1.compareTo(d2); } catch (NumberFormatException e) { e.printStackTrace(); return 0; } } });
@Override public int compare(String o1, String o2) { try { Double d1 = Double.parseDouble(o1); Double d2 = Double.parseDouble(o2); return d1.compareTo(d2); } catch (NumberFormatException e) { e.printStackTrace(); return 0; } } });
private static boolean isBestValue(Measure measure, Double bestValue) { switch (measure.getValueType()) { case BOOLEAN: return (bestValue.intValue() == 1) == measure.getBooleanValue(); case INT: return bestValue.intValue() == measure.getIntValue(); case LONG: return bestValue.longValue() == measure.getLongValue(); case DOUBLE: return bestValue.compareTo(measure.getDoubleValue()) == 0; default: return false; } } }
@Override public int compare(final Executor o1, final Executor o2) { final ExecutorInfo stat1 = o1.getExecutorInfo(); final ExecutorInfo stat2 = o2.getExecutorInfo(); final int result = 0; if (statisticsObjectCheck(stat1, stat2, CPUUSAGE_COMPARATOR_NAME)) { return result; } // CPU usage , the lesser the value is, the better. return ((Double) stat2.getCpuUsage()).compareTo(stat1.getCpuUsage()); } });