Package overit.geocall.util
Class SimpleMatrix
java.lang.Object
overit.geocall.util.SimpleMatrix
- All Implemented Interfaces:
Serializable,Matrix
Auxiliary class that implements the interface
Matrix and must be used
to create and manage a matrix. The class exposes two constructors, one to create
an empty matrix and one to create a matrix and fill it. It is possible to invert
the columns with the rows and obtain or set a single element of the matrix.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleMatrix(int w, int h) Create an empty matrix of width'w'(and then'w'columns) and height'h'(and then'h'rows).SimpleMatrix(int w, int h, Object[] oo) Create and fill a matrix of width'w'(and then'w'columns) and height'h'(and then'h'rows).
The array must contain the elements to be inserted into the matrix and is read this way: the first'w'elements (and then from index'0'to'w-1'of the array) are the elements to insert in the first row. -
Method Summary
Modifier and TypeMethodDescriptionget(int x, int y) Gets the element presents in the matrix in row'x'and in column'y'.intGets the height of the matrix.intgetWidth()Gets the width of the matrix.voidinvert()Inverts the columns of the matrix with the rows and viceversa.voidSets the element in the matrix to row'x'and in column'y'.toString()
-
Field Details
-
_inverted
protected boolean _inverted
-
-
Constructor Details
-
SimpleMatrix
public SimpleMatrix(int w, int h) Create an empty matrix of width'w'(and then'w'columns) and height'h'(and then'h'rows).- Parameters:
w- width of the matrix (or number of columns).h- height of the matrix (or number of rows).
-
SimpleMatrix
Create and fill a matrix of width'w'(and then'w'columns) and height'h'(and then'h'rows).
The array must contain the elements to be inserted into the matrix and is read this way: the first'w'elements (and then from index'0'to'w-1'of the array) are the elements to insert in the first row. The second'w'elements (and then from index'w'to'2w-1'of the array) are the elements to insert in the second row and so on.- Parameters:
w- width of the matrix (or number of columns).h- height of the matrix (or number of rows).oo- The array contains the elements to insert into the matrix.
-
-
Method Details
-
get
Gets the element presents in the matrix in row'x'and in column'y'. The indeces start from'0' -
set
Sets the element in the matrix to row'x'and in column'y'. -
getWidth
public int getWidth()Gets the width of the matrix. -
getHeight
public int getHeight()Gets the height of the matrix. -
invert
public void invert()Inverts the columns of the matrix with the rows and viceversa. -
toString
-