Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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

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<FloatDistance>
              extended by de.lmu.ifi.dbs.elki.distance.FloatDistance
All Implemented Interfaces:
Distance<FloatDistance>, Loggable, Externalizable, Serializable, Comparable<FloatDistance>

public class FloatDistance
extends NumberDistance<FloatDistance>

Provides a Distance for a float-valued distance.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Generated serialVersionUID.
private  float value
          The float value of this distance.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
FloatDistance()
          Empty constructor for serialization purposes.
FloatDistance(float value)
          Constructs a new FloatDistance object that represents the float argument.
 
Method Summary
 int compareTo(FloatDistance d)
           
 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.
 FloatDistance minus(FloatDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 FloatDistance plus(FloatDistance 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.
 FloatDistance times(float lambda)
          Returns a new distance as the product of this distance and the given double value.
 FloatDistance times(FloatDistance 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 float value
The float value of this distance.

Constructor Detail

FloatDistance

public FloatDistance()
Empty constructor for serialization purposes.


FloatDistance

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

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

plus

public FloatDistance plus(FloatDistance 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 FloatDistance minus(FloatDistance 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 FloatDistance times(FloatDistance 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 FloatDistance times(float 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(FloatDistance d)
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:
4 (4 Byte for a double value)

getDoubleValue

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

Specified by:
getDoubleValue in class NumberDistance<FloatDistance>
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<FloatDistance>
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<FloatDistance>
See Also:
Object.hashCode()

toString

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

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

Release 0.1 (2008-07-10_1838)