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 unit
S - the scalar type belonging to the vector type
V - the vector type with the given unit
D - 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:
 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 Details

    • Vector

      public Vector(U displayUnit)
      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

      public abstract S get(int index) throws ValueRuntimeException
      Retrieve a value from the vector.
      Parameters:
      index - int; the index to retrieve the value at
      Returns:
      S; the value as a Scalar
      Throws:
      ValueRuntimeException - in case index is out of bounds
    • getScalars

      public abstract S[] getScalars()
      Return the vector as an array of scalars.
      Returns:
      S[]; the vector as an array of scalars
    • iterator

      public abstract Iterator<S> iterator()
      Create and return an iterator over the scalars in this vector in proper sequence.
      Specified by:
      iterator in interface Iterable<U extends Unit<U>>
      Returns:
      Iterator<S>; an iterator over the scalars in this vector in proper sequence