Fix build warnings

This commit is contained in:
2026-01-25 23:52:56 -05:00
parent bd11bd240e
commit 02e5ed607e
5 changed files with 92 additions and 67 deletions

View File

@@ -1,7 +1,3 @@
//Matrix/src/main/java/com/mattrixwv/matrix/LongMatrix.java
//Mattrixwv
// Created: 02-10-22
//Modified: 08-11-24
package com.mattrixwv.matrix;
@@ -26,18 +22,17 @@ public class LongMatrix{
//?Helper functions
/**
* Sets the matrix grid to the specified 2D array. Validates the input to ensure
* all rows are of equal length.
* 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.
* @return the new validated grid
*/
protected void setGrid(long[][] grid){
private long[][] validateGrid(long[][] grid){
if(grid.length == 0){
this.grid = new long[0][0];
return new long[0][0];
}
else if(grid[0].length == 0){
this.grid = new long[grid.length][0];
return new long[grid.length][0];
}
else{
//Make sure all rows are the same length
@@ -55,9 +50,19 @@ public class LongMatrix{
}
//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(long[][] grid){
this.grid = validateGrid(grid);
}
/**
* Creates a deep copy of the matrix grid.
*
@@ -158,7 +163,7 @@ public class LongMatrix{
* @param grid The 2D array to initialize the matrix with.
*/
public LongMatrix(long[][] grid){
setGrid(grid);
this.grid = validateGrid(grid);
}
/**
* Constructs a copy of the specified matrix.
@@ -166,7 +171,7 @@ public class LongMatrix{
* @param matrix The matrix to copy.
*/
public LongMatrix(LongMatrix 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.