Java Matrix Copy copyMatrix(boolean[][] old)

Here you can find the source of copyMatrix(boolean[][] old)

Description

copy Matrix

License

Apache License

Declaration

public static boolean[][] copyMatrix(boolean[][] old) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static boolean[][] copyMatrix(boolean[][] old) {
        return copyMatrix(old, old.length);
    }//from  www  .  j av a 2s .c  om

    public static boolean[][] copyMatrix(boolean[][] old, int upToRow) {
        int m = Math.min(old.length, upToRow);
        if (m == 0) {
            return null;
        }
        int n = old[0].length;
        boolean[][] duplicate = new boolean[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                duplicate[i][j] = old[i][j];
            }
        }

        return duplicate;
    }
}

Related

  1. copyMatrix(boolean[][] matrix)
  2. copyMatrix(final double[][] c)
  3. copyMatrix(final double[][] src, final double[][] dest, int n)
  4. copyMatrix(final int rowsCount, final int columnsCount, final double[][] origMatrix)
  5. copyMatrix(float[] origin, float destination[])