de.caff.util

## Interface BitMask

- All Known Implementing Classes:
    BitMask16, BitMask32, BitMask64, BitSetBitMask

      public interface BitMask

  A set of bit flags.
  Author:
    Rammi

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `BitMask` | `and(BitMask other)` Get the result of a logical and of this bit mask and another.
    `BitMask` | `andNot(BitMask other)` Get the result of a logical and of this bit mask and the inverse of another.
    `BitMask` | `clear(int pos)` Clear the flag at the given position.
    `BitMask` | `cleared()` Get a bit mask from this where all flags are cleared.
    `BitMask` | `flip(int pos)` Flip the flag at the given position.
    `int` | `getBitCount()` Get the number of possible bits used in this flag.
    `int` | `getCardinality()` Get the number of bits set in this flag.
    `int` | `getHighestBitSet()` Get the position of the highest bit set.
    `int` | `getLowestBitSet()` Get the position of the lowest bit set.
    `boolean` | `isEmpty()` Is no flag set?
    `boolean` | `isSet(int pos)` Is the flag at the given position set?
    `int` | `low32()` Get the lower 32 bits of this mask.
    `long` | `low64()` Get the lower 64 bits of this mask.
    `BitMask` | `not()` Get the inverse of this bit mask.
    `BitMask` | `or(BitMask other)` Get the result of a logical or of this bit mask and another.
    `BitMask` | `set(int pos)` Set the flag at the given position.
    `java.util.BitSet` | `toBitSet()` Convert this bit mask into a bit set.
    `BitMask` | `xor(BitMask other)` Get the result of a logical xor (exclusive or) of this bit mask and another.

- - ### Method Detail

    - #### isSet

          boolean isSet(int pos)

      Is the flag at the given position set?
      Parameters:
        `pos` - position (non-negative)
      Returns:
        `true`: the flag is set
        `false`: the flag is not set

    - #### set

          @NotNull
          BitMask set(int pos)

      Set the flag at the given position.
      Parameters:
        `pos` - position
      Returns:
        bit mask where the flag at the given position is set

    - #### clear

          @NotNull
          BitMask clear(int pos)

      Clear the flag at the given position.
      Parameters:
        `pos` - position
      Returns:
        bit mask where the flag at the given position is cleared

    - #### getBitCount

          int getBitCount()

      Get the number of possible bits used in this flag.
      Returns:
        bit count

    - #### getCardinality

          int getCardinality()

      Get the number of bits set in this flag.
      Returns:
        set bit count

    - #### isEmpty

          boolean isEmpty()

      Is no flag set?
      Returns:
        `true`: if no flag in this bit mask is set
        `false`: if any flag in this bit mask is set

    - #### flip

          @NotNull
          BitMask flip(int pos)

      Flip the flag at the given position.
      Parameters:
        `pos` - position
      Returns:
        bit mask where the flag at the given position is flipped

    - #### not

          @NotNull
          BitMask not()

      Get the inverse of this bit mask.
      Returns:
        inverse bit mask

    - #### and

          @NotNull
          BitMask and(@NotNull
                               BitMask other)

      Get the result of a logical and of this bit mask and another.
      Parameters:
        `other` - other bit mask
      Returns:
        resulting bit mask

    - #### andNot

          @NotNull
          BitMask andNot(@NotNull
                                  BitMask other)

      Get the result of a logical and of this bit mask and the inverse of another.
      Parameters:
        `other` - other bit mask
      Returns:
        resulting bit mask

    - #### or

          @NotNull
          BitMask or(@NotNull
                              BitMask other)

      Get the result of a logical or of this bit mask and another.
      Parameters:
        `other` - other bit mask
      Returns:
        resulting bit mask

    - #### xor

          @NotNull
          BitMask xor(@NotNull
                               BitMask other)

      Get the result of a logical xor (exclusive or) of this bit mask and another.
      Parameters:
        `other` - other bit mask
      Returns:
        resulting bit mask

    - #### toBitSet

          @NotNull
          java.util.BitSet toBitSet()

      Convert this bit mask into a bit set.
      Returns:
        bit set

    - #### low32

          int low32()

      Get the lower 32 bits of this mask.
      Returns:
        lower 32 bits as an int

    - #### low64

          long low64()

      Get the lower 64 bits of this mask.
      Returns:
        lower 64 bits

    - #### getLowestBitSet

          int getLowestBitSet()

      Get the position of the lowest bit set.
      Returns:
        position of the lowest bit set, or `-1` if no bit is set

    - #### getHighestBitSet

          int getHighestBitSet()

      Get the position of the highest bit set.
      Returns:
        position of the highest bit set, or `-1` if no bit is set

    - #### cleared

          @NotNull
          BitMask cleared()

      Get a bit mask from this where all flags are cleared.
      Returns:
        a bit mask of this type where all flags are cleared