messif.objects.util
Class DistanceRankedObject<T>

java.lang.Object
  extended by messif.objects.util.DistanceRankedObject<T>
Type Parameters:
T - the encapsulated object class
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<DistanceRankedObject<?>>, DistanceRanked
Direct Known Subclasses:
RankedAbstractObject

public class DistanceRankedObject<T>
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, DistanceRanked, java.lang.Comparable<DistanceRankedObject<?>>

Ranked object where the rank is based on distances.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface messif.objects.util.DistanceRanked
comparator
 
Constructor Summary
DistanceRankedObject(T object, float distance)
          Creates a new instance of DistanceRankedObject that encapsulates a given object.
 
Method Summary
 DistanceRankedObject<T> clone(float newDistance)
          Clone this ranked object and change the distance of the clonned 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.
 int hashCode()
          Returns a hash code value for the stored distance.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistanceRankedObject

public DistanceRankedObject(T object,
                            float distance)
Creates a new instance of DistanceRankedObject that encapsulates a given object. The specified distance is used as object's rank.

Parameters:
object - the encapsulated object
distance - the distance specifying object's rank
Method Detail

getObject

public T getObject()
Returns the encapsulated object.

Returns:
the encapsulated object

getDistance

public float getDistance()
Returns the measured distance.

Specified by:
getDistance in interface DistanceRanked
Returns:
the measured distance

equals

public boolean equals(java.lang.Object obj)
Returns true if this encapsulated object is equal to the specified DistanceRankedObject encapsulated object. Null values are handled correctly.

Note that the equality defined by this method is inconsistent with compareTo(messif.objects.util.DistanceRankedObject).

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare
Returns:
true if this object is the same as the obj argument; false otherwise

hashCode

public int hashCode()
Returns a hash code value for the stored distance.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for the stored distance

compareTo

public int compareTo(DistanceRankedObject<?> o)
Compares this object with the specified object for order.

Note that the natural order defined by this method is inconsistent with equals(java.lang.Object).

Specified by:
compareTo in interface java.lang.Comparable<DistanceRankedObject<?>>
Parameters:
o - the object to be compared
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object

clone

public DistanceRankedObject<T> clone(float newDistance)
Clone this ranked object and change the distance of the clonned one

Parameters:
newDistance - distance to be set for the clonned object
Returns:
the clone with new distance

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object