Class Position

  • All Implemented Interfaces:
    java.io.Serializable

    public final class Position
    extends java.lang.Object
    implements java.io.Serializable
    Defines the position of a value within a tensor in the N-dimensional coordinate space.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Position​(java.util.Set<?> coordinates)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <CS> CS coordinateFor​(java.lang.Class<CS> dimension)  
      java.util.Set<?> coordinates()  
      boolean covers​(Position other)
      Checks if this position covers the other position, meaning that the other position is a sub position of the other.
      java.util.Set<java.lang.Class<?>> dimensionSet()
      Retrieves the dimensions of this position (i.e.
      static Position empty()  
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      boolean isConsistentWith​(java.util.Set<java.lang.Class<?>> dimensions)
      Checks if the position is consistent with the given dimensions.
      static Position of​(java.lang.Iterable<?> coordinates)
      Retrieves a position instance for the given coordinates.
      static Position of​(java.lang.Object... coordinates)
      Retrieves a position instance, representing the given coordinates.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Position

        protected Position​(java.util.Set<?> coordinates)
    • Method Detail

      • of

        public static Position of​(java.lang.Iterable<?> coordinates)
        Retrieves a position instance for the given coordinates. In order to be a valid set to create a position, the coordinates must:
        • They must be disjunct in class hierarchy (e.g. one must not inherit from another)
        • None of them must be an instance of a position
        Parameters:
        coordinates - the coordinates for which to get the position instance.
        Returns:
        a position instance with the given coordinates.
        Throws:
        java.lang.IllegalArgumentException - in case the coordinates are not a valid set for creating a position.
        java.lang.NullPointerException - if the given coordinates are null
      • of

        @SafeVarargs
        public static Position of​(java.lang.Object... coordinates)
        Retrieves a position instance, representing the given coordinates. This is a convenience method to a call to of(Iterable).
        Parameters:
        coordinates - the coordinates for which to retrieve a position instance
        Returns:
        a position instance
        Throws:
        java.lang.IllegalArgumentException - in case the coordinates are not a valid set for creating a position.
        java.lang.NullPointerException - if the given coordinates array is null
        See Also:
        of(Iterable)
      • empty

        public static Position empty()
      • coordinateFor

        public <CS> CS coordinateFor​(java.lang.Class<CS> dimension)
      • coordinates

        public java.util.Set<?> coordinates()
      • dimensionSet

        public java.util.Set<java.lang.Class<?>> dimensionSet()
        Retrieves the dimensions of this position (i.e. the type of the containing coordinates).

        NOTE! These dimensions may differ from the ones kept in the parent tensor!.

        Returns:
        the types of the coordinates
      • isConsistentWith

        public boolean isConsistentWith​(java.util.Set<java.lang.Class<?>> dimensions)
        Checks if the position is consistent with the given dimensions. Conformity means that the position contains exactly one coordinate for each dimension in the given set of dimensions (classes of coordinates).
        Parameters:
        dimensions - the dimensions for which conformity has to be checked.
        Returns:
        true if the position is conform, false if not.
      • covers

        public boolean covers​(Position other)
        Checks if this position covers the other position, meaning that the other position is a sub position of the other. In other words, this means that all the coordinates of the other position have to be contained in the coordinates of this position.
        Parameters:
        other - the other position to compare with
        Returns:
        true if this position covers the other, false otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object