public class CA2DInt
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
private int[][] |
fullMatrix
2D array contains the full matrix
|
private int[] |
lineNum
Array of unique numbers for compression
|
private int[] |
lineRep
Array of number of repetitions for compression
|
private static long |
serialVersionUID
serialVersionUID
|
private int |
sizeX
Number of rows
|
private int |
sizeY
Number of columns
|
| Constructor and Description |
|---|
CA2DInt(int sizeX,
int sizeY,
int defaultValue)
Constructor of compress 2D array
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int value,
int x,
int y)
Add a value to a single location in the array
|
void |
add(int value,
int fromX,
int fromY,
int toX,
int toY)
Add a value to a region in the array
|
void |
addColumn(int beforeColumn,
int numColumns,
int defaultValue)
Add one or more columns to array
|
void |
addRow(int beforeRow,
int numRows,
int defaultValue)
Add one or more rows to array
|
private void |
compressMatrix()
Prepare compressed data from full matrix to write out
|
void |
deepCopyFrom(CA2DInt matrix)
Initialize a compressed matrix by creating a deep copy
|
private void |
expandMatrix()
Expand compressed data to full matrix
|
int |
get(int x,
int y)
Get a single value from the array
|
int |
getSizeX()
Getter for number of rows
|
int |
getSizeY()
Getter for the number of columns
|
void |
multiply(int value,
int x,
int y)
Multiply a value to a single location in the array
|
void |
multiply(int value,
int fromX,
int fromY,
int toX,
int toY)
Multiply a value to a region in the array
|
private void |
readObject(java.io.ObjectInputStream in)
Read object from input stream
|
void |
removeColumn(int column)
Remove a single column from array
|
void |
removeColumn(int fromColumn,
int toColumn)
Remove multiple columns from array
|
void |
removeRow(int row)
Remove a single row from array
|
void |
removeRow(int fromRow,
int toRow)
Remove multiple rows from array
|
void |
set(int value,
int x,
int y)
Set a value to a single location in the array
|
void |
set(int value,
int fromX,
int fromY,
int toX,
int toY)
Set a value to a region in the array
|
private void |
writeObject(java.io.ObjectOutputStream out)
Write object to output stream
|
private static final long serialVersionUID
private int sizeX
private int sizeY
private int[][] fullMatrix
private int[] lineNum
private int[] lineRep
public CA2DInt(int sizeX,
int sizeY,
int defaultValue)
sizeX - Number of rowssizeY - Number of columnsdefaultValue - Default value in the arraypublic void set(int value,
int x,
int y)
value - new valuex - row indexy - column indexpublic void set(int value,
int fromX,
int fromY,
int toX,
int toY)
value - new valuefromX - from row index (inclusive)fromY - from column index (inclusive)toX - to row index (inclusive)toY - to column index (inclusive)public void add(int value,
int x,
int y)
value - value to be addedx - row indexy - column indexpublic void add(int value,
int fromX,
int fromY,
int toX,
int toY)
value - value to be addedfromX - from row index (inclusive)fromY - from column index (inclusive)toX - to row index (inclusive)toY - to column index (inclusive)public void multiply(int value,
int x,
int y)
value - value to be multipliedx - row indexy - column indexpublic void multiply(int value,
int fromX,
int fromY,
int toX,
int toY)
value - value to be multipliedfromX - from row index (inclusive)fromY - from column index (inclusive)toX - to row index (inclusive)toY - to column index (inclusive)public void addRow(int beforeRow,
int numRows,
int defaultValue)
beforeRow - row index before which new rows to be addednumRows - number of new rows to be addeddefaultValue - default value for new added rowspublic void addColumn(int beforeColumn,
int numColumns,
int defaultValue)
beforeColumn - column index before which new columns to be addednumColumns - number of new columns to be addeddefaultValue - default value for new added columnspublic void removeRow(int row)
row - row to be removedpublic void removeRow(int fromRow,
int toRow)
fromRow - first row to be removed (inclusive)toRow - last row to be removed (inclusive)public void removeColumn(int column)
column - column to be removedpublic void removeColumn(int fromColumn,
int toColumn)
fromColumn - first column to be removed (inclusive)toColumn - last column to be removed (inclusive)public int get(int x,
int y)
x - row indexy - column indexpublic int getSizeX()
public int getSizeY()
private void writeObject(java.io.ObjectOutputStream out)
throws java.io.IOException
out - object output streamjava.io.IOExceptionprivate void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
in - object input streamjava.io.IOExceptionjava.lang.ClassNotFoundExceptionprivate void compressMatrix()
private void expandMatrix()
public void deepCopyFrom(CA2DInt matrix)
matrix - matrix to be copied from