An IDEA Live Template for iterating through a BitSet

30 Aug 2005

I love IDEA's Live Templates, and I often find myself using java.util.BitSet. The BitSet javadoc describes a neat way of iterating through the 1 bits, and I do this often enough that it warranted a custom Live Template. Now all I need to do is hit itbs<TAB> to have this code automagically appear.

The template looks like this:

for(int $INDEX$ = $BS$.nextSetBit(0); $INDEX$ >= 0; $INDEX$ = $BS$.nextSetBit($INDEX$ + 1)) {

I've captured a few screenshots since you also have to setup variables for $INDEX$ and $BS$.

  • Home
  • Blog