Package io.jenetics.util
Interface ProxySorter.Comparator<T>
-
- Type Parameters:
T
- the array type, e.g.int[]
,double[]
orSeq<String>
- Enclosing class:
- ProxySorter
- 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 static interface ProxySorter.Comparator<T>
The comparator used for comparing two array elements at the specified indexes.The example above shows how to create a comparator forfinal ProxySorter.Comparator<double[]> comparator = (a, i, j) -> Double.compare(a[i], a[j]);
double[]
arrays.- Since:
- 5.1
- Version:
- 5.1
- Author:
- Franz Wilhelmstötter
- See Also:
ProxySorter.sort(Object, int, Comparator)
,ProxySorter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description int
compare(T array, int i, int j)
Compares the two array elements, specified by its indices, for order.default ProxySorter.Comparator<T>
reversed()
Returns a comparator that imposes the reverse ordering of this comparator.
-
-
-
Method Detail
-
compare
int compare(T array, int i, int j)
Compares the two array elements, specified by its indices, 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.- Parameters:
array
- the array where the two comparing elements are fetchedi
- the index of the first array elementj
- the index of the second array element- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Throws:
NullPointerException
- if an argument is null and this comparator does not permit null arguments- See Also:
Comparator.compare(Object, Object)
-
reversed
default ProxySorter.Comparator<T> reversed()
Returns a comparator that imposes the reverse ordering of this comparator.- Returns:
- a comparator that imposes the reverse ordering of this comparator.
-
-