public class ResultsVector extends Object
Each position in the vector describes the result for a single entity. The result is either a
Double
or an Exception
.
An Exception
indicates that the feature-calculation ended in failure, producing the
exception.
Constructor and Description |
---|
ResultsVector(int size)
Creates with a particular size.
|
Modifier and Type | Method and Description |
---|---|
void |
addTypedValuesTo(Collection<TypedValue> addTo,
int numberDecimalPlaces)
Adds
TypedValue representations of the results to a Collection . |
void |
copyFrom(int index,
int length,
ResultsVector source,
int sourceIndex)
Copies a contiguous subset of results from another vector.
|
boolean |
equals(Object... values)
Does the instance have exactly these values?
|
boolean |
equals(Object obj) |
boolean |
equalsPrecision(double eps,
Object... values)
Like
equals(Object) but includes a tolerance for checking equality of the doubles. |
double |
get(int index)
The result of a feature-calculation stored at a particular
index . |
Exception |
getError(int index)
Gets an error state at a particular position.
|
Optional<Double> |
getResult(int index)
Gets a result value at a particular position.
|
int |
hashCode() |
void |
set(int index,
double value)
Assigns a result at a particular position.
|
void |
set(int startIndex,
ResultsVector resultsToAssign)
Assigns many results, starting at a particular position, and incrementing thereafter.
|
void |
setError(int index,
Exception exception)
Set an error state at a particular position.
|
void |
setErrorAll(Exception exception)
Set an error state at all positions.
|
int |
size()
The number of calculations stored in the vector.
|
String |
toString() |
double |
total()
The total value of all results.
|
public ResultsVector(int size)
size
- the number of results the vector can store.public double total()
Double.NaN
if any are errored.public void set(int index, double value)
index
- the index of the position (zero-valued).value
- the value to assign as a result.public void set(int startIndex, ResultsVector resultsToAssign)
startIndex
- the index of the initial position (zero-valued) for the first result.resultsToAssign
- the values to assign in startIndex
and subsequent positions.public void setError(int index, Exception exception)
index
- the index of the position (zero-valued).exception
- the error state.public void setErrorAll(Exception exception)
exception
- the error state.public Exception getError(int index)
This should only be called at positions which for sure are errored.
index
- the position (zero-indexed).public Optional<Double> getResult(int index)
index
- the position (zero-indexed).Optional.empty()
if the position is errored.public double get(int index)
index
.index
- the index (zero-indexed). It should be >= 0
and < size()
.Double.NaN
if an
exception occurred during calculation.public void copyFrom(int index, int length, ResultsVector source, int sourceIndex)
index
- start-position to start copying into (zero-indexed).length
- number of items to copy.source
- vector to copy from.sourceIndex
- index in the source away to start from.public void addTypedValuesTo(Collection<TypedValue> addTo, int numberDecimalPlaces)
TypedValue
representations of the results to a Collection
.addTo
- the collection to add the representations to.numberDecimalPlaces
- the number of decimal places to use, or -1 to visually shorten as
much as possible.public int size()
public boolean equals(Object... values)
values
- the values to check for equality.values
.public boolean equalsPrecision(double eps, Object... values)
equals(Object)
but includes a tolerance for checking equality of the doubles.eps
- amount of allowed absolute error.values
- the values to check for equality.values
, within the
tolerance.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.