Here you can find the source of filter(double[] data, BitSet mask)
public static double[] filter(double[] data, BitSet mask)
//package com.java2s; /*//w w w .j ava 2 s . c o m * ------------------------------------------------------------------------ Copyright 2016 by Aaron * Hart Email: Aaron.Hart@gmail.com * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License, Version 3, as published by the Free Software Foundation. * * This program 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 this program; if * not, see <http://www.gnu.org/licenses>. * --------------------------------------------------------------------- * * Created on December 14, 2016 by Aaron Hart */ import java.util.BitSet; public class Main { public static double[] filter(double[] data, BitSet mask) { double[] result = new double[mask.cardinality()]; int j = 0; for (int i = 0; i < data.length; i++) { if (mask.get(i)) { result[j] = data[i]; j++; } } return result; } }