|
|
|
@ -35,11 +35,13 @@ import java.util.concurrent.ThreadLocalRandom;
@@ -35,11 +35,13 @@ import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
public class mbEnums { |
|
|
|
|
|
|
|
|
|
public static <T extends Enum<T>> long toLong(EnumSet<T> enumSet) { |
|
|
|
|
long r = 0; |
|
|
|
|
for (T value : enumSet) { |
|
|
|
|
r |= 1L << value.ordinal(); |
|
|
|
|
} |
|
|
|
|
return r; |
|
|
|
|
|
|
|
|
|
long bitvector = 0L; |
|
|
|
|
|
|
|
|
|
for (T value : enumSet) |
|
|
|
|
bitvector |= 1L << value.ordinal(); |
|
|
|
|
|
|
|
|
|
return bitvector; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static <E extends java.lang.Enum<E>> EnumSet<E> fromLong(long bitVector, Class<E> enumClass) { |
|
|
|
|