Class Vector.View<V extends Vector>

java.lang.Object
de.linusdev.lutils.math.vector.Vector.View<V>
Type Parameters:
V - FloatN, IntN or LongN
All Implemented Interfaces:
Vector
Direct Known Subclasses:
FloatN.View
Enclosing interface:
Vector

public abstract static class Vector.View<V extends Vector> extends Object implements Vector
  • Nested Class Summary

    Nested classes/interfaces inherited from interface de.linusdev.lutils.math.vector.Vector

    Vector.View<V extends Vector>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int @NotNull []
     
    protected final V
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    View(V original, int @NotNull [] mapping)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Vector.View<V>
    Used to avoid unsafe casting.
    @NotNull Object
    The factor for each component.
    int @NotNull []
    The returned mapping must always map to a non view vector.
     
    abstract boolean
     
    boolean
    Whether this vector is array backed.
    boolean
    Whether this vector is buffer backed.
    static boolean
    isMappingSpecial(int @NotNull [] defaultMapping, @NotNull Vector viewToCheck)
    Checks if the mapping of given viewToCheck is special compared to the given defaultMapping.
    static boolean
    isMappingSpecial(@NotNull Vector view)
    Checks if the mapping of given view is special.
    A non-special mapping is the following: mapping[0]=0, mapping[1]=1, ...
    or generally speaking: mapping[i]=i.
    Everything else is a special mapping.
    boolean
    Whether this vector is only a view onto another vector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.linusdev.lutils.math.vector.Vector

    getMemberCount, getStructure
  • Field Details

    • original

      @NotNull protected final V extends Vector original
    • mapping

      protected final int @NotNull [] mapping
  • Constructor Details

    • View

      protected View(@NotNull V original, int @NotNull [] mapping)
  • Method Details

    • isMappingSpecial

      public static boolean isMappingSpecial(@NotNull @NotNull Vector view)
      Checks if the mapping of given view is special.
      A non-special mapping is the following: mapping[0]=0, mapping[1]=1, ...
      or generally speaking: mapping[i]=i.
      Everything else is a special mapping.
      Parameters:
      view - Vector, which must be a view.
      Returns:
      true if the mapping of view is special
      See Also:
    • isMappingSpecial

      public static boolean isMappingSpecial(int @NotNull [] defaultMapping, @NotNull @NotNull Vector viewToCheck)
      Checks if the mapping of given viewToCheck is special compared to the given defaultMapping. A non-special mapping is the following: mapping[0]=defaultMapping[0], mapping[1]=defaultMapping[1], ...
      or generally speaking: mapping[i]=defaultMapping[i].
      Everything else is a special mapping.
      Parameters:
      defaultMapping - the defaultMapping
      viewToCheck - Vector, which must be a view.
      Returns:
      true if the mapping of viewToCheck is special
    • getOriginal

      @NotNull public V getOriginal()
      Returns:
      the original vector this vector views to
    • getMapping

      public int @NotNull [] getMapping()
      The returned mapping must always map to a non view vector.
      Returns:
      the mapping to the original vector
      Throws:
      UnsupportedOperationException - if this vector is not a view on another vector.
    • isArrayBacked

      public boolean isArrayBacked()
      Description copied from interface: Vector
      Whether this vector is array backed.
      Specified by:
      isArrayBacked in interface Vector
      Returns:
      true if this vector is array backed.
    • isBufferBacked

      public boolean isBufferBacked()
      Description copied from interface: Vector
      Whether this vector is buffer backed. If this method returns true, Vector.getStructure() will not throw an UnsupportedOperationException.
      Specified by:
      isBufferBacked in interface Vector
      Returns:
      true if this vector is buffer backed.
    • isView

      public boolean isView()
      Description copied from interface: Vector
      Whether this vector is only a view onto another vector.
      Specified by:
      isView in interface Vector
      Returns:
      true if this vector is a view.
    • hasFactor

      public abstract boolean hasFactor()
      Returns:
      true if this view has a factor when getting/setting values.
    • getFactor

      @NotNull public @NotNull Object getFactor()
      The factor for each component. The factor[i] is used for the i-component of this view vector, not on the original.
      The returned array will always be of the same type as the vector (FloatN -> float[], ...).
      Returns:
      factor array
    • getAsView

      @NotNull public @NotNull Vector.View<V> getAsView()
      Description copied from interface: Vector
      Used to avoid unsafe casting.
      Specified by:
      getAsView in interface Vector
      Returns:
      the vector itself, but as Vector.View.