/** * Compares the two specified {@code float} values using {@link Float#compare(float, float)}. You * may prefer to invoke that method directly; this method exists only for consistency with the * other utilities in this package. * * <p><b>Note:</b> this method simply delegates to the JDK method {@link Float#compare}. It is * provided for consistency with the other primitive types, whose compare methods were not added * to the JDK until JDK 7. * * @param a the first {@code float} to compare * @param b the second {@code float} to compare * @return the result of invoking {@link Float#compare(float, float)} */ public static int compare(float a, float b) { return Float.compare(a, b); }
public int compare(WordInfo o1, WordInfo o2) { return Float.compare(o1.p, o2.p); } });
@Override public int compareTo(State o) { return Float.compare(cost, o.cost); } }
@Override public int compare(FeatureSortItem o1, FeatureSortItem o2) { return Float.compare(o1.total, o2.total); } });
/** * Compares this mutable to another in ascending order. * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @Override public int compareTo(final MutableFloat other) { return Float.compare(this.value, other.value); }
/** * Finds the first occurrence of value in <code>float</code> array. */ public static int indexOf(float[] array, float value) { for (int i = 0; i < array.length; i++) { if (Float.compare(array[i], value) == 0) { return i; } } return -1; } /**
/** * Finds the first occurrence in <code>float</code> array from specified given position and upto given length. */ public static int indexOf(float[] array, float value, int startIndex, int endIndex) { for (int i = startIndex; i < endIndex; i++) { if (Float.compare(array[i], value) == 0) { return i; } } return -1; }
/** * Compares value of two same instances. */ public int compareTo(MutableFloat other) { return Float.compare(value, other.value); }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o instanceof FloatNode) { // We must account for NaNs: NaN does not equal NaN, therefore we have // to use Double.compare(). final float otherValue = ((FloatNode) o)._value; return Float.compare(_value, otherValue) == 0; } return false; }
@Override public int compare(float[] left, float[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = Float.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
@Override public int compare(float[] left, float[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = Float.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
private static boolean floatIsDifferent(float f1, float f2, float delta) { if (Float.compare(f1, f2) == 0) { return false; } if ((Math.abs(f1 - f2) <= delta)) { return false; } return true; }
@Override public int compare(Object o, Object o1) { return Float.compare(((Number) o).floatValue(), ((Number) o1).floatValue()); } }.nullsFirst();
@Override public ComparisonChain compare(float left, float right) { return classify(Float.compare(left, right)); }
@Override public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this // function being the equivalence of internal long representation. float leftValue = intBitsToFloat(leftBlock.getInt(leftPosition, 0)); float rightValue = intBitsToFloat(rightBlock.getInt(rightPosition, 0)); return Float.compare(leftValue, rightValue); }
@Override public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this // function being the equivalence of internal long representation. float leftValue = intBitsToFloat(leftBlock.getInt(leftPosition, 0)); float rightValue = intBitsToFloat(rightBlock.getInt(rightPosition, 0)); return Float.compare(leftValue, rightValue); }
private static void testSortDescending(float[] input, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.sortDescending(input); // GWT's Arrays.equals doesn't appear to handle NaN correctly, so test each element individually for (int i = 0; i < input.length; i++) { assertEquals(0, Float.compare(expectedOutput[i], input[i])); } }
private static void testSortDescending( float[] input, int fromIndex, int toIndex, float[] expectedOutput) { input = Arrays.copyOf(input, input.length); Floats.sortDescending(input, fromIndex, toIndex); // GWT's Arrays.equals doesn't appear to handle NaN correctly, so test each element individually for (int i = 0; i < input.length; i++) { assertEquals(0, Float.compare(expectedOutput[i], input[i])); } }
@Override public int compare(Row o1, Row o2) { int value = Float.compare(o1.getMetric("rows").floatValue(), o2.getMetric("rows").floatValue()); if (value != 0) { return value; } return idxComparator.compare(o1, o2); } };
@Override public int compare(Row o1, Row o2) { return Float.compare(o1.getMetric("idx").floatValue(), o2.getMetric("idx").floatValue()); } };