ptolemy.actor.util
Class FuzzyDoubleComparator

java.lang.Object
  extended by ptolemy.actor.util.FuzzyDoubleComparator
All Implemented Interfaces:
java.util.Comparator

Deprecated. As Ptolemy II 4.1, use GeneralComparator instead.

public class FuzzyDoubleComparator
extends java.lang.Object
implements java.util.Comparator

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: FuzzyDoubleComparator.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Jie Liu
Accepted Rating:
Yellow (hyzheng)
Proposed Rating:
Yellow (liuj)

Field Summary
private  double _threshold
          Deprecated. The threshold that controls the fuzziness.
 
Constructor Summary
FuzzyDoubleComparator()
          Deprecated. Construct a FuzzyDoubleComparator.
FuzzyDoubleComparator(double threshold)
          Deprecated. Construct a FuzzyDoubleComparator with the given threshold.
 
Method Summary
 int compare(java.lang.Object first, java.lang.Object second)
          Deprecated. Return -1 if first < second - threshold/2;
return 1 if first > second + threshold/2;
return 0 otherwise.
 double getThreshold()
          Deprecated. Return the fuzziness threshold.
 void setThreshold(double threshold)
          Deprecated. Set the fuzziness threshold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

_threshold

private double _threshold
Deprecated. 
The threshold that controls the fuzziness. Default value 1e-10.

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. 
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 interface java.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()