KnnMethod.Classes
Class Distance

java.lang.Object
  extended by KnnMethod.Classes.Distance
All Implemented Interfaces:
java.lang.Comparable<Distance>

public class Distance
extends java.lang.Object
implements java.lang.Comparable<Distance>

The class to store the distance between testing and training item. It also stored the name of an item and its index.


Constructor Summary
Distance(int i, double l, java.lang.String c)
           
 
Method Summary
 int compareTo(Distance o)
          Compares distances of objects.
 java.lang.String getClassInRow()
          Gets the class name, for which the distance is stored.
 double getIndex()
          Method, which returns the value of index for the training table.
 double getVzdalenost()
          Gets the object's stored distance.
 void setClassInRow(java.lang.String classInRow)
          Stores the class name for faster access.
 void setIndex(int newIndex)
          Stores the index into the training table.
 void setVzdalenost(double newVzdalenost)
          Stores the new value of distance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distance

public Distance(int i,
                double l,
                java.lang.String c)
Method Detail

getClassInRow

public java.lang.String getClassInRow()
Gets the class name, for which the distance is stored.

Returns:
the class name, for which the distance is stored

setClassInRow

public void setClassInRow(java.lang.String classInRow)
Stores the class name for faster access.

Parameters:
classInRow - class name, for which the distance is counted.

getIndex

public double getIndex()
Method, which returns the value of index for the training table.

Returns:
a value of index for the training table.

setIndex

public void setIndex(int newIndex)
Stores the index into the training table.

Parameters:
newIndex - new value of index in the training table.

getVzdalenost

public double getVzdalenost()
Gets the object's stored distance.

Returns:
object's distance

setVzdalenost

public void setVzdalenost(double newVzdalenost)
Stores the new value of distance.

Parameters:
newVzdalenost - the new value of object's distance

compareTo

public int compareTo(Distance o)
Compares distances of objects. If the distances are equal, the objects are sorted by Class

Specified by:
compareTo in interface java.lang.Comparable<Distance>
Parameters:
o - the object to compare
Returns:
negative integer, zero or positive integer, if the object's distance is lower, equal or higher than a specified object o.