Java BitSet findTrue(BitSet set)

Here you can find the source of findTrue(BitSet set)

Description

Returns an array containing all numbers of bits that are set to true.

License

Open Source License

Parameter

Parameter Description
set the set to be processed

Return

a list of all true bits in this set

Declaration

public static int[] findTrue(BitSet set) 

Method Source Code


//package com.java2s;
import java.util.BitSet;

public class Main {
    /**//  www . ja va2  s .  c o  m
     * Returns an array containing all numbers of bits that are set to true.
     * @param set the set to be processed
     * @return a list of all true bits in this set
     */
    public static int[] findTrue(BitSet set) {
        int[] ret = new int[set.cardinality()];
        int offset = 0;

        for (int idx = set.nextSetBit(0); idx >= 0; idx = set.nextSetBit(idx + 1)) {
            ret[offset++] = idx;
        }
        return ret;
    }
}

Related

  1. extractLong(BitSet bitSet, int from, int to)
  2. extractSetBitsMsgFromTxSet(final BitSet txSet)
  3. filter(double[] data, BitSet mask)
  4. filterByIndices(List list, BitSet filter)
  5. filtered(final Iterator iterator, final BitSet filter)
  6. firstIndexOfChar(String sqlString, BitSet keys, int startindex)
  7. firstInvalidOctet(CharSequence cs, BitSet bits)
  8. formatBitset(BitSet bitset, int width)
  9. generateBitSetBySize(int size, boolean initValue)