Package org.pepsoft.util
Class BitField
java.lang.Object
org.pepsoft.util.BitField
An unlimited (except by the range of the
int type)
two-dimensional field of bits, initially false.
This class is not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA visitor of bits on a 2D plane. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanget(int x, int y) Get a bit.Get the bounding box of all the bits that are set.voidreset(int x, int y) Reset a bit.voidset(int x, int y) Set a bit.booleanvisitSetBits(BitField.BitVisitor visitor) Perform a task for all bits that are set.
-
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:
trueif the bit is set,falseotherwise.
-
getBoundingBox
Get the bounding box of all the bits that are set.- Returns:
- The bounding box of all the bits that are set, or
nullif no bits are set.
-
visitSetBits
Perform a task for all bits that are set.- Parameters:
visitor- The task to perform.- Returns:
trueif the visitor returnedtruefor every bit and every bit was therefore visited.falseif the visitor returnedfalsefor some bit and not all bits may have been visited.
-