title: Get all Indexes of the set bits in a BitSet
body: <p>I'm looking for a fast algorithm with gives me all the indexes of the set bits in a BitSet object. 
  This is slow:</p>
  
  <pre class="lang-java prettyprint-override"><code>BitSet bitSet = ...
  Collection&lt;Integer&gt; indexes = new ArrayList&lt;Integer&gt;(bitSet.cardinality());
  int nextSetBit = bitSet.nextSetBit(0);
  for (int i = 0; i &lt; bitSet.cardinality(); ++i ) {
      indexes.add(nextSetBit);
      nextSetBit = bitSet.nextSetBit(nextSetBit + 1);
  }
  ...
  </code></pre>
  
  <p>Any help is appreciated! </p>