private class AverageAccumulator.Data extends java.lang.Object implements Accumulator.DataBundle
DataBundle
implementation which keeps a running total of
a numeric value and an iteration count, and provides the average value
when requested.Modifier and Type | Field and Description |
---|---|
private integer |
count
Iteration counter.
|
private decimal |
total
Running total for accumulated value.
|
Modifier | Constructor and Description |
---|---|
private |
Data()
Construct an instance of this class, setting the starting total to
either unknown value or 0, depending upon whether the enclosing
accumulator is initialized for use.
|
Modifier and Type | Method and Description |
---|---|
void |
accumulate(BaseDataType datum)
Add the numeric value of
datum to the running total. |
void |
assign(Undoable value)
Sets the state of this instance based on the state of the passed instance.
|
BaseDataType |
calculate()
Calculate the average, based on the current total and iteration
count.
|
Undoable |
deepCopy()
This is a form of a copy constructor that makes a deep copy of the
current instance and returns this copy as a new instance of the same
class.
|
void |
reset()
Reset (to zero) the total and count variables, in preparation for
beginning a new break group.
|
private decimal total
private integer count
private Data()
public void reset()
reset
in interface Accumulator.DataBundle
public void accumulate(BaseDataType datum)
datum
to the running total.
Increment the count internal variable.accumulate
in interface Accumulator.DataBundle
datum
- Datum to be accumulated; it is expected that this is a
numeric type. If unknown
then the accumulated
average value will be unknown
.java.lang.ClassCastException
- if datum
cannot be cast to
NumberType
.public BaseDataType calculate()
calculate
in interface Accumulator.DataBundle
accumulate(com.goldencode.p2j.util.BaseDataType)
ever
occurred).public Undoable deepCopy()