Java Array Clone clone(int[] in)

Here you can find the source of clone(int[] in)

Description

clone

License

Apache License

Declaration

public static final int[] clone(int[] in) 

Method Source Code

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

public class Main {
    public static final int[] clone(int[] in) {
        int nx = in.length;
        int[] out = new int[nx];
        for (int i = 0; i < nx; i++) {
            out[i] = in[i];/*from ww w .ja  v  a 2  s  .  c om*/
        }
        return out;
    }

    public static final float[] clone(float[] in) {
        int nx = in.length;
        float[] out = new float[nx];
        for (int i = 0; i < nx; i++) {
            out[i] = in[i];
        }
        return out;
    }

    public static final byte[] clone(byte[] in) {
        int nx = in.length;
        byte[] out = new byte[nx];
        for (int i = 0; i < nx; i++) {
            out[i] = in[i];
        }
        return out;
    }

    public static final double[] clone(double[] in) {
        int nx = in.length;
        double[] out = new double[nx];
        for (int i = 0; i < nx; i++) {
            out[i] = in[i];
        }
        return out;
    }

    public static final int[][] clone(int[][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int[][] out = new int[nx][ny];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++) {
                out[i][j] = in[i][j];
            }
        return out;
    }

    public static final float[][] clone(float[][] in) {
        int nx = in.length;
        int ny = in[0].length;
        float[][] out = new float[nx][ny];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++) {
                out[i][j] = in[i][j];
            }
        return out;
    }

    public static final double[][] clone(double[][] in) {
        int nx = in.length;
        int ny = in[0].length;
        double[][] out = new double[nx][ny];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++) {
                out[i][j] = in[i][j];
            }
        return out;
    }

    public static final int[][][] clone(int[][][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int nz = in[0][0].length;
        int[][][] out = new int[nx][ny][nz];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++)
                for (int k = 0; k < nz; k++) {
                    out[i][j][k] = in[i][j][k];
                }
        return out;
    }

    public static final double[][][] clone(double[][][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int nz = in[0][0].length;
        double[][][] out = new double[nx][ny][nz];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++)
                for (int k = 0; k < nz; k++) {
                    out[i][j][k] = in[i][j][k];
                }
        return out;
    }

    public static final float[][][] clone(float[][][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int nz = in[0][0].length;
        float[][][] out = new float[nx][ny][nz];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++)
                for (int k = 0; k < nz; k++) {
                    out[i][j][k] = in[i][j][k];
                }
        return out;
    }

    public static final double[][][][] clone(double[][][][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int nz = in[0][0].length;
        int nc = in[0][0][0].length;
        double[][][][] out = new double[nx][ny][nz][nc];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++)
                for (int k = 0; k < nz; k++)
                    for (int l = 0; l < nc; l++) {
                        out[i][j][k][l] = in[i][j][k][l];
                    }
        return out;
    }

    public static final float[][][][] clone(float[][][][] in) {
        int nx = in.length;
        int ny = in[0].length;
        int nz = in[0][0].length;
        int nc = in[0][0][0].length;
        float[][][][] out = new float[nx][ny][nz][nc];
        for (int i = 0; i < nx; i++)
            for (int j = 0; j < ny; j++)
                for (int k = 0; k < nz; k++)
                    for (int l = 0; l < nc; l++) {
                        out[i][j][k][l] = in[i][j][k][l];
                    }
        return out;
    }
}

Related

  1. clone(float[][] array)
  2. clone(int[] a)
  3. clone(int[] array)
  4. clone(int[] array)
  5. clone(int[] array)
  6. clone(int[] src)
  7. clone(int[] src, int[] dest)
  8. clone(Object[] array)
  9. clone(Object[] array)