Here you can find the source of findTrue(BitSet set)
Parameter | Description |
---|---|
set | the set to be processed |
public static int[] findTrue(BitSet set)
//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; } }