Java List Remove Null Value removeNullValues(List targetValues, List> argumentValues)

Here you can find the source of removeNullValues(List targetValues, List> argumentValues)

Description

remove Null Values

License

Open Source License

Declaration

public static void removeNullValues(List<Double> targetValues, List<List<Double>> argumentValues) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Federal Institute for Risk Assessment (BfR), Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.//from   w  w  w  .ja v  a  2s . c o m
 *
 * 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/>.
 *
 * Contributors:
 *     Department Biological Safety - BfR
 *******************************************************************************/

import java.util.List;

public class Main {
    public static void removeNullValues(List<Double> targetValues, List<List<Double>> argumentValues) {
        for (int i = 0; i < targetValues.size(); i++) {
            boolean remove = false;

            if (targetValues.get(i) == null) {
                remove = true;
                continue;
            }

            if (!remove) {
                for (int j = 0; j < argumentValues.size(); j++) {
                    if (argumentValues.get(j).get(i) == null) {
                        remove = true;
                        break;
                    }
                }
            }

            if (remove) {
                targetValues.remove(i);

                for (int j = 0; j < argumentValues.size(); j++) {
                    argumentValues.get(j).remove(i);
                }

                i--;
            }
        }
    }
}

Related

  1. removeNulls(Collection list)
  2. removeNulls(final List list)
  3. removeNulls(List values)
  4. removeNulls(List list)
  5. removeNulls(List values)