public class IntegerMatrix
extends java.lang.Object
This implementation stores the coordinates and values of non-null entries in a hash map. Hence, memory consumption depends on the number of non-null entries in the matrix rather than the dimension of the matrix.
Constructor and Description |
---|
IntegerMatrix()
Creates a new null matrix.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
get(int row,
int col)
Retrieves the integer at the given coordinates.
|
java.lang.Integer |
increment(int row,
int col)
Increments the integer value at the given coordinates by one.
|
boolean |
isEmpty()
Tests whether this matrix is a null matrix.
|
public java.lang.Integer increment(int row, int col)
row
- Matrix row number. Must not be negative.col
- Matrix column number. Must not be negative.public java.lang.Integer get(int row, int col)
row
- Matrix row number. Must not be negative.col
- Matrix column number. Must not be negative.public boolean isEmpty()
false
if the matrix has any non-zero entries, else
true
.