Constructor and Description |
---|
MatrixInt() |
Modifier and Type | Method and 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 |
release()
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.
|
public void setup(int width, int height)
Matrix
setup
in interface Matrix
width
- The number of columns.height
- The number of rows.Matrix.setup(int, int)
public void set(int i, int j, int x)
Matrix
set
in interface Matrix
i
- The column index.j
- The row index.x
- The value to set.Matrix.set(int, int, int)
public int get(int i, int j)
Matrix
get
in interface Matrix
i
- The column index.j
- The row index.Matrix.get(int, int)
public void incrementPathBy(int i, int j, int n)
Matrix
value(i, j) := value(i+1, j+1) + n
incrementPathBy
in interface Matrix
i
- The column index.j
- The row index.n
- The increment number.Matrix.incrementPathBy(int, int, int)
public void incrementByMaxPath(int i, int j)
Matrix
value(i, j) := max( value(i+1, j) , value(i, j+1) )
incrementByMaxPath
in interface Matrix
i
- The column index.j
- The row index.Matrix.incrementByMaxPath(int, int)
public boolean isGreaterX(int i, int j)
Matrix
true
we should move on the X direction.
if value(i+1, j) > value(i, j+1)
isGreaterX
in interface Matrix
i
- The column index.j
- The row index.true
to move to i+1;
false
otherwise.Matrix.isGreaterX(int, int)
public boolean isGreaterY(int i, int j)
Matrix
true
we should move on the X direction.
if value(i+1, j) < value(i, j+1)
isGreaterY
in interface Matrix
i
- The column index.j
- The row index.true
to move to j+1;
false
otherwise.Matrix.isGreaterY(int, int)
public boolean isSameXY(int i, int j)
Matrix
true
we moving on the X direction is
equivalent to moving on the Y direction.
if value(i+1, j) == value(i, j+1)
isSameXY
in interface Matrix
i
- The column index.j
- The row index.true
if it is the same;
false
otherwise.Matrix.isSameXY(int, int)
public void release()
release
in interface Matrix
Matrix.release()
Copyright © 2007-2019. All Rights Reserved.