本文整理了Java中java.lang.Float.compareTo()
方法的一些代码示例,展示了Float.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Float.compareTo()
方法的具体详情如下:
包路径:java.lang.Float
类名称:Float
方法名:compareTo
[英]Compares this object to the specified float object to determine their relative order. There are two special cases:
代码示例来源:origin: gocd/gocd
@Override
public int compareTo(Object other) {
return this.averageDepth.compareTo(((NodeBaryCentre) other).averageDepth);
}
}
代码示例来源:origin: MovingBlocks/Terasology
@Override
public int compare(Float o1, Float o2) {
return o1.compareTo(o2);
}
}, Ordering.arbitrary());
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int compareValues(Float first, Float second) {
// Reversed intentionally because relevance by default
// sorts descending:
return second.compareTo(first);
}
代码示例来源:origin: lealone/Lealone
@Override
public int compare(Object aObj, Object bObj) {
Float a = (Float) aObj;
Float b = (Float) bObj;
return a.compareTo(b);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* @return true if {@link #weight} has a value that is a valid number.
*/
public boolean isWeighted() {
return this.weight.compareTo(1.0F) != 0;
}
代码示例来源:origin: stanfordnlp/CoreNLP
@Override
public int compare(String depIndex1, String depIndex2) {
return Float.valueOf(depIndex1).compareTo(Float.valueOf(depIndex2));
}
}
代码示例来源:origin: com.h2database/h2
@Override
public int compare(Object aObj, Object bObj) {
if (aObj instanceof Float && bObj instanceof Float) {
Float a = (Float) aObj;
Float b = (Float) bObj;
return a.compareTo(b);
}
return super.compare(aObj, bObj);
}
代码示例来源:origin: linkedin/rest.li
@Override
public int compareTo(AcceptEncoding target)
{
return new Float(target.getQuality()).compareTo(getQuality());
}
}
代码示例来源:origin: linkedin/rest.li
@Override
public int compareTo(AcceptEncoding target)
{
return new Float(target.getQuality()).compareTo(getQuality());
}
}
代码示例来源:origin: alibaba/fastjson
int result = valueFloat.compareTo((Float) propertyValue);
switch (op) {
case EQ:
代码示例来源:origin: apache/geode
return ((Float) num1).compareTo((Float) num2);
else
return ((Float) num1).compareTo(new Float(num2.doubleValue()));
else if (num2 instanceof Float)
return new Float(num1.doubleValue()).compareTo((Float) num2);
代码示例来源:origin: google/guava
public void testCompare() {
for (float x : VALUES) {
for (float y : VALUES) {
// note: spec requires only that the sign is the same
assertEquals(x + ", " + y, Float.valueOf(x).compareTo(y), Floats.compare(x, y));
}
}
}
代码示例来源:origin: apache/incubator-pinot
case FLOAT:
if (!selectionSort.isIsAsc()) {
ret = ((Float) v1).compareTo((Float) v2);
} else {
ret = ((Float) v2).compareTo((Float) v1);
代码示例来源:origin: com.alibaba/fastjson
int result = valueFloat.compareTo((Float) propertyValue);
switch (op) {
case EQ:
代码示例来源:origin: apache/incubator-pinot
break;
case FLOAT:
compare = ((Float) thisVal).compareTo((Float) otherVal);
break;
case DOUBLE:
代码示例来源:origin: apache/hive
return ((Float) o1).compareTo((Float) o2);
代码示例来源:origin: org.freemarker/freemarker
return ((Float) first).compareTo((Float) second);
代码示例来源:origin: reactor/reactor-core
@Override
public int compareTo(@Nullable SensorData other) {
if (null == other) {
return 1;
}
return value.compareTo(other.getValue());
}
代码示例来源:origin: Sable/soot
if (tempVal.compareTo(new Float(0)) == 0) {
primTypeFieldValueToUse.put(combined, tempVal);
} else {
代码示例来源:origin: debezium/debezium
@SuppressWarnings("unchecked")
@Override
public int compareTo(Value that) {
if (Value.isNull(that)) return 1;
if ( this.isBoolean() && that.isBoolean() ) {
return this.asBoolean().compareTo(that.asBoolean());
}
if (this.isNumber() && that.isNumber()) {
if (this.isLong()) return this.asLong().compareTo(that.asLong());
if (this.isDouble()) return this.asDouble().compareTo(that.asDouble());
if (this.isInteger()) return this.asInteger().compareTo(that.asInteger());
if (this.isFloat()) return this.asFloat().compareTo(that.asFloat());
if (this.isBigDecimal()) return this.asBigDecimal().compareTo(that.asBigDecimal());
return this.asBigInteger().compareTo(that.asBigInteger());
}
if ( this.isDocument() && that.isDocument()) {
return this.asDocument().compareTo(that.asDocument());
}
if ( this.isArray() && that.isArray() ) {
return this.asArray().compareTo(that.asArray());
}
Comparable<Object> thisValue = (Comparable<Object>)this.asObject();
Comparable<Object> thatValue = (Comparable<Object>)((ComparableValue)that.comparable()).asObject();
if ( thisValue.getClass().isAssignableFrom(thatValue.getClass())) {
return thisValue.compareTo(thatValue);
} else if (thatValue.getClass().isAssignableFrom(thisValue.getClass())) {
return thatValue.compareTo(thisValue) * -1; // correct for the reversed comparison
}
return ((Comparable<Object>) this.value).compareTo(that.asObject());
}
内容来源于网络,如有侵权,请联系作者删除!