package school_project.Utils;

import java.util.Arrays;

public class Array{
    public static boolean[][] MatrixCopyOf(boolean[][] o){
        boolean[][] ret =  new boolean[o.length][];
        for (int i = 0; i < o.length; i++){
            ret[i] = Arrays.copyOf(o[i], o[i].length);
        }
        return ret;
    }

    public static boolean[][] MatrixRemoveRow(boolean[][] o, int row){
        boolean[][] newMatrix = new boolean[o.length - 1][o[0].length];
        int newRow = 0;
        for (int i = 0; i < o.length; i++) {
            if(i == row)
                i++;
            if(i >= o.length)
                continue;
            newMatrix[newRow] = o[i];
            newRow++;
        }
        return newMatrix;
    }

    public static boolean[][] MatrixRemoveColumn(boolean[][] o, int col){
        boolean[][] newMatrix = new boolean[o.length][o[0].length - 1];
        for (int i = 0; i < o.length; i++) {
            int newCol = 0;
            for(int j = 0; j < o[0].length; j++){
                if(j == col)
                    j++;
                if(j >= o[0].length)
                    continue;
                newMatrix[i][newCol] = o[i][j];
                newCol++;
            }
        }
        return newMatrix;
    }

    public static boolean isRowOnlyFalse(boolean[][] o, int row){
        boolean mark = true;
        for (int i = 0; i < o[row].length; i++) {
            if(o[row][i])
                mark = false;
        }
        return mark;
    }

    public static boolean isColumnOnlyFalse(boolean[][] o, int column){
        boolean mark = true;
        for (int i = 0; i < o.length; i++) {
            if(o[i][column])
                mark = false;
        }
        return mark;
    }
}
