Package net.maswag.falcaun
Class ValueWithTime<T>
java.lang.Object
net.maswag.falcaun.ValueWithTime<T>
- Type Parameters:
T- the type of values
A sequence of values each associated with an increasing timestamp.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes with empty lists.ValueWithTime(List<Double> timestamps, List<T> values) Initializes with the given timestamps and values. -
Method Summary
Modifier and TypeMethodDescriptionat(double time) Get the value at the given time.doubleduration()Get the duration of the signal.booleanisEmpty()Check if the value is empty.range(double from, double to) Get the values in the given time range.range(double from, double to, boolean leftInclusive, boolean rightInclusive) Get the values in the given time range.intsize()Get the number of contained values.stream(double signalStep) Stream the List of values between each signal step.
-
Field Details
-
timestamps
-
values
-
-
Constructor Details
-
ValueWithTime
public ValueWithTime()Initializes with empty lists. -
ValueWithTime
Initializes with the given timestamps and values. i-th timestamp corresponds to i-th value. So the sizes of timestamps and values must be equal.- Parameters:
timestamps- The list of timestampsvalues- The list of values- Throws:
IllegalArgumentException- if the sizes of timestamps and values are not equal or if any value is null
-
-
Method Details
-
duration
public double duration()Get the duration of the signal. That is the difference between the last and first timestamps.- Returns:
- The duration of the signal, or 0 if the signal is empty
-
size
public int size()Get the number of contained values. -
isEmpty
public boolean isEmpty()Check if the value is empty. -
at
Get the value at the given time.- Parameters:
time- The time to get the value at- Returns:
- the value at the closest time
-
range
Get the values in the given time range.- Parameters:
from- The start time (non-inclusive)to- The end time (inclusive)
-
range
public ValueWithTime<T> range(double from, double to, boolean leftInclusive, boolean rightInclusive) Get the values in the given time range.- Parameters:
from- The start timeto- The end timeleftInclusive- Whether the start time is inclusiverightInclusive- Whether the end time is inclusive
-
stream
Stream the List of values between each signal step. Since the values between each signal step can be multiple in general, each element of the stream is a list.The i-th element is the list of values whose timestamp is between ((i-1) * signalStep, i * signalStep].
- Parameters:
signalStep- The time step between each signal- Returns:
- A stream of lists of values, grouped by signal step.
-