public class ArrayComparator<E> extends Object implements Comparator<E>, Serializable
compare(E, E) is an array, and
it compares the n-th element, where n is passed in the constructor,
ArrayComparator(int, boolean) (the index parameter).
It also assumes the element must implement Comparable.| Constructor and Description |
|---|
ArrayComparator(int index,
boolean ascending)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(E o1,
E o2) |
boolean |
equals(Object o) |
int |
getIndex()
Returns the index of the element.
|
int |
hashCode() |
boolean |
isAscending()
Returns whether the sorting is ascending.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic ArrayComparator(int index,
boolean ascending)
index - which index of an array to compareascending - whether to sort as ascending (or descending).public int compare(E o1, E o2)
compare in interface Comparator<E>public int getIndex()
public boolean isAscending()
public boolean equals(Object o)
equals in interface Comparator<E>equals in class ObjectCopyright © 2024. All rights reserved.