Flag testing
This commit is contained in:
@@ -37,6 +37,16 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class mbEnums {
|
||||
|
||||
public static <T extends Enum<T>> int toInt(EnumSet<T> enumSet) {
|
||||
|
||||
int bitvector = 0;
|
||||
|
||||
for (T value : enumSet)
|
||||
bitvector |= 1 << value.ordinal();
|
||||
|
||||
return bitvector;
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> long toLong(EnumSet<T> enumSet) {
|
||||
|
||||
long bitvector = 0L;
|
||||
|
||||
Reference in New Issue
Block a user