Class ConsecutiveWindowAccumulator
java.lang.Object
com.amalgamasimulation.utils.windowaccumulator.ConsecutiveWindowAccumulator
- All Implemented Interfaces:
IWindowAccumulator
Implements an accumulator for numerical value which accumulating them over
consecutive time windows of a specified duration. This class tracks and
calculates statistics for values that fall within sliding time windows,
allowing for the analysis of data points that are added in chronological
order. It is optimized for scenarios where values are added in sequence and
statistical calculations are needed for the most recent window of time. This
situation is typical for logic of simulation models.
- Author:
- Andrey Malykhanov
-
Constructor Summary
ConstructorsConstructorDescriptionConsecutiveWindowAccumulator
(double timeWindowSize) Creates a newConsecutiveWindowAccumulator
with the specified time window size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double time, double value) Adds a new statistical element to the accumulator.void
clear()
Clears all the data from the accumulator.double
get
(double time) Returns the sum of elements in the accumulator whose time of addition does not exceed the specified time.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.amalgamasimulation.utils.windowaccumulator.IWindowAccumulator
getAvg, getMax, getMin
-
Constructor Details
-
ConsecutiveWindowAccumulator
public ConsecutiveWindowAccumulator(double timeWindowSize) Creates a newConsecutiveWindowAccumulator
with the specified time window size.- Parameters:
timeWindowSize
- The duration of the time window for which statistics are to be accumulated.
-
-
Method Details
-
add
public void add(double time, double value) Description copied from interface:IWindowAccumulator
Adds a new statistical element to the accumulator.- Specified by:
add
in interfaceIWindowAccumulator
- Parameters:
time
- The time associated with the statistical element.value
- The value of the statistical element.
-
get
public double get(double time) Description copied from interface:IWindowAccumulator
Returns the sum of elements in the accumulator whose time of addition does not exceed the specified time.- Specified by:
get
in interfaceIWindowAccumulator
- Parameters:
time
- The maximum time up to which values are accumulated.- Returns:
- The sum of elements added to the accumulator up to the specified time.
-
clear
public void clear()Description copied from interface:IWindowAccumulator
Clears all the data from the accumulator.- Specified by:
clear
in interfaceIWindowAccumulator
-