Java Set sub set subset(double[] vals, boolean[] select)

Here you can find the source of subset(double[] vals, boolean[] select)

Description

subset

License

LGPL

Declaration

public static double[] subset(double[] vals, boolean[] select) 

Method Source Code

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

import java.util.*;

public class Main {
    public static double[] subset(double[] vals, boolean[] select) {
        assert vals.length == select.length;

        List<Double> list = new ArrayList<Double>();
        for (int i = 0; i < vals.length; i++) {
            if (select[i] && !Double.isNaN(vals[i]))
                list.add(vals[i]);//from   w w  w .  ja  v  a 2 s  . c o  m
        }
        double[] sub = new double[list.size()];

        int i = 0;
        for (Double val : list) {
            sub[i++] = val;
        }
        return sub;
    }
}

Related

  1. getFirstSubString(String s, Set delimiters)
  2. getSubsets(Set set)
  3. split(Set original, int subsetSize)
  4. sub(Set a, Set b)
  5. subset(Set sub, Set sup)
  6. subSet(Set nn, T n)