Interface ArrayComparator32

All Superinterfaces:
ArrayComparator
All Known Implementing Classes:
JArrays.ByteArrayComparator, JArrays.CharArrayComparator, JArrays.DoubleArrayComparator, JArrays.FloatArrayComparator, JArrays.IntArrayComparator, JArrays.LongArrayComparator, JArrays.ShortArrayComparator
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 ArrayComparator32 extends ArrayComparator

Version of ArrayComparator for a case of 32-bit indexes (int instead of long).

Author:
Daniel Alievsky
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    less(int first, int second)
    Should return true if, and only if, the element at position first in the sorted array is "less" than the element at position second.
    default boolean
    less(long first, long second)
    This method, implemented in this interface, just calls another less method with int indexes:
  • Method Details

    • less

      default boolean less(long first, long second)
      This method, implemented in this interface, just calls another less method with int indexes:
           less((int) first, (int) second);
       
      Note: for maximal performance, it does not check that the passed intexes are really 32-bit. While using with arrays, containing 231 elements or more, this comparator will work incorrecly.
      Specified by:
      less in interface ArrayComparator
      Parameters:
      first - index of the first compared element.
      second - index of the second compared element.
      Returns:
      true if, and only if, the element #first is "less" than the element #second.
    • less

      boolean less(int first, int second)
      Should return true if, and only if, the element at position first in the sorted array is "less" than the element at position second. ("Less" element will have less index in the sorted array.) The result of this comparison must be fully defined by the values of the elements of the sorted array.
      Parameters:
      first - index of the first compared element.
      second - index of the second compared element.
      Returns:
      true if, and only if, the element #first is "less" than the element #second.