public class FlagSet
extends java.lang.Object
NOTE: We do not use the BitSet class because it provides setting bits by index but not by the bitmask (flag).
Modifier and Type | Method and Description |
---|---|
void |
add(long flag)
Adds the specified flag to the flag set.
|
void |
and(long flag)
AND function of existing and specified flags. |
void |
clear()
Sets the flag set to zero.
|
boolean |
contains(long flag)
Verifies if the specified flag is present in the flag set.
|
boolean |
getBit(int index)
Gets the bit by the specified index.
|
int |
getBits(int from,
int to)
Returns the number from specified range of the bits.
|
long |
getFlags()
Returns the flag set value.
|
static long |
getMask(int from,
int to)
Returns the mask for specified bit range.
|
void |
or(long flag)
OR function of existing and specified flags. |
void |
remove(long flag)
Removes the specified flag from the flag set.
|
void |
setBit(int index,
boolean set)
Sets or removes the bit by specified index.
|
void |
setBits(int from,
int to,
long value) |
void |
setupFlag(long flag,
boolean set)
Sets the specified flag.
|
java.lang.String |
toString() |
public void and(long flag)
AND
function of existing and specified flags.flag
- public void or(long flag)
OR
function of existing and specified flags.flag
- public void add(long flag)
or(long)
function.flag
- flag to add.public void remove(long flag)
flag
- flag to remove.public boolean contains(long flag)
flag
- flag to check.public void clear()
public long getFlags()
public void setupFlag(long flag, boolean set)
flag
- flag to set or remove.set
- if true - set the flag; false - remove.public java.lang.String toString()
toString
in class java.lang.Object
public int getBits(int from, int to)
from
- specifies begin index of the bits range.to
- specifies end index of the bits range.public boolean getBit(int index)
index
- the bit index.public void setBit(int index, boolean set)
index
- the bit index.set
- true - set bit to 1; false - clear the bit.public void setBits(int from, int to, long value)
public static long getMask(int from, int to)
from
- specifies begin index of the bits range.to
- specifies end index of the bits range.