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) |
int |
getIndex()
Returns the index of the element.
|
boolean |
isAscending()
Returns whether the sorting is ascending.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalspublic 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()
Copyright © 2015. All rights reserved.