Package it.unimi.dsi.fastutil.bytes
Interface ByteComparator
-
- All Superinterfaces:
java.util.Comparator<java.lang.Byte>
- All Known Implementing Classes:
AbstractByteComparator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ByteComparator extends java.util.Comparator<java.lang.Byte>A type-specificComparator; provides methods to compare two primitive types both as objects and as primitive types.Note that
fastutilprovides a corresponding abstract class that can be used to implement this interface just by specifying the type-specific comparator.- See Also:
Comparator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description intcompare(byte k1, byte k2)Compares its two primitive-type arguments for order.default intcompare(java.lang.Byte ok1, java.lang.Byte ok2)Deprecated.Please use the corresponding type-specific method instead.static <U extends java.lang.Comparable<? super U>>
ByteComparatorcomparing(Byte2ObjectFunction<? extends U> keyExtractor)Accepts a function that extracts aComparablesort key from a primitive key, and returns a comparator that compares by that sort key.static <U extends java.lang.Comparable<? super U>>
ByteComparatorcomparing(Byte2ObjectFunction<? extends U> keyExtractor, java.util.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 ByteComparatorcomparingDouble(Byte2DoubleFunction keyExtractor)Accepts a function that extracts andoublesort key from a primitive key, and returns a comparator that compares by that sort key.static ByteComparatorcomparingInt(Byte2IntFunction keyExtractor)Accepts a function that extracts anintsort key from a primitive key, and returns a comparator that compares by that sort key.static ByteComparatorcomparingLong(Byte2LongFunction keyExtractor)Accepts a function that extracts anlongsort key from a primitive key, and returns a comparator that compares by that sort key.default ByteComparatorreversed()default ByteComparatorthenComparing(ByteComparator 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 java.util.Comparator<java.lang.Byte>thenComparing(java.util.Comparator<? super java.lang.Byte> second)
-
-
-
Method Detail
-
compare
int compare(byte k1, byte 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:
Comparator
-
reversed
default ByteComparator reversed()
- Specified by:
reversedin interfacejava.util.Comparator<java.lang.Byte>
-
compare
@Deprecated default int compare(java.lang.Byte ok1, java.lang.Byte ok2)Deprecated.Please use the corresponding type-specific method instead.- Specified by:
comparein interfacejava.util.Comparator<java.lang.Byte>- Implementation Specification:
- This implementation delegates to the corresponding type-specific method.
-
thenComparing
default ByteComparator thenComparing(ByteComparator second)
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:
Comparator.thenComparing(Comparator)
-
thenComparing
default java.util.Comparator<java.lang.Byte> thenComparing(java.util.Comparator<? super java.lang.Byte> second)
- Specified by:
thenComparingin interfacejava.util.Comparator<java.lang.Byte>
-
comparing
static <U extends java.lang.Comparable<? super U>> ByteComparator comparing(Byte2ObjectFunction<? extends U> keyExtractor)
Accepts a function that extracts aComparablesort 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 theComparablesort key- Returns:
- a comparator that compares by an extracted key
- Throws:
java.lang.NullPointerException- ifkeyExtractorisnull
-
comparing
static <U extends java.lang.Comparable<? super U>> ByteComparator comparing(Byte2ObjectFunction<? extends U> keyExtractor, java.util.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- theComparatorused to compare the sort key- Returns:
- a comparator that compares by an extracted key using the specified
Comparator - Throws:
java.lang.NullPointerException- ifkeyExtractororkeyComparatorarenull
-
comparingInt
static ByteComparator comparingInt(Byte2IntFunction keyExtractor)
Accepts a function that extracts anintsort 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:
java.lang.NullPointerException- ifkeyExtractorisnull
-
comparingLong
static ByteComparator comparingLong(Byte2LongFunction keyExtractor)
Accepts a function that extracts anlongsort 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:
java.lang.NullPointerException- ifkeyExtractorisnull
-
comparingDouble
static ByteComparator comparingDouble(Byte2DoubleFunction keyExtractor)
Accepts a function that extracts andoublesort 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:
java.lang.NullPointerException- ifkeyExtractorisnull
-
-