Interface Bitmap

All Known Implementing Classes:
MultiBlockBitmap, SingleBlockBitmap

public interface Bitmap
Represents a set of bits indicating the presence or absence of data elements in a message. Bit indices are 1-based.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the total number of bits in the bitmap.
    int
    Returns the number of bits that are set.
    boolean
    clear(int bit)
    Clears the given bit.
    boolean
    get(int bit)
    Returns whether the given bit is set.
    default boolean
    isExtensionBit(int bit)
    Returns whether the given bit is an extension indicator.
    boolean
    set(int bit)
    Sets the given bit.
    Returns a stream of the 1-based indices of all set bits.
    byte[]
    Converts the bitmap to a byte array in big-endian bit order (bit 1 is the MSB of byte 0).
  • Method Details

    • capacity

      int capacity()
      Returns the total number of bits in the bitmap.
      Returns:
      the total number of bits.
    • get

      boolean get(int bit)
      Returns whether the given bit is set.
      Parameters:
      bit - the 1-based bit index to check.
      Returns:
      true if the bit is set, false otherwise.
      Throws:
      IllegalArgumentException - if bit is less than 1 or greater than capacity().
    • set

      boolean set(int bit)
      Sets the given bit.
      Parameters:
      bit - the 1-based bit index to set.
      Returns:
      true if the bit was not already set, false otherwise.
      Throws:
      IllegalArgumentException - if bit is less than 1 or greater than capacity().
    • clear

      boolean clear(int bit)
      Clears the given bit.
      Parameters:
      bit - the 1-based bit index to clear.
      Returns:
      true if the bit was set, false otherwise.
      Throws:
      IllegalArgumentException - if bit is less than 1 or greater than capacity().
    • cardinality

      int cardinality()
      Returns the number of bits that are set.
      Returns:
      the number of bits set.
    • stream

      IntStream stream()
      Returns a stream of the 1-based indices of all set bits.
      Returns:
      a stream of set bit indices.
    • toByteArray

      byte[] toByteArray()
      Converts the bitmap to a byte array in big-endian bit order (bit 1 is the MSB of byte 0).
      Returns:
      the byte array representation of the bitmap.
    • isExtensionBit

      default boolean isExtensionBit(int bit)
      Returns whether the given bit is an extension indicator. Extension indicators signal that additional bitmap blocks follow and cannot be used as data fields.
      Parameters:
      bit - the 1-based bit index to check.
      Returns:
      true if the bit is an extension indicator, false otherwise.