|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fi.utu.cs.physics.EpsilonComparator
A rounding comparator for double-precision floating point values.
An epsilon value is used when comparing two values
(i.e., compare(f, g)
returns zero, if
Math.abs(f - g) < getComparisonEpsilon()
).
Constructor Summary | |
EpsilonComparator(double e)
Creates a comparator with the epsilon value e . |
Method Summary | |
int |
compare(double v1,
double v2)
Compares v1 and v2 for order.
|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares the two arguments for order. |
double |
getEpsilon()
Returns the epsilon. |
void |
setEpsilon(double e)
Sets the epsilon value to e . |
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 EpsilonComparator(double e)
e
.
Method Detail |
public double getEpsilon()
public void setEpsilon(double e)
e
. The new
epsilon must be greater than zero.
public int compare(double v1, double v2)
v1
and v2
for order.
Returns a negative integer, zero, or a positive integer as
v1
is less than, equal to, or greater than
v2
. The values are equal, if their difference
is less than epsilon.
public int compare(java.lang.Object o1, java.lang.Object o2)
Number
.
Returns a negative integer, zero, or a positive integer as the
first argument is less than, equal to, or greater than the second.
The arguments are equal, if their difference is less than epsilon.
Note: This comparator imposes orderings that are inconsistent
with equals.
compare
in interface java.util.Comparator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |