T - the type of each individual valuepublic interface ScenarioArray<T>
Implementations of this interface provide scenario-specific values.
In the simplest case, this might be a list of values, one for each scenario. This is handled by this factory methods on this interface.
There are two obvious reasons for creating implementations of this interface with special handling for certain types of value:
When dealing with primitive data it is likely be more efficient to store the scenario values in a primitive array instead of using a list. This removes the need for boxing and reduces memory footprint. Also, if a function calculates values for all scenarios at the same time, it is likely to be more efficient if the data is stored in arrays as the values will be stored in a contiguous block of memory.
The generic type parameter is the type of the single value associated with each scenario. For example, in the case of optimized curve storage, the single value is a curve.
| Modifier and Type | Method and Description |
|---|---|
T |
get(int scenarioIndex)
Gets the value at the specified scenario index.
|
int |
getScenarioCount()
Gets the number of scenarios.
|
static <T> ScenarioArray<T> |
of(int scenarioCount,
IntFunction<T> valueFunction)
Obtains an instance using a function to create the entries.
|
static <T> ScenarioArray<T> |
of(List<T> values)
Obtains an instance from the specified list of values.
|
static <T> ScenarioArray<T> |
of(T... values)
Obtains an instance from the specified array of values.
|
static <T> ScenarioArray<T> |
ofSingleValue(int scenarioCount,
T value)
Obtains an instance from a single value where the value applies to all scenarios.
|
default Stream<T> |
stream()
Returns a stream of the values.
|
@SafeVarargs static <T> ScenarioArray<T> of(T... values)
T - the type of the valuevalues - the values, one value for each scenariostatic <T> ScenarioArray<T> of(List<T> values)
T - the type of the valuevalues - the values, one value for each scenariostatic <T> ScenarioArray<T> of(int scenarioCount, IntFunction<T> valueFunction)
The function is passed the scenario index and returns the value for that index.
T - the type of the valuescenarioCount - the number of scenariosvalueFunction - the function used to obtain each valueIllegalArgumentException - is size is zero or lessstatic <T> ScenarioArray<T> ofSingleValue(int scenarioCount, T value)
T - the type of the valuescenarioCount - the nnumber of scenariosvalue - the single value, used for all scenariosint getScenarioCount()
T get(int scenarioIndex)
scenarioIndex - the zero-based index of the scenarioIndexOutOfBoundsException - if the index is invalidCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.