Interface ArrayComparator
- All Known Subinterfaces:
ArrayComparator32
- 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.
Comparison interface, designed for comparing elements in some data array.
Unlike the standard java.util.Comparator, the basic method less(long, long)
of this interface works not with data elements, but with their indexes in the array:
this method should get them from the analysed array itself.
So, every object, implementing this interface, is supposed to be working with some fixed linear data array.
The method of storing data in the array can be any; for example, it can be an AlgART array
or a usual Java array.
The length of the array is limited only by 263−1 (maximal possible value for long
indexes).
In JArrays
class you will find implementations of this interface for processing usual Java arrays.
This interface is used by ArraySorter
class.
- Author:
- Daniel Alievsky
-
Method Summary
Modifier and TypeMethodDescriptionboolean
less
(long first, long 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.
-
Method Details
-
less
boolean less(long first, long 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.
-