Package org.djunits.value.base
Class Vector<U extends Unit<U>,S extends Scalar<U,S>,V extends Vector<U,S,V,D>,D extends Storage<D>>
java.lang.Object
org.djunits.value.IndexedValue<U,S,V,D>
org.djunits.value.base.Vector<U,S,V,D>
- Type Parameters:
U
- the unitS
- the scalar type belonging to the vector typeV
- the vector type with the given unitD
- the data storage type
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<S>
,Value<U,
V>
- Direct Known Subclasses:
DoubleVector
,FloatVector
public abstract class Vector<U extends Unit<U>,S extends Scalar<U,S>,V extends Vector<U,S,V,D>,D extends Storage<D>>
extends IndexedValue<U,S,V,D>
implements Iterable<S>
Vector to distinguish a vector from vectors and matrices. A possible way to implement this interface is:
BSD-style license. See DJUNITS License.
class LengthVector implements Vector<LengthUnit, Length, LengthVector>Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
-
Method Summary
Methods inherited from class org.djunits.value.IndexedValue
cardinality, checkCopyOnWrite, clone, getData, getDisplayUnit, getScalarClass, getStorageType, immutable, isCopyOnWrite, isDense, isMutable, isSparse, mutable, setCopyOnWrite, setData, setDisplayUnit, setMutable, toDense, toSparse
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Vector
Construct a new Vector.- Parameters:
displayUnit
- U; the unit of the new AbstractValue
-
-
Method Details
-
size
public abstract int size()Retrieve the size of the vector.- Returns:
- int; the size of the vector
-
get
Retrieve a value from the vector.- Parameters:
index
- int; the index to retrieve the value at- Returns:
- S; the value as a Scalar
- Throws:
IndexOutOfBoundsException
- in case index is out of bounds
-
getScalars
Return the vector as an array of scalars.- Returns:
- S[]; the vector as an array of scalars
-
iterator
Create and return an iterator over the scalars in this vector in proper sequence.
-