Fix build warnings
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
//Matrix/src/main/java/com/mattrixwv/IntegerMatrix.java
|
||||
//Mattrixwv
|
||||
// Created: 02-01-22
|
||||
//Modified: 08-11-24
|
||||
package com.mattrixwv.matrix;
|
||||
|
||||
|
||||
@@ -26,18 +22,17 @@ public class IntegerMatrix{
|
||||
|
||||
//?Helper functions
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
* Validates that all rows in the grid are of equal length.
|
||||
*
|
||||
* @param grid The 2D array to set as the matrix grid.
|
||||
* @param grid The 2D array to validate.
|
||||
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
|
||||
*/
|
||||
protected void setGrid(int[][] grid){
|
||||
private int[][] validateGrid(int[][] grid){
|
||||
if(grid.length == 0){
|
||||
this.grid = new int[0][0];
|
||||
return new int[0][0];
|
||||
}
|
||||
else if(grid[0].length == 0){
|
||||
this.grid = new int[grid.length][0];
|
||||
return new int[grid.length][0];
|
||||
}
|
||||
else{
|
||||
//Make sure all rows are the same length
|
||||
@@ -55,9 +50,19 @@ public class IntegerMatrix{
|
||||
}
|
||||
|
||||
//Save the new grid
|
||||
this.grid = newGrid;
|
||||
return newGrid;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
|
||||
* all rows are of equal length.
|
||||
*
|
||||
* @param grid The 2D array to set as the matrix grid.
|
||||
* @throws InvalidRowSizeException If the rows of the matrix are not all the same length.
|
||||
*/
|
||||
protected void setGrid(int[][] grid){
|
||||
this.grid = validateGrid(grid);
|
||||
}
|
||||
/**
|
||||
* Creates a deep copy of the matrix grid.
|
||||
*
|
||||
@@ -158,7 +163,7 @@ public class IntegerMatrix{
|
||||
* @param grid The 2D array to initialize the matrix with.
|
||||
*/
|
||||
public IntegerMatrix(int[][] grid){
|
||||
setGrid(grid);
|
||||
this.grid = validateGrid(grid);
|
||||
}
|
||||
/**
|
||||
* Constructs a copy of the specified matrix.
|
||||
@@ -166,7 +171,7 @@ public class IntegerMatrix{
|
||||
* @param matrix The matrix to copy.
|
||||
*/
|
||||
public IntegerMatrix(IntegerMatrix matrix){
|
||||
setGrid(matrix.grid);
|
||||
this.grid = validateGrid(matrix.grid);
|
||||
}
|
||||
/**
|
||||
* Constructs a matrix with the specified number of rows and columns, filled with the specified value.
|
||||
|
||||
Reference in New Issue
Block a user