本文整理了Java中java.lang.Double.compareTo()
方法的一些代码示例,展示了Double.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.compareTo()
方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:compareTo
[英]Compares this object to the specified double object to determine their relative order. There are two special cases:
代码示例来源:origin: apache/incubator-druid
@Override
public int compare(Object o, Object o1)
{
return ((Double) o).compareTo((Double) o1);
}
};
代码示例来源:origin: apache/incubator-druid
@Override
public int compare(Object o, Object o1)
{
return ((Double) o).compareTo((Double) o1);
}
};
代码示例来源:origin: apache/hbase
@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.
}
代码示例来源:origin: h2oai/h2o-2
@Override
public int compare(Integer o1, Integer o2) {
return ((Double)means[o1]).compareTo(means[o2]);
}
});
代码示例来源:origin: stackoverflow.com
public class District implements Comparable<District>{
String zipcode;
Double populationDensity;
public int compareTo(District other)
{
return populationDensity.compareTo(other.populationDensity);
}
}
代码示例来源:origin: apache/kylin
@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;
}
}
};
代码示例来源:origin: apache/incubator-pinot
@Override
public int compare(Number2ObjectPair o1, Number2ObjectPair o2) {
return new Double(o1.a.doubleValue()).compareTo(new Double(o2.a.doubleValue()));
}
}
代码示例来源:origin: apache/incubator-pinot
@Override
public int compare(Number2ObjectPair o1, Number2ObjectPair o2) {
return new Double(o2.a.doubleValue()).compareTo(new Double(o1.a.doubleValue()));
}
}
代码示例来源:origin: FudanNLP/fnlp
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);
}
});
代码示例来源:origin: h2oai/h2o-3
@Override
public int compare(final double[] a, final double[] b) {
Double d1 = a[0]; Double d2 = b[0];
return d1.compareTo(d2);
}
});
代码示例来源:origin: com.h2database/h2
@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);
}
代码示例来源:origin: google/guava
@Override
public int compare(Number a, Number b) {
return ((Double) a.doubleValue()).compareTo(b.doubleValue());
}
代码示例来源:origin: stackoverflow.com
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());
代码示例来源:origin: neo4j/neo4j
@Override
public int compareTo( PositionData o )
{
return f().compareTo( o.f() );
}
代码示例来源:origin: apache/kylin
@Override
public int compare(String o1, String o2) {
Double d1 = Double.parseDouble(o1);
Double d2 = Double.parseDouble(o2);
return d1.compareTo(d2);
}
}));
代码示例来源:origin: google/guava
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));
}
}
}
代码示例来源:origin: apache/kylin
@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;
}
}
});
代码示例来源:origin: apache/kylin
@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;
}
}
});
代码示例来源:origin: SonarSource/sonarqube
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;
}
}
}
代码示例来源:origin: azkaban/azkaban
@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());
}
});
内容来源于网络,如有侵权,请联系作者删除!