Class FastBitSet


  • public final class FastBitSet
    extends Object

    Simplistic version of the jdk BitSet

    No bound-checking, internal capacity must be extended explicitely.
    • Constructor Summary

      Constructors 
      Constructor Description
      FastBitSet​(int nbits)
      Creates a bit set of size nbits
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Sets all of the bits in this BitSet to false.
      void clear​(int bitIndex)
      Sets the bit specified by the index to false.
      void ensureCapacity​(int requiredBits)
      Ensures that the BitSet can hold enough bits.
      boolean flip​(int bitIndex)
      Sets the bit at the specified index to the complement of its current value.
      boolean get​(int bitIndex)
      Returns the value of the bit with the specified index.
      void set​(int bitIndex)
      Sets the bit at the specified index to true.
      int size()
      Returns the number of bits of space actually in use by this BitSet to represent bit values.
    • Constructor Detail

      • FastBitSet

        public FastBitSet​(int nbits)
        Creates a bit set of size nbits
        Parameters:
        nbits - the initial size of the bit set.
    • Method Detail

      • ensureCapacity

        public void ensureCapacity​(int requiredBits)
        Ensures that the BitSet can hold enough bits.
        Parameters:
        requiredBits - the required number of bits.
      • flip

        public boolean flip​(int bitIndex)
        Sets the bit at the specified index to the complement of its current value.
        Parameters:
        bitIndex - the index of the bit to flip
        Returns:
        true if the bit was set to, false if it was unset
      • set

        public void set​(int bitIndex)
        Sets the bit at the specified index to true.
        Parameters:
        bitIndex - a bit index.
      • clear

        public void clear​(int bitIndex)
        Sets the bit specified by the index to false.
        Parameters:
        bitIndex - the index of the bit to be cleared.
      • clear

        public void clear()
        Sets all of the bits in this BitSet to false.
      • get

        public boolean get​(int bitIndex)
        Returns the value of the bit with the specified index. The value is true if the bit with the index bitIndex is currently set in this BitSet; otherwise, the result is false.
        Parameters:
        bitIndex - the bit index.
        Returns:
        the value of the bit with the specified index.
      • size

        public int size()
        Returns the number of bits of space actually in use by this BitSet to represent bit values. The maximum element in the set is the size - 1st element.
        Returns:
        the number of bits currently in this bit set.