Package it.unimi.dsi.fastutil.floats
Interface FloatComparator
- All Superinterfaces:
Comparator<Float>
- All Known Implementing Classes:
AbstractFloatComparator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A type-specific
Comparator
; provides methods to compare two primitive types both as
objects and as primitive types.
Note that fastutil
provides a corresponding abstract class that can be used to implement
this interface just by specifying the type-specific comparator.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
compare
(float k1, float k2) Compares its two primitive-type arguments for order.default int
Deprecated.Please use the corresponding type-specific method instead.static <U extends Comparable<? super U>>
FloatComparatorcomparing
(Float2ObjectFunction<? extends U> keyExtractor) Accepts a function that extracts aComparable
sort key from a primitive key, and returns a comparator that compares by that sort key.static <U extends Comparable<? super U>>
FloatComparatorcomparing
(Float2ObjectFunction<? extends U> keyExtractor, Comparator<? super U> keyComparator) Accepts a function that extracts a sort key from a primitive key, and returns a comparator that compares by that sort key using the specifiedComparator
.static FloatComparator
comparingDouble
(Float2DoubleFunction keyExtractor) Accepts a function that extracts andouble
sort key from a primitive key, and returns a comparator that compares by that sort key.static FloatComparator
comparingInt
(Float2IntFunction keyExtractor) Accepts a function that extracts anint
sort key from a primitive key, and returns a comparator that compares by that sort key.static FloatComparator
comparingLong
(Float2LongFunction keyExtractor) Accepts a function that extracts anlong
sort key from a primitive key, and returns a comparator that compares by that sort key.default FloatComparator
reversed()
default FloatComparator
thenComparing
(FloatComparator second) Return a new comparator that first uses this comparator, then uses the second comparator if this comparator compared the two elements as equal.default Comparator
<Float> thenComparing
(Comparator<? super Float> second) Methods inherited from interface java.util.Comparator
equals, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
compare
int compare(float k1, float k2) Compares its two primitive-type arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- See Also:
-
reversed
- Specified by:
reversed
in interfaceComparator<Float>
-
compare
Deprecated.Please use the corresponding type-specific method instead.- Specified by:
compare
in interfaceComparator<Float>
- Implementation Specification:
- This implementation delegates to the corresponding type-specific method.
-
thenComparing
Return a new comparator that first uses this comparator, then uses the second comparator if this comparator compared the two elements as equal.- See Also:
-
thenComparing
- Specified by:
thenComparing
in interfaceComparator<Float>
-
comparing
static <U extends Comparable<? super U>> FloatComparator comparing(Float2ObjectFunction<? extends U> keyExtractor) Accepts a function that extracts aComparable
sort key from a primitive key, and returns a comparator that compares by that sort key.The returned comparator is serializable if the specified function is also serializable.
- Parameters:
keyExtractor
- the function used to extract theComparable
sort key- Returns:
- a comparator that compares by an extracted key
- Throws:
NullPointerException
- ifkeyExtractor
isnull
-
comparing
static <U extends Comparable<? super U>> FloatComparator comparing(Float2ObjectFunction<? extends U> keyExtractor, Comparator<? super U> keyComparator) Accepts a function that extracts a sort key from a primitive key, and returns a comparator that compares by that sort key using the specifiedComparator
.The returned comparator is serializable if the specified function and comparator are both serializable.
- Parameters:
keyExtractor
- the function used to extract the sort keykeyComparator
- theComparator
used to compare the sort key- Returns:
- a comparator that compares by an extracted key using the specified
Comparator
- Throws:
NullPointerException
- ifkeyExtractor
orkeyComparator
arenull
-
comparingInt
Accepts a function that extracts anint
sort key from a primitive key, and returns a comparator that compares by that sort key.The returned comparator is serializable if the specified function is also serializable.
- Parameters:
keyExtractor
- the function used to extract the integer sort key- Returns:
- a comparator that compares by an extracted key
- Throws:
NullPointerException
- ifkeyExtractor
isnull
-
comparingLong
Accepts a function that extracts anlong
sort key from a primitive key, and returns a comparator that compares by that sort key.The returned comparator is serializable if the specified function is also serializable.
- Parameters:
keyExtractor
- the function used to extract the long sort key- Returns:
- a comparator that compares by an extracted key
- Throws:
NullPointerException
- ifkeyExtractor
isnull
-
comparingDouble
Accepts a function that extracts andouble
sort key from a primitive key, and returns a comparator that compares by that sort key.The returned comparator is serializable if the specified function is also serializable.
- Parameters:
keyExtractor
- the function used to extract the double sort key- Returns:
- a comparator that compares by an extracted key
- Throws:
NullPointerException
- ifkeyExtractor
isnull
-