24 */
25
26 package java.util;
27
28 /**
29 * Private implementation class for EnumSet, for "jumbo" enum types
30 * (i.e., those with more than 64 elements).
31 *
32 * @author Josh Bloch
33 * @since 1.5
34 * @serial exclude
35 */
36 class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
37 private static final long serialVersionUID = 334349849919042784L;
38
39 /**
40 * Bit vector representation of this set. The ith bit of the jth
41 * element of this array represents the presence of universe[64*j +i]
42 * in this set.
43 */
44 private long elements[];
45
46 // Redundant - maintained for performance
47 private int size = 0;
48
49 JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
50 super(elementType, universe);
51 elements = new long[(universe.length + 63) >>> 6];
52 }
53
54 void addRange(E from, E to) {
55 int fromIndex = from.ordinal() >>> 6;
56 int toIndex = to.ordinal() >>> 6;
57
58 if (fromIndex == toIndex) {
59 elements[fromIndex] = (-1L >>> (from.ordinal() - to.ordinal() - 1))
60 << from.ordinal();
61 } else {
62 elements[fromIndex] = (-1L << from.ordinal());
63 for (int i = fromIndex + 1; i < toIndex; i++)
64 elements[i] = -1;
|
24 */
25
26 package java.util;
27
28 /**
29 * Private implementation class for EnumSet, for "jumbo" enum types
30 * (i.e., those with more than 64 elements).
31 *
32 * @author Josh Bloch
33 * @since 1.5
34 * @serial exclude
35 */
36 class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
37 private static final long serialVersionUID = 334349849919042784L;
38
39 /**
40 * Bit vector representation of this set. The ith bit of the jth
41 * element of this array represents the presence of universe[64*j +i]
42 * in this set.
43 */
44 private long[] elements;
45
46 // Redundant - maintained for performance
47 private int size = 0;
48
49 JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
50 super(elementType, universe);
51 elements = new long[(universe.length + 63) >>> 6];
52 }
53
54 void addRange(E from, E to) {
55 int fromIndex = from.ordinal() >>> 6;
56 int toIndex = to.ordinal() >>> 6;
57
58 if (fromIndex == toIndex) {
59 elements[fromIndex] = (-1L >>> (from.ordinal() - to.ordinal() - 1))
60 << from.ordinal();
61 } else {
62 elements[fromIndex] = (-1L << from.ordinal());
63 for (int i = fromIndex + 1; i < toIndex; i++)
64 elements[i] = -1;
|