Package ffx.numerics.clustering
Class Distance
java.lang.Object
ffx.numerics.clustering.Distance
- All Implemented Interfaces:
Cloneable
,Comparable<Distance>
Simple value object storing a distance and an optional weight used during
linkage computations; comparable by distance and cloneable.
- Since:
- 1.0
- Author:
- Lars Behnke, 2013, Michael J. Schnieders
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a clone of this Distance.int
Compares by distance value, with null other treated as greater (this invalid input: '<' other).Gets the distance value.Gets the weight.boolean
isNaN()
Checks whether the distance value is NaN or undefined.void
setDistance
(Double distance) Sets the distance value.void
Sets the weight.toString()
Returns a string containing distance and weight values.
-
Constructor Details
-
Distance
public Distance()Creates a Distance with value 0 and weight 1. -
Distance
Creates a Distance with the given value and unit weight.- Parameters:
distance
- the distance value
-
Distance
Creates a Distance with the given value and weight.- Parameters:
distance
- the distance valueweight
- the weight associated with this distance
-
-
Method Details
-
getDistance
Gets the distance value.- Returns:
- the distance value (may be null)
-
setDistance
Sets the distance value.- Parameters:
distance
- the distance value to set
-
getWeight
Gets the weight.- Returns:
- the weight
-
setWeight
Sets the weight.- Parameters:
weight
- the weight to set
-
isNaN
public boolean isNaN()Checks whether the distance value is NaN or undefined.- Returns:
- true if the distance is null or NaN; false otherwise
-
compareTo
Compares by distance value, with null other treated as greater (this invalid input: '<' other).- Specified by:
compareTo
in interfaceComparable<Distance>
- Parameters:
distance
- the other Distance to compare to- Returns:
- negative, zero, or positive per Comparable contract
-
toString
Returns a string containing distance and weight values. -
clone
Creates a clone of this Distance.
-