Here you can find the source of trimZeroTail(final double[] data)
Parameter | Description |
---|---|
data | the data |
public static double[] trimZeroTail(final double[] data)
//package com.java2s; /*/*from ww w.j a va2s.com*/ * Title: CloudSim Toolkit * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * * Copyright (c) 2009-2012, The University of Melbourne, Australia */ import java.util.Arrays; public class Main { /** * Trim zero tail. * * @param data the data * @return the double[] */ public static double[] trimZeroTail(final double[] data) { return Arrays.copyOfRange(data, 0, countNonZeroBeginning(data)); } /** * Count non zero beginning of the data. * * @param data the data * @return the int */ public static int countNonZeroBeginning(final double[] data) { int i = data.length - 1; while (i >= 0) { if (data[i--] != 0) { break; } } return i + 2; } }