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
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.AbstractDistance
DOUBLE_PATTERN, INFINITY_PATTERN, INTEGER_PATTERN
 
Constructor Summary
NumberDistance()
          Constructs a new NumberDistance object that represents the value argument.
 
Method Summary
 byte byteValue()
          Get the value as byte.
 int compareTo(D other)
          Compares this NumberDistance with the given NumberDistance wrt the represented value.
abstract  double doubleValue()
          Get the value as double.
 float floatValue()
          Get the value as float.
abstract  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.
 int intValue()
          Get the value as int.
abstract  long longValue()
          Get the value as long.
(package private) abstract  void setValue(N value)
          Sets the value of this NumberDistance.
 short shortValue()
          Get the value as short.
 String toString()
          Returns a string representation of this NumberDistance.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractDistance
equals, getPattern, isInfiniteDistance, isNullDistance, isUndefinedDistance, requiredInputPattern, testInputPattern
 
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
externalizableSize, infiniteDistance, minus, nullDistance, parseString, plus, undefinedDistance
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Constructor Detail

NumberDistance

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

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.

Parameters:
other - Other object
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 abstract N getValue()
Returns the value of this NumberDistance.

Returns:
the value of this NumberDistance

setValue

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

Parameters:
value - the value to be set

doubleValue

public abstract double doubleValue()
Get the value as double.

Returns:
same result as getValue().doubleValue() but may be more efficient.

floatValue

public float floatValue()
Get the value as float.

Returns:
same result as getValue().floatValue() but may be more efficient.

intValue

public int intValue()
Get the value as int.

Returns:
same result as getValue().intValue() but may be more efficient.

longValue

public abstract long longValue()
Get the value as long.

Returns:
same result as getValue().longValue() but may be more efficient.

shortValue

public short shortValue()
Get the value as short.

Returns:
same result as getValue().shortValue() but may be more efficient.

byteValue

public byte byteValue()
Get the value as byte.

Returns:
same result as getValue().byteValue() but may be more efficient.

Release 0.3 (2010-03-31_1612)