V - the vector type@FunctionalInterface public interface ElementComparator<V>
V.
The following example creates an ElementComparator function for a
double[] array:
final ElementComparator<double[]> comp =
(u, v, i) -> Double.compare(u[i], v[i]);| Modifier and Type | Method and Description |
|---|---|
int |
compare(V u,
V v,
int index)
Compares the components of
a and b at the given
index. |
default <T> ElementComparator<T> |
map(Function<? super T,? extends V> mapper)
Return an element comparator for the mapped type
T. |
default Comparator<V> |
ofIndex(int index)
Return a comparator which takes the component at the give
index
for comparison two objects of type T. |
default ElementComparator<V> |
reversed()
Returns a comparator that imposes the reverse ordering of this
comparator.
|
int compare(V u, V v, int index)
a and b at the given
index. E.g.
final ElementComparator<double[]> comp =
(u, v, i) -> Double.compare(u[i], v[i]);u - the first vectorv - the second vectorindex - the vector indexNullPointerException - if either a or b is
nullIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= length(a) || index >= length(b))default ElementComparator<V> reversed()
default <T> ElementComparator<T> map(Function<? super T,? extends V> mapper)
T.T - the new comparator typemapper - the mapper functionTdefault Comparator<V> ofIndex(int index)
index
for comparison two objects of type T.index - the component indexindex© 2007-2018 Franz Wilhelmstötter (2018-10-28 17:23)