|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.sort.SortKey<Integer> edu.nrao.sss.sort.IntSortKey
public abstract class IntSortKey
A sort key for Integers
s (and int
s).
Comparator
. The main job of the subclass
is to provide the integers to this parent class. Example:
/** * Sorts engines based on the number of cylinders they have. */ public class EngineCylinderCountKey extends IntSortKey implements Comparator<Engine> { public int compare(Engine e1, Engine e2) { return compareObjects(e1.getCylinders().size(), e2.getCylinders().size()); } }
Clients of the example EngineCylinderCountKey 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 |
IntSortKey()
Helps create a new instance. |
Method Summary | |
---|---|
protected int |
compareAscending(Integer o1,
Integer o2)
Uses the natural ordering of Integer . |
protected int |
compareNatural(Integer o1,
Integer o2)
Uses the natural ordering of Integer . |
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 IntSortKey()
Method Detail |
---|
protected int compareNatural(Integer o1, Integer o2)
Integer
.
compareNatural
in class SortKey<Integer>
protected int compareAscending(Integer o1, Integer o2)
Integer
.
compareAscending
in class SortKey<Integer>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |