Java Array Clone clone_multidim_array(float[][] arr)

Here you can find the source of clone_multidim_array(float[][] arr)

Description

copies a 2D float array

License

Open Source License

Parameter

Parameter Description
arr a parameter

Declaration

public static float[][] clone_multidim_array(float[][] arr) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ******************************************************************************/

public class Main {
    /*******************
     * copies a 2D float array//from ww  w. java  2 s  .  c om
     * @param arr
     * @return
     */
    public static float[][] clone_multidim_array(float[][] arr) {
        float[][] temp = new float[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            temp[i] = arr[i].clone();
        }
        return temp;
    }

    /*******************
     * copies a 2D int array
     * @param arr
     * @return
     */
    public static int[][] clone_multidim_array(int[][] arr) {
        int[][] temp = new int[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            temp[i] = arr[i].clone();
        }
        return temp;
    }

    /************************
     * copies a 2D short array
     * @param arr
     * @return
     */
    public static short[][] clone_multidim_array(short[][] arr) {
        short[][] temp = new short[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            temp[i] = arr[i].clone();
        }
        return temp;
    }

    /************************
     * copies a 2D byte array
     * @param arr
     * @return
     */
    public static byte[][] clone_multidim_array(byte[][] arr) {
        byte[][] temp = new byte[arr.length][];
        for (int i = 0; i < arr.length; i++) {
            temp[i] = arr[i].clone();
        }
        return temp;
    }
}

Related

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