|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.sort.SortKey<Double> edu.nrao.sss.sort.DoubleSortKey
public abstract class DoubleSortKey
A sort key for Double
s (and double
s).
Comparator
. The main job of the subclass
is to provide the doubles to this parent class. Example:
/** * Sorts teams based on their win / loss percentage. */ public class TeamWinPctKey extends DoubleSortKey implements Comparator<Team> { public int compare(Team t1, Team t2) { return compareObjects(t1.getWinningPercentage(), t2.getWinningPercentage()); } }
Clients of the example TeamWinPctKey class are able to configure
that comparator via the SortKey.setOrder(SortOrder)
method,
something they cannot do with
the plain Comparator interface. They may then place instances
of this class in a CompoundComparator
.
Version Info:
$Revision: 593 $ |
$Date: 2007-05-07 15:54:14 -0600 (Mon, 07 May 2007) $ |
$Author: dharland $ |
Constructor Summary | |
---|---|
protected |
DoubleSortKey()
Helps create a new instance. |
Method Summary | |
---|---|
protected int |
compareAscending(Double o1,
Double o2)
Uses the natural ordering of Double . |
protected int |
compareNatural(Double o1,
Double o2)
Uses the natural ordering of Double . |
Methods inherited from class edu.nrao.sss.sort.SortKey |
---|
compareObjects, compareObjects, getOrder, nullOrdering, objectsAreEqual, setOrder |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DoubleSortKey()
Method Detail |
---|
protected int compareNatural(Double o1, Double o2)
Double
.
compareNatural
in class SortKey<Double>
protected int compareAscending(Double o1, Double o2)
Double
.
compareAscending
in class SortKey<Double>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |