Class MatrixInt

java.lang.Object
com.topologi.diffx.algorithm.MatrixInt
All Implemented Interfaces:
Matrix

public final class MatrixInt extends Object implements Matrix
A matrix implementation which backbone is a matrix of integers.
Version:
7 April 2005
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int[][]
    The actual matrix storing the values.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get(int i, int j)
    Returns the value at the given position.
    void
    incrementByMaxPath(int i, int j)
    Increment by the maximum path.
    void
    incrementPathBy(int i, int j, int n)
    Increment the path.
    boolean
    isGreaterX(int i, int j)
    Returns true we should move on the X direction.
    boolean
    isGreaterY(int i, int j)
    Returns true we should move on the X direction.
    boolean
    isSameXY(int i, int j)
    Returns true we moving on the X direction is equivalent to moving on the Y direction.
    void
    Gets rid of the underlying matrix so that garbage collector can do its work.
    void
    set(int i, int j, int x)
    Sets the value of the matrix at the given position.
    void
    setup(int width, int height)
    Create a matrix of the given width and height.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • matrix

      private int[][] matrix
      The actual matrix storing the values.
  • Constructor Details

    • MatrixInt

      public MatrixInt()
  • Method Details

    • setup

      public void setup(int width, int height)
      Description copied from interface: Matrix
      Create a matrix of the given width and height.
      Specified by:
      setup in interface Matrix
      Parameters:
      width - The number of columns.
      height - The number of rows.
      See Also:
    • set

      public void set(int i, int j, int x)
      Description copied from interface: Matrix
      Sets the value of the matrix at the given position.
      Specified by:
      set in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      x - The value to set.
      See Also:
    • get

      public int get(int i, int j)
      Description copied from interface: Matrix
      Returns the value at the given position.
      Specified by:
      get in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      Returns:
      The value at the given position.
      See Also:
    • incrementPathBy

      public void incrementPathBy(int i, int j, int n)
      Description copied from interface: Matrix
      Increment the path.

      value(i, j) := value(i+1, j+1) + n

      Specified by:
      incrementPathBy in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      n - The increment number.
      See Also:
    • incrementByMaxPath

      public void incrementByMaxPath(int i, int j)
      Description copied from interface: Matrix
      Increment by the maximum path.

      value(i, j) := max( value(i+1, j) , value(i, j+1) )

      Specified by:
      incrementByMaxPath in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      See Also:
    • isGreaterX

      public boolean isGreaterX(int i, int j)
      Description copied from interface: Matrix
      Returns true we should move on the X direction.

      if value(i+1, j) > value(i, j+1)

      Specified by:
      isGreaterX in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      Returns:
      true to move to i+1; false otherwise.
      See Also:
    • isGreaterY

      public boolean isGreaterY(int i, int j)
      Description copied from interface: Matrix
      Returns true we should move on the X direction.

      if value(i+1, j) < value(i, j+1)

      Specified by:
      isGreaterY in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      Returns:
      true to move to j+1; false otherwise.
      See Also:
    • isSameXY

      public boolean isSameXY(int i, int j)
      Description copied from interface: Matrix
      Returns true we moving on the X direction is equivalent to moving on the Y direction.

      if value(i+1, j) == value(i, j+1)

      Specified by:
      isSameXY in interface Matrix
      Parameters:
      i - The column index.
      j - The row index.
      Returns:
      true if it is the same; false otherwise.
      See Also:
    • release

      public void release()
      Gets rid of the underlying matrix so that garbage collector can do its work.
      Specified by:
      release in interface Matrix
      See Also: