Module id.xfunction

Class IntBitSet

Object
IntBitSet

public class IntBitSet extends Object
BitSet implementation which uses ints to represent words.

Java standard BitSet uses long as a word which means if you need to obtain all words as an array of integers you will need to create a new int array and copy all bits from BitSet.

When this is done very often it can decrease performance.

This class is using int as word so it is possible to obtain array of integers with no cost.

  • Constructor Details

    • IntBitSet

      public IntBitSet(int len)
      Parameters:
      len - number of bits which are going to be stored
    • IntBitSet

      public IntBitSet(int[] array)
      Parameters:
      array - creates new IntBitSet backed up by given array
  • Method Details

    • flip

      public void flip(int fromIndex, int toIndex)
      Flips all bits between [fromIndex, toIndex)
    • flip

      public int flip(int word, int fromIndex, int toIndex)
    • flip

      public void flip(int i)
      Flip single bit by its position
    • intArray

      public int[] intArray()
      Returns:
      internal int array
    • nextSetBit

      public int nextSetBit(int fromIndex)
      Returns the index of the first bit that is set to true that occurs on or after the specified starting index. If no such bit exists then return -1
    • toBinaryString

      public String toBinaryString()