Package ptolemy.actor.util
Class FuzzyDoubleComparator
- java.lang.Object
-
- ptolemy.actor.util.FuzzyDoubleComparator
-
- All Implemented Interfaces:
java.util.Comparator
@Deprecated public class FuzzyDoubleComparator extends java.lang.Object implements java.util.Comparator
Deprecated.As Ptolemy II 4.1, use GeneralComparator instead.Compare two Double objects with respect to a fuzzy threshold. The threshold is set by setThreshold(). If the difference of the two double number is less than the threshold, then they are considered equal. The default value of the fuzzy threshold is 1e-10.After Ptolemy II 4.1, this class is not used any more. Use
GeneralComparator
instead.- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Jie Liu
- Pt.AcceptedRating:
- Yellow (hyzheng)
- Pt.ProposedRating:
- Yellow (liuj)
-
-
Constructor Summary
Constructors Constructor Description FuzzyDoubleComparator()
Deprecated.Construct a FuzzyDoubleComparator.FuzzyDoubleComparator(double threshold)
Deprecated.Construct a FuzzyDoubleComparator with the given threshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compare(java.lang.Object first, java.lang.Object second)
Deprecated.Compare two objects according to a threshold.double
getThreshold()
Deprecated.Return the fuzziness threshold.void
setThreshold(double threshold)
Deprecated.Set the fuzziness threshold.
-
-
-
Constructor Detail
-
FuzzyDoubleComparator
public FuzzyDoubleComparator()
Deprecated.Construct a FuzzyDoubleComparator. The compare threshold is 1e-10
-
FuzzyDoubleComparator
public FuzzyDoubleComparator(double threshold)
Deprecated.Construct a FuzzyDoubleComparator with the given threshold.- Parameters:
threshold
- The threshold
-
-
Method Detail
-
compare
public int compare(java.lang.Object first, java.lang.Object second)
Deprecated.Compare two objects according to a threshold. Return -1 if first < second - threshold/2; return 1 if first > second + threshold/2; return 0 otherwise.If any of the argument is not a Double object, a ClassCastException will be thrown.
- Specified by:
compare
in interfacejava.util.Comparator
- Parameters:
first
- The first Double object.second
- The second Double object.- Returns:
- The comparison result, -1, 0, or 1.
-
getThreshold
public double getThreshold()
Deprecated.Return the fuzziness threshold.- Returns:
- The fuzziness threshold.
- See Also:
setThreshold(double)
-
setThreshold
public void setThreshold(double threshold)
Deprecated.Set the fuzziness threshold. The threshold is always positive. If the argument is negative, then its absolute value is taken.- Parameters:
threshold
- The threshold.- See Also:
getThreshold()
-
-