Package dev.roanh.gmark.util
Class RangeMatrix<T>
java.lang.Object
dev.roanh.gmark.util.RangeMatrix<T>
- Type Parameters:
T
- The dta type stored in the matrix.
- Direct Known Subclasses:
SelectivityGraph.DistanceMatrix
A matrix implementation backed by a
fixed size 2 dimensional array.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRangeMatrix
(int size) Constructs a new square range matrix with the given size.RangeMatrix
(int rows, int cols) Constructs a new square range matrix with the given dimensions.RangeMatrix
(int rows, int cols, Supplier<T> init) Constructs a new range matrix with the given dimensions and initialising every matrix element with the given supplier.RangeMatrix
(int size, Supplier<T> init) Constructs a new square range matrix with the given size and initialising every matrix element with the given supplier. -
Method Summary
Modifier and TypeMethodDescriptionget
(int row, int col) Gets the element stored in the given matrix cell.Gets the element stored in the given matrix cell.Gets the element stored in the given matrix cell.Gets the element stored in the given matrix cell.int
Gets the number of columns in this matrix.int
Gets the number of rows in this matrix.void
Sets the element at the given matrix cell to the given value.void
Sets the element at the given matrix cell to the given value.void
Sets the element at the given matrix cell to the given value.void
Sets the element at the given matrix cell to the given value.
-
Field Details
-
data
The data stored in this matrix. -
rows
private int rowsThe number of rows in this matrix. -
cols
private int colsThe number of columns in this matrix.
-
-
Constructor Details
-
RangeMatrix
public RangeMatrix(int size) Constructs a new square range matrix with the given size.- Parameters:
size
- The size of the matrix.
-
RangeMatrix
public RangeMatrix(int rows, int cols) Constructs a new square range matrix with the given dimensions.- Parameters:
rows
- The number of rows in the matrix.cols
- The number of columns in the matrix.
-
RangeMatrix
Constructs a new square range matrix with the given size and initialising every matrix element with the given supplier.- Parameters:
size
- The size of the matrix.init
- The supplier to initialise all matrix elements, possiblynull
.
-
RangeMatrix
Constructs a new range matrix with the given dimensions and initialising every matrix element with the given supplier.- Parameters:
rows
- The number of rows in the matrix.cols
- The number of columns in the matrix.init
- The supplier to initialise all matrix elements, possiblynull
.
-
-
Method Details
-
get
Gets the element stored in the given matrix cell.- Parameters:
row
- The row of the cell to get.col
- The column of the cell to get.- Returns:
- The element stored in the requested matrix cell.
- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.- See Also:
-
get
Gets the element stored in the given matrix cell.- Parameters:
row
- The row of the cell to get.col
- The column of the cell to get.- Returns:
- The element stored in the requested matrix cell.
- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.- See Also:
-
get
Gets the element stored in the given matrix cell.- Parameters:
row
- The row of the cell to get.col
- The column of the cell to get.- Returns:
- The element stored in the requested matrix cell.
- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.- See Also:
-
get
Gets the element stored in the given matrix cell.- Parameters:
row
- The row of the cell to get.col
- The column of the cell to get.- Returns:
- The element stored in the requested matrix cell.
- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.
-
set
Sets the element at the given matrix cell to the given value.- Parameters:
row
- The row of the cell to set.col
- The column of the cell to set.value
- The new data to store.- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.
-
set
Sets the element at the given matrix cell to the given value.- Parameters:
row
- The row of the cell to set.col
- The column of the cell to set.value
- The new data to store.- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.
-
set
Sets the element at the given matrix cell to the given value.- Parameters:
row
- The row of the cell to set.col
- The column of the cell to set.value
- The new data to store.- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.
-
set
Sets the element at the given matrix cell to the given value.- Parameters:
row
- The row of the cell to set.col
- The column of the cell to set.value
- The new data to store.- Throws:
ArrayIndexOutOfBoundsException
- When the given index is out of bounds.
-
getRowCount
public int getRowCount()Gets the number of rows in this matrix.- Returns:
- The number of rows in this matrix.
-
getColumnCount
public int getColumnCount()Gets the number of columns in this matrix.- Returns:
- The number of columns in this matrix.
-