|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.number.Counter
public class Counter
This class counts the number of repeated numbers.
Two numbers are considered the same if they are close enough, rounded to a user specified number of decimal points.
| Field Summary | |
|---|---|
int |
scale
a precision parameter for rounding a double: number of decimal points to keep |
| Constructor Summary | |
|---|---|
Counter()
Construct an instance of Counter. |
|
Counter(int scale)
Construct an instance of Counter. |
|
| Method Summary | |
|---|---|
void |
add(double... numbers)
Add more doubles to the counter. |
void |
add(double number)
Add a new double to the counter. |
int |
count(double number)
Get the counts, i.e., the number of repetitions, for a particular double. |
java.util.Set<java.lang.Double> |
keySet()
Get the set of numbers the counter has seen. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final int scale
| Constructor Detail |
|---|
public Counter()
No rounding.
public Counter(int scale)
Round the doubles to scale number of decimal points.
scale - number of decimal points| Method Detail |
|---|
public void add(double number)
number - a doublepublic void add(double... numbers)
numbers - doublespublic int count(double number)
If the counter has not see the number, it returns 0.
number - a double
public java.util.Set<java.lang.Double> keySet()
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||