public class MemoryCoOccurrenceMatrix extends java.lang.Object implements CoOccurrenceMatrix
Modifier and Type | Field and Description |
---|---|
private int[] |
data |
private int |
dimension |
private int |
dimSquare |
Constructor and Description |
---|
MemoryCoOccurrenceMatrix(int dimension)
Creates a new matrix that stores dimension times dimension int values in memory.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Sets all counters to zero.
|
int |
getDimension()
Returns the dimension of this matrix.
|
int |
getValue(int i,
int j)
Returns the matrix value at a given position.
|
void |
incValue(int i,
int j)
Increases the counter for pair (i, j) by one.
|
void |
setValue(int i,
int j,
int newValue)
Sets the counter for pair (i, j) to a new value.
|
private final int dimension
private final int dimSquare
private final int[] data
public MemoryCoOccurrenceMatrix(int dimension)
dimension
- the matrix' dimension, which is both the number of rows and columnspublic void clear()
CoOccurrenceMatrix
clear
in interface CoOccurrenceMatrix
public int getDimension()
CoOccurrenceMatrix
getDimension
in interface CoOccurrenceMatrix
public int getValue(int i, int j)
CoOccurrenceMatrix
getValue
in interface CoOccurrenceMatrix
i
- column index, from 0 to CoOccurrenceMatrix.getDimension()
- 1j
- row index, from 0 to CoOccurrenceMatrix.getDimension()
- 1public void incValue(int i, int j) throws java.lang.IllegalArgumentException
CoOccurrenceMatrix
setValue(i, j, getValue(i, j) + 1);
.incValue
in interface CoOccurrenceMatrix
i
- column index, from 0 to CoOccurrenceMatrix.getDimension()
- 1j
- row index, from 0 to CoOccurrenceMatrix.getDimension()
- 1java.lang.IllegalArgumentException
- for invalid index pairs (i, j)public void setValue(int i, int j, int newValue)
CoOccurrenceMatrix
setValue
in interface CoOccurrenceMatrix
i
- column index, from 0 to CoOccurrenceMatrix.getDimension()
- 1j
- row index, from 0 to CoOccurrenceMatrix.getDimension()
- 1