Class ConcurrentBitSet


  • public class ConcurrentBitSet
    extends Object
    A segmented BitSet that supports greater concurrency and faster finding of clear bits.
    • Constructor Detail

      • ConcurrentBitSet

        public ConcurrentBitSet​(int maxBits,
                                int concurrencyLevel)
        Parameters:
        maxBits -
        concurrencyLevel - - should be a power of 2
    • Method Detail

      • clear

        public void clear​(int bitIndex)
      • getAndSetNextClearBit

        public int getAndSetNextClearBit()
        Makes a best effort to atomically find the next clear bit and set it
        Returns:
        the next bit index or -1 if no clear bits are found
      • getNextSegment

        public int getNextSegment()
      • getBitsSet

        public int getBitsSet​(int segment)
        return an estimate of the number of bits set
        Parameters:
        segment -
        Returns:
      • getHighestBitSet

        public int getHighestBitSet​(int segment)
        return an estimate of the highest bit (relative index) that has been set
        Parameters:
        segment -
        Returns:
      • getAndSetNextClearBit

        public int getAndSetNextClearBit​(int segment)
        Parameters:
        segment -
        Returns:
        the next clear bit index as an absolute index - not relative to a segment
      • getTotalBits

        public int getTotalBits()
      • getBitsSet

        public int getBitsSet()
      • getBitsPerSegment

        public int getBitsPerSegment()
      • setCompact

        public void setCompact​(boolean compact)
        Set to always allocate against the first available block in a segment.
        Parameters:
        compact -
      • compactHighestBitSet

        public int compactHighestBitSet​(int segment)