Java BitSet filterByIndices(List list, BitSet filter)

Here you can find the source of filterByIndices(List list, BitSet filter)

Description

filter By Indices

License

Open Source License

Declaration

static public <E> List<E> filterByIndices(List<E> list, BitSet filter) 

Method Source Code


//package com.java2s;
/*/*w w w  .  j  av  a  2s .c om*/
 * Copyright (c) 2015 Villu Ruusmann
 *
 * This file is part of JPMML-Converter
 *
 * JPMML-Converter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JPMML-Converter 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with JPMML-Converter.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;

public class Main {
    static public <E> List<E> filterByIndices(List<E> list, BitSet filter) {
        List<E> result = new ArrayList<>(list.size());

        for (int i = 0; i < list.size(); i++) {
            E element = list.get(i);

            if (filter.get(i)) {
                result.add(element);
            }
        }

        return result;
    }
}

Related

  1. escape(String s, BitSet safeChars)
  2. expand(final BitSet bits, final BitSet add)
  3. extractLong(BitSet bitSet, int from, int to)
  4. extractSetBitsMsgFromTxSet(final BitSet txSet)
  5. filter(double[] data, BitSet mask)
  6. filtered(final Iterator iterator, final BitSet filter)
  7. findTrue(BitSet set)
  8. firstIndexOfChar(String sqlString, BitSet keys, int startindex)
  9. firstInvalidOctet(CharSequence cs, BitSet bits)