Java Array Clone clone2DArray(final boolean[][] array)

Here you can find the source of clone2DArray(final boolean[][] array)

Description

Creates an independent copy of the boolean array.

License

Open Source License

Parameter

Parameter Description
array The array to be cloned

Return

An independent 'deep' structure clone of the array

Declaration

public static boolean[][] clone2DArray(final boolean[][] array) 

Method Source Code

//package com.java2s;
/*  Copyright 2010 Ben Ruijl, Wouter Smeenk
    //from   www.  j a  va2s. co  m
This file is part of Walled In.
    
Walled In is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
    
Walled In is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Walled In; see the file LICENSE.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
    
 */

public class Main {
    /**
     * Creates an independent copy of the boolean array. This involves cloning
     * the structure and the data itself.
     * 
     * @param array
     *            The array to be cloned
     * @return An independent 'deep' structure clone of the array
     */
    public static boolean[][] clone2DArray(final boolean[][] array) {
        final int rows = array.length;

        final boolean[][] newArray = array.clone();

        for (int row = 0; row < rows; row++) {
            newArray[row] = array[row].clone();
        }

        return newArray;
    }
}

Related

  1. clone(T[] array)
  2. clone(T[] array)
  3. clone2DArray(double[][] a)
  4. clone2DArray(Double[][] array)
  5. clone2dArray(double[][] myArray)
  6. clone_multidim_array(float[][] arr)
  7. cloneAndMultiplyArray(float[] array, float factor)
  8. cloneArray(boolean[][] src)
  9. cloneArray(byte[] bytes)