|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.domains.ct.kernel.util.FuzzyDoubleComparator
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.
| Red (johnr) |
| Yellow (liuj) |
| Constructor Summary | |
FuzzyDoubleComparator()
Construct a FuzzyDoubleComparator. |
|
FuzzyDoubleComparator(double threshold)
Construct a FuzzyDoubleComparator with the given threshold. |
|
| Method Summary | |
int |
compare(java.lang.Object fst,
java.lang.Object snd)
Return -1 if fst < snd - threshold/2; return 1 if fst > snd + threshold/2; return 0 otherwise. |
double |
getThreshold()
Return the fuzziness threshold. |
void |
setThreshold(double threshold)
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 |
| Constructor Detail |
public FuzzyDoubleComparator()
public FuzzyDoubleComparator(double threshold)
threshold - The threshold| Method Detail |
public int compare(java.lang.Object fst,
java.lang.Object snd)
If any of the argument is not a Double object, a ClassCastException will be thrown.
compare in interface java.util.Comparatorfst - The first Double object.snd - The second Double object.
public double getThreshold()
public void setThreshold(double threshold)
threshold - The threshold.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||