T
- the encapsulated object classpublic class DistanceRankedObject<T> extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, DistanceRanked, java.lang.Comparable<DistanceRankedObject<?>>
comparator
Constructor and Description |
---|
DistanceRankedObject(O object,
DistanceFunction<? super O> distanceFunction,
O referenceObject)
Creates a new instance of DistanceRankedObject that encapsulates a given object
and measures the distance using
distanceFunction from the given reference object. |
DistanceRankedObject(T object,
float distance)
Creates a new instance of DistanceRankedObject that encapsulates a given object.
|
Modifier and Type | Method and Description |
---|---|
DistanceRankedObject<T> |
clone(float newDistance)
Clone this ranked object and change the distance of the cloned one
|
int |
compareTo(DistanceRankedObject<?> o)
Compares this object with the specified object for order.
|
boolean |
equals(java.lang.Object obj)
Returns true if this encapsulated object is equal to the specified
DistanceRankedObject encapsulated object. |
float |
getDistance()
Returns the measured distance.
|
T |
getObject()
Returns the encapsulated object.
|
static <T> java.util.Iterator<T> |
getObjectsIterator(java.util.Iterator<? extends DistanceRankedObject<T>> iterator)
Converts an iterator on
distance-ranked objects
to an iterator on the objects themselves. |
int |
hashCode()
Returns a hash code value for the stored distance.
|
java.lang.String |
toString() |
public DistanceRankedObject(T object, float distance)
object
- the encapsulated objectdistance
- the distance specifying object's rankpublic DistanceRankedObject(O object, DistanceFunction<? super O> distanceFunction, O referenceObject) throws java.lang.NullPointerException
distanceFunction
from the given reference object.O
- the type of object used to measure the distanceobject
- the encapsulated objectdistanceFunction
- the distance function used for the measuringreferenceObject
- the reference object from which the distance is measuredjava.lang.NullPointerException
- if the distance function is nullpublic T getObject()
public float getDistance()
getDistance
in interface DistanceRanked
public boolean equals(java.lang.Object obj)
DistanceRankedObject
encapsulated object. Null values
are handled correctly.
Note that the equality defined by this method is inconsistent with compareTo(messif.objects.util.DistanceRankedObject<?>)
.
equals
in class java.lang.Object
obj
- the reference object with which to comparetrue
if this object is the same as the obj
argument; false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object
public int compareTo(DistanceRankedObject<?> o)
Note that the natural order defined by this method is inconsistent with equals(java.lang.Object)
.
compareTo
in interface java.lang.Comparable<DistanceRankedObject<?>>
o
- the object to be comparedpublic DistanceRankedObject<T> clone(float newDistance)
newDistance
- distance to be set for the cloned objectpublic static <T> java.util.Iterator<T> getObjectsIterator(java.util.Iterator<? extends DistanceRankedObject<T>> iterator)
distance-ranked objects
to an iterator on the objects themselves.
Note that the remove method is passed on the original iterator, so
the returned iterator supports removal if and only if the given
iterator
supports removal.T
- the type of objects the distance-ranked object encapsulatesiterator
- the original iterator on the distance-ranked objectspublic java.lang.String toString()
toString
in class java.lang.Object