52 *
53 * <P>Like most collection implementations, {@code EnumSet} is not
54 * synchronized. If multiple threads access an enum set concurrently, and at
55 * least one of the threads modifies the set, it should be synchronized
56 * externally. This is typically accomplished by synchronizing on some
57 * object that naturally encapsulates the enum set. If no such object exists,
58 * the set should be "wrapped" using the {@link Collections#synchronizedSet}
59 * method. This is best done at creation time, to prevent accidental
60 * unsynchronized access:
61 *
62 * <pre>
63 * Set<MyEnum> s = Collections.synchronizedSet(EnumSet.noneOf(MyEnum.class));
64 * </pre>
65 *
66 * <p>Implementation note: All basic operations execute in constant time.
67 * They are likely (though not guaranteed) to be much faster than their
68 * {@link HashSet} counterparts. Even bulk operations execute in
69 * constant time if their argument is also an enum set.
70 *
71 * <p>This class is a member of the
72 * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
73 * Java Collections Framework</a>.
74 *
75 * @author Josh Bloch
76 * @since 1.5
77 * @see EnumMap
78 */
79 @SuppressWarnings("serial") // No serialVersionUID due to usage of
80 // serial proxy pattern
81 public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
82 implements Cloneable, java.io.Serializable
83 {
84 /**
85 * The class of all the elements of this set.
86 */
87 final transient Class<E> elementType;
88
89 /**
90 * All of the values comprising E. (Cached for performance.)
91 */
92 final transient Enum<?>[] universe;
|
52 *
53 * <P>Like most collection implementations, {@code EnumSet} is not
54 * synchronized. If multiple threads access an enum set concurrently, and at
55 * least one of the threads modifies the set, it should be synchronized
56 * externally. This is typically accomplished by synchronizing on some
57 * object that naturally encapsulates the enum set. If no such object exists,
58 * the set should be "wrapped" using the {@link Collections#synchronizedSet}
59 * method. This is best done at creation time, to prevent accidental
60 * unsynchronized access:
61 *
62 * <pre>
63 * Set<MyEnum> s = Collections.synchronizedSet(EnumSet.noneOf(MyEnum.class));
64 * </pre>
65 *
66 * <p>Implementation note: All basic operations execute in constant time.
67 * They are likely (though not guaranteed) to be much faster than their
68 * {@link HashSet} counterparts. Even bulk operations execute in
69 * constant time if their argument is also an enum set.
70 *
71 * <p>This class is a member of the
72 * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
73 * Java Collections Framework</a>.
74 *
75 * @author Josh Bloch
76 * @since 1.5
77 * @see EnumMap
78 */
79 @SuppressWarnings("serial") // No serialVersionUID due to usage of
80 // serial proxy pattern
81 public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
82 implements Cloneable, java.io.Serializable
83 {
84 /**
85 * The class of all the elements of this set.
86 */
87 final transient Class<E> elementType;
88
89 /**
90 * All of the values comprising E. (Cached for performance.)
91 */
92 final transient Enum<?>[] universe;
|