Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance
Class NumberDistance<D extends NumberDistance<D,N>,N extends Number>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.AbstractDistance<D>
      extended by de.lmu.ifi.dbs.elki.distance.NumberDistance<D,N>
Type Parameters:
D - the (final) type of NumberDistance used
N - the type of Number used (e.g. Double, Integer, Float, etc.)
All Implemented Interfaces:
Distance<D>, Externalizable, Serializable, Comparable<D>
Direct Known Subclasses:
BitDistance, DoubleDistance, FloatDistance, IntegerDistance

public abstract class NumberDistance<D extends NumberDistance<D,N>,N extends Number>
extends AbstractDistance<D>

Provides a Distance for a number-valued distance.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private  N value
          The value of this distance.
 
Constructor Summary
NumberDistance(N value)
          Constructs a new NumberDistance object that represents the value argument.
 
Method Summary
 int compareTo(D other)
          Compares this NumberDistance with the given NumberDistance wrt the represented value.
 N getValue()
          Returns the value of this NumberDistance.
 int hashCode()
          Returns the hash code for this NumberDistance, which is the hash code of its value.
(package private)  void setValue(N value)
          Sets the value of this NumberDistance.
 String toString()
          Returns a string representation of this NumberDistance.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractDistance
equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.Distance
description, externalizableSize, minus, plus
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

value

private N extends Number value
The value of this distance.

Constructor Detail

NumberDistance

public NumberDistance(N value)
Constructs a new NumberDistance object that represents the value argument.

Parameters:
value - the value to be represented by the NumberDistance.
Method Detail

hashCode

public final int hashCode()
Returns the hash code for this NumberDistance, which is the hash code of its value.

Specified by:
hashCode in class AbstractDistance<D extends NumberDistance<D,N>>
Returns:
the hash code of the value

compareTo

public int compareTo(D other)
Compares this NumberDistance with the given NumberDistance wrt the represented value.

d1.compareTo(d2) is the same as Double.compare(d1.value.doubleValue(), d2.value.doubleValue()). Subclasses may need to overwrite this method if necessary.

Returns:
a negative integer, zero, or a positive integer as the value of this NumberDistance is less than, equal to, or greater than the value of the specified NumberDistance.

toString

public final String toString()
Returns a string representation of this NumberDistance.

Specified by:
toString in interface Distance<D extends NumberDistance<D,N>>
Overrides:
toString in class Object
Returns:
the value of this NumberDistance.

getValue

public final N getValue()
Returns the value of this NumberDistance.

Returns:
the value of this NumberDistance

setValue

void setValue(N value)
Sets the value of this NumberDistance.

Parameters:
value - the value to be set

Release 0.2.1 (2009-07-13_1605)