Interface LongComparator

  • All Superinterfaces:
    java.util.Comparator<java.lang.Long>
    All Known Implementing Classes:
    AbstractLongComparator
    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 LongComparator
    extends java.util.Comparator<java.lang.Long>
    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:
    Comparator
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      int compare​(long k1, long k2)
      Compares its two primitive-type arguments for order.
      default int compare​(java.lang.Long ok1, java.lang.Long ok2)
      Deprecated.
      Please use the corresponding type-specific method instead.
      static <U extends java.lang.Comparable<? super U>>
      LongComparator
      comparing​(Long2ObjectFunction<? extends U> keyExtractor)
      Accepts a function that extracts a Comparable sort key from a primitive key, and returns a comparator that compares by that sort key.
      static <U extends java.lang.Comparable<? super U>>
      LongComparator
      comparing​(Long2ObjectFunction<? 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 specified Comparator.
      static LongComparator comparingDouble​(Long2DoubleFunction keyExtractor)
      Accepts a function that extracts an double sort key from a primitive key, and returns a comparator that compares by that sort key.
      static LongComparator comparingInt​(Long2IntFunction keyExtractor)
      Accepts a function that extracts an int sort key from a primitive key, and returns a comparator that compares by that sort key.
      static LongComparator comparingLong​(Long2LongFunction keyExtractor)
      Accepts a function that extracts an long sort key from a primitive key, and returns a comparator that compares by that sort key.
      default LongComparator reversed()  
      default LongComparator thenComparing​(LongComparator 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.Long> thenComparing​(java.util.Comparator<? super java.lang.Long> second)  
      • Methods inherited from interface java.util.Comparator

        equals, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Method Detail

      • compare

        int compare​(long k1,
                    long 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 LongComparator reversed()
        Specified by:
        reversed in interface java.util.Comparator<java.lang.Long>
      • compare

        @Deprecated
        default int compare​(java.lang.Long ok1,
                            java.lang.Long ok2)
        Deprecated.
        Please use the corresponding type-specific method instead.
        Specified by:
        compare in interface java.util.Comparator<java.lang.Long>
        Implementation Specification:
        This implementation delegates to the corresponding type-specific method.
      • thenComparing

        default LongComparator thenComparing​(LongComparator 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.Long> thenComparing​(java.util.Comparator<? super java.lang.Long> second)
        Specified by:
        thenComparing in interface java.util.Comparator<java.lang.Long>
      • comparing

        static <U extends java.lang.Comparable<? super U>> LongComparator comparing​(Long2ObjectFunction<? extends U> keyExtractor)
        Accepts a function that extracts a Comparable 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 Comparable sort key
        Returns:
        a comparator that compares by an extracted key
        Throws:
        java.lang.NullPointerException - if keyExtractor is null
      • comparing

        static <U extends java.lang.Comparable<? super U>> LongComparator comparing​(Long2ObjectFunction<? 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 specified Comparator.

        The returned comparator is serializable if the specified function and comparator are both serializable.

        Parameters:
        keyExtractor - the function used to extract the sort key
        keyComparator - the Comparator used to compare the sort key
        Returns:
        a comparator that compares by an extracted key using the specified Comparator
        Throws:
        java.lang.NullPointerException - if keyExtractor or keyComparator are null
      • comparingInt

        static LongComparator comparingInt​(Long2IntFunction keyExtractor)
        Accepts a function that extracts an int 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:
        java.lang.NullPointerException - if keyExtractor is null
      • comparingLong

        static LongComparator comparingLong​(Long2LongFunction keyExtractor)
        Accepts a function that extracts an long 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:
        java.lang.NullPointerException - if keyExtractor is null
      • comparingDouble

        static LongComparator comparingDouble​(Long2DoubleFunction keyExtractor)
        Accepts a function that extracts an double 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:
        java.lang.NullPointerException - if keyExtractor is null