|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.ScoredObject<E>
E - the type of object that is scoredpublic class ScoredObject<E>
A ScoredObject provides an implementation of the
Scored interface with an attached object. Scored
objects are immutable and identity is reference. The object
returned by the getter getObject() is the actual object
stored, so changes to it will affect the scored object of which it
is a part.
| Field Summary |
|---|
| Fields inherited from interface com.aliasi.util.Scored |
|---|
REVERSE_SCORE_COMPARATOR, SCORE_COMPARATOR |
| Constructor Summary | |
|---|---|
ScoredObject(E obj,
double score)
Construct a scored object from the specified object and score. |
|
| Method Summary | ||
|---|---|---|
static
|
comparator()
Returns a comparator that sorts in ascending order of score. |
|
boolean |
equals(Object that)
Returns true if the specified object is
a scored object with an object equal to this object's
and equal scores. |
|
E |
getObject()
Returns the object attached to this scored object. |
|
static
|
reverseComparator()
Returns a comparator that sorts in descending order of score. |
|
double |
score()
Returns the score for this scored object. |
|
String |
toString()
Returns a string-based representation of this object consisting of the score followed by a colon ( ':'), followed
by the object converted to a string. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ScoredObject(E obj,
double score)
obj - Object for the constructed scored object.score - Score for the constructed scored object.| Method Detail |
|---|
public E getObject()
public double score()
score in interface Scoredpublic String toString()
':'), followed
by the object converted to a string.
toString in class Objectpublic boolean equals(Object that)
true if the specified object is
a scored object with an object equal to this object's
and equal scores.
equals in class Objectthat - Object to compare to this scored object.
true if the object is a scored object
equal to this one.public static <E extends Scored> Comparator<E> comparator()
This comparator may not be consistent with equality on the objects being compared, as it only depends on the score.
The returned comparator may be used as the priority ordering
for a priority queue of objects sorted by score. It may also
be passed to Arrays.sort(Object[],Comparator).
This implementation is a singleton -- the same comparator is used for all instances.
E - the type of scored objects being compared
public static <E extends Scored> Comparator<E> reverseComparator()
comparator(); see
that method's documentation for more details.
E - the type of scored objects being compared
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||