Package com.topologi.diffx.algorithm
Class MatrixInt
java.lang.Object
com.topologi.diffx.algorithm.MatrixInt
- All Implemented Interfaces:
Matrix
A matrix implementation which backbone is a matrix of integers.
- Version:
- 7 April 2005
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintget(int i, int j) Returns the value at the given position.voidincrementByMaxPath(int i, int j) Increment by the maximum path.voidincrementPathBy(int i, int j, int n) Increment the path.booleanisGreaterX(int i, int j) Returnstruewe should move on the X direction.booleanisGreaterY(int i, int j) Returnstruewe should move on the X direction.booleanisSameXY(int i, int j) Returnstruewe moving on the X direction is equivalent to moving on the Y direction.voidrelease()Gets rid of the underlying matrix so that garbage collector can do its work.voidset(int i, int j, int x) Sets the value of the matrix at the given position.voidsetup(int width, int height) Create a matrix of the given width and height.
-
Field Details
-
matrix
private int[][] matrixThe actual matrix storing the values.
-
-
Constructor Details
-
MatrixInt
public MatrixInt()
-
-
Method Details
-
setup
public void setup(int width, int height) Description copied from interface:MatrixCreate a matrix of the given width and height. -
set
public void set(int i, int j, int x) Description copied from interface:MatrixSets the value of the matrix at the given position. -
get
public int get(int i, int j) Description copied from interface:MatrixReturns the value at the given position. -
incrementPathBy
public void incrementPathBy(int i, int j, int n) Description copied from interface:MatrixIncrement the path.value(i, j) := value(i+1, j+1) + n
- Specified by:
incrementPathByin interfaceMatrix- 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:MatrixIncrement by the maximum path.value(i, j) := max( value(i+1, j) , value(i, j+1) )
- Specified by:
incrementByMaxPathin interfaceMatrix- Parameters:
i- The column index.j- The row index.- See Also:
-
isGreaterX
public boolean isGreaterX(int i, int j) Description copied from interface:MatrixReturnstruewe should move on the X direction.if value(i+1, j) > value(i, j+1)
- Specified by:
isGreaterXin interfaceMatrix- Parameters:
i- The column index.j- The row index.- Returns:
trueto move to i+1;falseotherwise.- See Also:
-
isGreaterY
public boolean isGreaterY(int i, int j) Description copied from interface:MatrixReturnstruewe should move on the X direction.if value(i+1, j) < value(i, j+1)
- Specified by:
isGreaterYin interfaceMatrix- Parameters:
i- The column index.j- The row index.- Returns:
trueto move to j+1;falseotherwise.- See Also:
-
isSameXY
public boolean isSameXY(int i, int j) Description copied from interface:MatrixReturnstruewe moving on the X direction is equivalent to moving on the Y direction.if value(i+1, j) == value(i, j+1)
-
release
public void release()Gets rid of the underlying matrix so that garbage collector can do its work.
-