Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance
Class DoubleDistance

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.distance.AbstractDistance<D>
          extended by de.lmu.ifi.dbs.elki.distance.NumberDistance<DoubleDistance>
              extended by de.lmu.ifi.dbs.elki.distance.DoubleDistance
All Implemented Interfaces:
Distance<DoubleDistance>, Loggable, Externalizable, Serializable, Comparable<DoubleDistance>

public class DoubleDistance
extends NumberDistance<DoubleDistance>

Provides a Distance for a double-valued distance.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Generated serialVersionUID.
private  double value
          The double value of this distance.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
DoubleDistance()
          Empty constructor for serialization purposes.
DoubleDistance(double value)
          Constructs a new DoubleDistance object that represents the double argument.
 
Method Summary
 int compareTo(DoubleDistance d)
          Compares this DoubleDistance with the given DoubleDistance wrt the representad double.
 boolean equals(Object o)
          Returns true if o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.
 int externalizableSize()
          Retuns the number of Bytes this distance uses if it is written to an external file.
 double getDoubleValue()
          Returns the double value of this distance.
 int hashCode()
          Any extending class should implement a proper hashCode method.
 DoubleDistance minus(DoubleDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 DoubleDistance plus(DoubleDistance distance)
          Returns a new distance as sum of this distance and the given distance.
 void readExternal(ObjectInput in)
          The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
 DoubleDistance times(double lambda)
          Returns a new distance as the product of this distance and the given double value.
 DoubleDistance times(DoubleDistance distance)
          Returns a new distance as the product of this distance and the given distance.
 String toString()
          Returns a string representation of this distance.
 void writeExternal(ObjectOutput out)
          The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.NumberDistance
description
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Generated serialVersionUID.

See Also:
Constant Field Values

value

private double value
The double value of this distance.

Constructor Detail

DoubleDistance

public DoubleDistance()
Empty constructor for serialization purposes.


DoubleDistance

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

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

plus

public DoubleDistance plus(DoubleDistance distance)
Description copied from interface: Distance
Returns a new distance as sum of this distance and the given distance.

Parameters:
distance - the distancce to be added to this distance
Returns:
a new distance as sum of this distance and the given distance
See Also:
Distance.plus(Distance)

minus

public DoubleDistance minus(DoubleDistance distance)
Description copied from interface: Distance
Returns a new Distance by subtracting the given distance from this distance.

Parameters:
distance - the distance to be subtracted from this distance
Returns:
a new Distance by subtracting the given distance from this distance
See Also:
Distance.minus(Distance)

times

public DoubleDistance times(DoubleDistance distance)
Returns a new distance as the product of this distance and the given distance.

Parameters:
distance - the distancce to be multiplied with this distance
Returns:
a new distance as the product of this distance and the given distance

times

public DoubleDistance times(double lambda)
Returns a new distance as the product of this distance and the given double value.

Parameters:
lambda - the double value this distance should be multiplied with
Returns:
a new distance as the product of this distance and the given double value

compareTo

public int compareTo(DoubleDistance d)
Compares this DoubleDistance with the given DoubleDistance wrt the representad double.

d1.compareTo(d2) is the same as Double.compare(d1.value, d2.value).

See Also:
Comparable.compareTo(Object)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters:
in - the stream to read data from in order to restore the object
Throws:
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being restored cannot be found.

externalizableSize

public int externalizableSize()
Retuns the number of Bytes this distance uses if it is written to an external file.

Returns:
8 (8 Byte for a double value)

getDoubleValue

public double getDoubleValue()
Returns the double value of this distance.

Specified by:
getDoubleValue in class NumberDistance<DoubleDistance>
Returns:
the double value of this distance

equals

public boolean equals(Object o)
Description copied from class: AbstractDistance
Returns true if o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.

Overrides:
equals in class AbstractDistance<DoubleDistance>
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Description copied from class: AbstractDistance
Any extending class should implement a proper hashCode method.

Specified by:
hashCode in class AbstractDistance<DoubleDistance>
See Also:
Object.hashCode()

toString

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

Specified by:
toString in interface Distance<DoubleDistance>
Overrides:
toString in class Object
Returns:
a string representation of this distance.

Release 0.1 (2008-07-10_1838)