Class BitVector

  • All Implemented Interfaces:
    Cloneable, Bits

    public final class BitVector
    extends Object
    implements Cloneable, Bits
    Optimized implementation of a vector of bits. This is more-or-less like java.util.BitSet, but also includes the following:
    • a count() method, which efficiently computes the number of one bits;
    • optimized read from and write to disk;
    • inlinable get() method;
    • store and load, as bit set or d-gaps, depending on sparseness;
    NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Method Detail

      • set

        public final void set​(int bit)
        Sets the value of bit to one.
      • getAndSet

        public final boolean getAndSet​(int bit)
        Sets the value of bit to true, and returns true if bit was already set
      • clear

        public final void clear​(int bit)
        Sets the value of bit to zero.
      • get

        public final boolean get​(int bit)
        Returns true if bit is one and false if it is zero.
        Specified by:
        get in interface Bits
      • size

        public final int size()
        Returns the number of bits in this vector. This is also one greater than the number of the largest valid bit number.
      • length

        public final int length()
        Returns the number of bits in this vector. This is also one greater than the number of the largest valid bit number.
        Specified by:
        length in interface Bits
      • count

        public final int count()
        Returns the total number of one bits in this vector. This is efficiently computed and cached, so that, if the vector is not changed, no recomputation is done for repeated calls.
      • getRecomputedCount

        public final int getRecomputedCount()
        For testing