public class ArrayComparator<E>
extends java.lang.Object
implements java.util.Comparator<E>, java.io.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(java.lang.Object o) |
int |
getIndex()
Returns the index of the element.
|
int |
hashCode() |
boolean |
isAscending()
Returns whether the sorting is ascending.
|
public ArrayComparator(int index, boolean ascending)
index
- which index of an array to compareascending
- whether to sort as ascending (or descending).public int getIndex()
public boolean isAscending()
public boolean equals(java.lang.Object o)
equals
in interface java.util.Comparator<E>
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2005-2022 Potix Corporation. All Rights Reserved.