U - Unit the unit for which this Vector will be createdpublic abstract class FloatVector<U extends Unit<U>> extends AbstractValue<U> implements FloatVectorInterface<U>, Serializable
Copyright (c) 2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
$LastChangedDate: 2015-10-07 11:49:36 +0200 (Wed, 07 Oct 2015) $, @version $Revision: 92 $, by $Author: averbraeck $, initial
version 30 Oct, 2015
| Modifier and Type | Class and Description |
|---|---|
static class |
FloatVector.Abs<U extends Unit<U>> |
static class |
FloatVector.Rel<U extends Unit<U>> |
| Modifier and Type | Field and Description |
|---|---|
protected org.djunits.value.vfloat.vector.FloatVectorData |
data
The stored data as an object, can be sparse or dense.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FloatVector(U unit)
Construct a new Absolute Immutable FloatVector.
|
| Modifier and Type | Method and Description |
|---|---|
int |
cardinality()
Count the number of cells that have a non-zero value (ignores tolerance).
|
protected void |
checkIndex(int index)
Check that a provided index is valid.
|
protected void |
checkSize(float[] other)
Centralized size equality check.
|
protected void |
checkSize(FloatVector<?> other)
Centralized size equality check.
|
boolean |
equals(Object obj) |
protected abstract org.djunits.value.vfloat.vector.FloatVectorData |
getData() |
float |
getInUnit(int index)
Retrieve the value stored at a specified position in the original unit.
|
float |
getInUnit(int index,
U targetUnit)
Retrieve the value stored at a specified position converted into a specified unit.
|
float |
getSI(int index)
Retrieve the value stored at a specified position in the standard SI unit.
|
float[] |
getValuesInUnit()
Create a float[] array filled with the values in the original unit.
|
float[] |
getValuesInUnit(U targetUnit)
Create a float[] array filled with the values converted into a specified unit.
|
float[] |
getValuesSI()
Create a float[] array filled with the values in the standard SI unit.
|
int |
hashCode() |
protected FloatVectorDataSparse |
initializeSparse(SortedMap<Integer,Float> values,
int length)
Import the values from a sparse map of integers and values.
|
protected FloatVectorDataSparse |
initializeSparseMA(SortedMap<Integer,FloatScalar.Abs<U>> values,
int length)
Import the values from a sparse map of integers and values.
|
protected FloatVectorDataSparse |
initializeSparseMR(SortedMap<Integer,FloatScalar.Rel<U>> values,
int length)
Import the values from a sparse map of integers and values.
|
protected float |
safeGet(int index)
Retrieve a value in vectorSI without checking validity of the index.
|
protected void |
safeSet(int index,
float valueSI)
Modify a value in vectorSI without checking validity of the index.
|
int |
size()
Retrieve the size of the vector.
|
String |
toString() |
String |
toString(boolean verbose,
boolean withUnit)
Print this FloatVector with optional type and unit information.
|
String |
toString(U displayUnit)
Print this FloatVector with the values expressed in the specified unit.
|
String |
toString(U displayUnit,
boolean verbose,
boolean withUnit)
Print this FloatVector with the values expressed in the specified unit.
|
float |
zSum()
Compute the sum of all values of this vector.
|
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelativeclone, finalize, getClass, notify, notifyAll, wait, wait, waitget, mutable, toDense, toSparseprotected org.djunits.value.vfloat.vector.FloatVectorData data
protected FloatVector(U unit)
unit - U; the unit of the new Absolute Immutable FloatVectorprotected abstract org.djunits.value.vfloat.vector.FloatVectorData getData()
protected final FloatVectorDataSparse initializeSparse(SortedMap<Integer,Float> values, int length)
values - Map<Integer, Float>; the valueslength - the size of the vectorprotected final FloatVectorDataSparse initializeSparseMA(SortedMap<Integer,FloatScalar.Abs<U>> values, int length)
values - Map<Integer, Float>; the valueslength - the size of the vectorprotected final FloatVectorDataSparse initializeSparseMR(SortedMap<Integer,FloatScalar.Rel<U>> values, int length)
values - Map<Integer, Float>; the valueslength - the size of the vectorpublic final float[] getValuesSI()
getValuesSI in interface FloatVectorInterface<U extends Unit<U>>public final float[] getValuesInUnit()
getValuesInUnit in interface FloatVectorInterface<U extends Unit<U>>public final float[] getValuesInUnit(U targetUnit)
getValuesInUnit in interface FloatVectorInterface<U extends Unit<U>>targetUnit - U; the unit into which the values are converted for usepublic final int size()
size in interface FloatVectorInterface<U extends Unit<U>>protected final void checkIndex(int index)
throws ValueException
index - int; the value to checkValueException - when index is invalidpublic final float getSI(int index)
throws ValueException
getSI in interface FloatVectorInterface<U extends Unit<U>>index - int; index of the value to retrieveValueException - when index out of range (index < 0 or index >= size())public final float getInUnit(int index)
throws ValueException
getInUnit in interface FloatVectorInterface<U extends Unit<U>>index - int; index of the value to retrieveValueException - when index out of range (index < 0 or index >= size())public final float getInUnit(int index,
U targetUnit)
throws ValueException
getInUnit in interface FloatVectorInterface<U extends Unit<U>>index - int; index of the value to retrievetargetUnit - U; the unit for the resultValueException - when index out of range (index < 0 or index >= size())public final float zSum()
zSum in interface FloatVectorInterface<U extends Unit<U>>public final int cardinality()
cardinality in interface FloatVectorInterface<U extends Unit<U>>public final String toString()
public final String toString(U displayUnit)
toString in interface FloatVectorInterface<U extends Unit<U>>displayUnit - U; the unit into which the values are converted for displaypublic final String toString(boolean verbose, boolean withUnit)
toString in interface FloatVectorInterface<U extends Unit<U>>verbose - boolean; if true; include type info; if false; exclude type infowithUnit - boolean; if true; include the unit; of false; exclude the unitpublic final String toString(U displayUnit, boolean verbose, boolean withUnit)
toString in interface FloatVectorInterface<U extends Unit<U>>displayUnit - U; the unit into which the values are converted for displayverbose - boolean; if true; include type info; if false; exclude type infowithUnit - boolean; if true; include the unit; of false; exclude the unitprotected final void checkSize(FloatVector<?> other) throws ValueException
other - FloatVector<?>; other FloatVectorValueException - when other is null, or vectors have unequal sizeprotected final void checkSize(float[] other)
throws ValueException
other - float[]; array of floatValueException - when vectors have unequal sizeprotected final float safeGet(int index)
index - int; the indexprotected final void safeSet(int index,
float valueSI)
index - int; the indexvalueSI - float; the new value for the entry in vectorSICopyright © 2015 Delft University of Technology. All rights reserved.