|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.science.Samples
public class Samples
Simply stores double values via the add
method.
Typically, these are samples from some sort of measurement.
No restriction is placed on the values stored except this: add only accepts normal (non-NaN and non-infinite) doubles.
This restriction means that the result returned by values
may be safely supplied to other classes (e.g. the statistical routines inside Math2
).
This class is not multithread safe.
StatsOverTime
Nested Class Summary | |
---|---|
static class |
Samples.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private static int |
integerMaxDiv2
|
private int |
n
Stores the number of data values recorded by this instance. |
private static int |
sizeInitial_default
Specifies the default value for the initial size of the values buffer. |
private double[] |
values
Buffer which holds the data values. |
Constructor Summary | |
---|---|
Samples()
Constructor which allocates an initial buffer with size sizeInitial_default . |
|
Samples(int sizeInitial)
Constructor which allocates an initial buffer with size specified by sizeInitial. |
Method Summary | |
---|---|
void |
add(double d)
Adds d to the internal array which stores all the values. |
private void |
increaseBuffer()
Increases the capacity of the values buffer. |
int |
size()
Returns the number of values that have been added to this instance. |
double[] |
values()
Returns a new array which holds all the values that have been added to this instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int sizeInitial_default
private static final int integerMaxDiv2
private double[] values
private int n
values
.
Constructor Detail |
---|
public Samples()
sizeInitial_default
.
public Samples(int sizeInitial) throws IllegalArgumentException
IllegalArgumentException
- if sizeInitial <= 0Method Detail |
---|
public void add(double d) throws IllegalArgumentException, IllegalStateException
IllegalArgumentException
- if d is not normal
;
IllegalStateException
- if the buffer's length = Integer.MAX_VALUE
private void increaseBuffer() throws IllegalStateException
Integer.MAX_VALUE
).
IllegalStateException
- if the buffer's length = Integer.MAX_VALUE
public int size()
public double[] values()
The implementation here returns an array which has the values in the order that they were added.
Contract: the result is never null, but will be zero-length if no values have ever been added.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |