Class ResultsVector
Object
ResultsVector
A vector of results of applying a feature-calculations to many entities.
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.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTypedValuesTo(Collection<TypedValue> addTo, int numberDecimalPlaces) AddsTypedValuerepresentations of the results to aCollection.voidcopyFrom(int index, int length, ResultsVector source, int sourceIndex) Copies a contiguous subset of results from another vector.booleanbooleanDoes the instance have exactly these values?booleanequalsPrecision(double eps, Object... values) Likeequals(Object)but includes a tolerance for checking equality of the doubles.doubleget(int index) The result of a feature-calculation stored at a particularindex.getError(int index) Gets an error state at a particular position.getResult(int index) Gets a result value at a particular position.inthashCode()voidset(int index, double value) Assigns a result at a particular position.voidset(int startIndex, ResultsVector resultsToAssign) Assigns many results, starting at a particular position, and incrementing thereafter.voidSet an error state at a particular position.voidsetErrorAll(Exception exception) Set an error state at all positions.intsize()The number of calculations stored in the vector.toString()doubletotal()The total value of all results.
-
Constructor Details
-
ResultsVector
public ResultsVector(int size) Creates with a particular size.- Parameters:
size- the number of results the vector can store.
-
-
Method Details
-
total
public double total()The total value of all results.- Returns:
- the sum of all results, or
Double.NaNif any are errored.
-
set
public void set(int index, double value) Assigns a result at a particular position.- Parameters:
index- the index of the position (zero-valued).value- the value to assign as a result.
-
set
Assigns many results, starting at a particular position, and incrementing thereafter.- Parameters:
startIndex- the index of the initial position (zero-valued) for the first result.resultsToAssign- the values to assign instartIndexand subsequent positions.
-
setError
Set an error state at a particular position.- Parameters:
index- the index of the position (zero-valued).exception- the error state.
-
setErrorAll
Set an error state at all positions.- Parameters:
exception- the error state.
-
getError
Gets an error state at a particular position.This should only be called at positions which for sure are errored.
- Parameters:
index- the position (zero-indexed).- Returns:
- the exception for the error.
-
getResult
Gets a result value at a particular position.- Parameters:
index- the position (zero-indexed).- Returns:
- the result-value if unerrored, or
Optional.empty()if the position is errored.
-
get
public double get(int index) The result of a feature-calculation stored at a particularindex.- Parameters:
index- the index (zero-indexed). It should be>= 0and< size().- Returns:
- the value corresponding to the feature-calculation or
Double.NaNif an exception occurred during calculation.
-
copyFrom
Copies a contiguous subset of results from another vector.- Parameters:
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.
-
addTypedValuesTo
AddsTypedValuerepresentations of the results to aCollection.- Parameters:
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.
-
size
public int size()The number of calculations stored in the vector.- Returns:
- the total number of calculations in the vector.
-
equals
Does the instance have exactly these values?- Parameters:
values- the values to check for equality.- Returns:
- true, if the results in this object are exactly the same as
values.
-
equalsPrecision
Likeequals(Object)but includes a tolerance for checking equality of the doubles.- Parameters:
eps- amount of allowed absolute error.values- the values to check for equality.- Returns:
- true, if the results in this object are the same as
values, within the tolerance.
-
equals
-
hashCode
public int hashCode() -
toString
-