Class BitField

java.lang.Object
org.pepsoft.util.BitField

public class BitField extends Object
An unlimited (except by the range of the int type) two-dimensional field of bits, initially false.

This class is not thread-safe.

  • Constructor Details

    • BitField

      public BitField()
  • Method Details

    • set

      public void set(int x, int y)
      Set a bit.
      Parameters:
      x - The X coordinate of the bit to set.
      y - The Y coordinate of the bit to set.
    • reset

      public void reset(int x, int y)
      Reset a bit.
      Parameters:
      x - The X coordinate of the bit to reset.
      y - The Y coordinate of the bit to reset.
    • get

      public boolean get(int x, int y)
      Get a bit.
      Parameters:
      x - The X coordinate of the bit to get.
      y - The Y coordinate of the bit to get.
      Returns:
      true if the bit is set, false otherwise.
    • getBoundingBox

      public Rectangle getBoundingBox()
      Get the bounding box of all the bits that are set.
      Returns:
      The bounding box of all the bits that are set, or null if no bits are set.
    • visitSetBits

      public boolean visitSetBits(BitField.BitVisitor visitor)
      Perform a task for all bits that are set.
      Parameters:
      visitor - The task to perform.
      Returns:
      true if the visitor returned true for every bit and every bit was therefore visited. false if the visitor returned false for some bit and not all bits may have been visited.