Here you can find the source of flattenN(float[][] in, int size, int width, float[] out)
Parameter | Description |
---|---|
in | The array to be flattened |
size | The number of items to copy from the in array |
width | The number of items in the second dimension |
out | The output array to write the values to |
public static void flattenN(float[][] in, int size, int width, float[] out)
//package com.java2s; /***************************************************************************** * Web3d.org Copyright (c) 2001 - 2006 * Java Source * * This source is licensed under the GNU LGPL v2.1 * Please read http://www.gnu.org/copyleft/lgpl.html for more information * * This software comes with the standard NO WARRANTY disclaimer for any * purpose. Use it at your own risk. If there's a problem you get to fix it. * ****************************************************************************/ public class Main { /**//from ww w.j a v a2 s .c o m * Flatten a 2D array with n items in the second dimension into a 1D array. * Generic but slower then the static sized conterparts. * * @param in The array to be flattened * @param size The number of items to copy from the in array * @param width The number of items in the second dimension * @param out The output array to write the values to */ public static void flattenN(float[][] in, int size, int width, float[] out) { int count = size * width - 1; for (int i = size; --i >= 0;) { for (int j = width; --j >= 0;) { out[count--] = in[i][j]; } } } /** * Flatten a 2D array with n items in the second dimension into a 1D array. * * @param in The array to be flattened * @param size The number of items to copy from the in array * @param width The number of items in the second dimension * @param out The output array to write the values to */ public static void flattenN(double[][] in, int size, int width, double[] out) { int count = size * width - 1; for (int i = size; --i >= 0;) { for (int j = width; --j >= 0;) { out[count--] = in[i][j]; } } } }