public class Flags extends Object
Note, that usage of this class to store int flags instead of boolean flags is
efficient (in case of memory usage) only if you need to store and handle more than 4 boolean
flags. It's because, the size of this object will be "always" 16 bytes and at the other hand
the size of each of boolean flag is 4 bytes so if you have for example 8 booleans
to handle some states, these boolean fields will together use 24 bytes of an available
memory.
Of course, significant memory savings can be visible only in case when this class is used within the context of a class of which instances are in an android application used and instantiated in large amount, like hundreds or thousands of instances and more.
| Constructor and Description |
|---|
Flags()
Creates a new instance of Flags with current flags initialized to
0. |
Flags(int flags)
Creates a new instance of Flags with the initial flags value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int flag)
Adds the specified flag to the current ones (if not presented yet).
|
int |
get()
Returns a value of the current flags.
|
boolean |
has(int flag)
Checks whether the requested flag is presented within the current flags or not.
|
void |
remove(int flag)
Removes the specified flag from the current ones (if presented).
|
void |
reset()
Resets value of this flags to
0. |
public Flags()
0.public Flags(int flags)
flags - The initial value for flags.public void add(int flag)
public void remove(int flag)
public boolean has(int flag)
flag - The desired flag to check.True if flag is presented, false otherwise.add(int),
remove(int),
get()public int get()
public void reset()
0.