EnumSet extends AbstractSet and implements Set. It is specifically for use with keys of an enum type. It is a generic class that has this declaration:
class EnumSet<E extends Enum<E>>
Here, E specifies the elements. Notice that E must extend Enum, which enforces the requirement that the elements must be of the specified enum type.
The Methods Defined by EnumSet
Method | Description |
static <E extends Enum<E>> | Creates an EnumSet that contains the elements in the |
EnumSet<E> allOf(Class<E> t) | enumeration specified by t. |
static <E extends Enum<E>> EnumSet<E> | Creates an EnumSet that is comprised of those elements not |
complementOf(EnumSet<E> e) | stored in e. |
static <E extends Enum<E>> | Creates an EnumSet from the elements stored in c. |
EnumSet<E> copyOf(EnumSet<E> c) | |
static <E extends Enum<E>> | Creates an EnumSet from the elements stored in c. |
EnumSet<E> copyOf(Collection<E> c) | |
static <E extends Enum<E>> | Creates an EnumSet that contains the elements that are not in |
EnumSet<E> noneOf(Class<E> t) | the enumeration specified by t, which is an empty set by definition. |
static <E extends Enum<E>> | Creates an EnumSet that contains v and zero or more |
EnumSet<E> of(E v, E … varargs) | additional enumeration values. |
static <E extends Enum<E>> | Creates an EnumSet that contains v. |
EnumSet<E> of(E v) | |
static <E extends Enum<E>> | Creates an EnumSet that contains v1 and v2. |
EnumSet<E> of(E v1, E v2) | |
static <E extends Enum<E>> | Creates an EnumSet that contains v1 through v3. |
EnumSet<E> of(E v1, E v2, E v3) | |
static <E extends Enum<E>> | Creates an EnumSet that contains v1 through v4. |
EnumSet<E> of(E v1, E v2, E v3, E v4) | |
static <E extends Enum<E>> | Creates an EnumSet that contains v1 through v5. |
EnumSet<E> of(E v1, E v2, E v3, E v4, | |
E v5) | |
static <E extends Enum<E>> | Creates an EnumSet that contains the elements in the range |
EnumSet<E> range(E start, E end) | specified by start and end. |
The Methods Defined by Iterator
Method | Description | |||
boolean hasNext( ) | Returns true if there are more elements. Otherwise, returns false. | |||
E next( ) | Returns the next element. Throws NoSuchElementException if there is not | |||
a next element. | ||||
void remove( ) | Removes the current element. Throws IllegalStateException if an attempt | |||
is made to call remove( ) that is not preceded by a call to next( ). |