# EnumSet

public abstract class **EnumSet** extends [AbstractSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractSet.html)\<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\>  
implements [Cloneable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Cloneable.html) [Serializable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Serializable.html) A specialized `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html` implementation for use with enum types. All of
the elements in an enum set must come from a single enum type that is
specified, explicitly or implicitly, when the set is created. Enum sets
are represented internally as bit vectors. This representation is
extremely compact and efficient. The space and time performance of this
class should be good enough to allow its use as a high-quality, typesafe
alternative to traditional int-based "bit flags." Even bulk
operations (such as containsAll and retainAll) should
run very quickly if their argument is also an enum set.

The iterator returned by the iterator method traverses the
elements in their *natural order* (the order in which the enum
constants are declared). The returned iterator is *weakly consistent*: it will never throw `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/ConcurrentModificationException.html`
and it may or may not show the effects of any modifications to the set that
occur while the iteration is in progress.

Null elements are not permitted. Attempts to insert a null element
will throw `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html`. Attempts to test for the
presence of a null element or to remove one will, however, function
properly.

Like most collection implementations, EnumSet is not
synchronized. If multiple threads access an enum set concurrently, and at
least one of the threads modifies the set, it should be synchronized
externally. This is typically accomplished by synchronizing on some
object that naturally encapsulates the enum set. If no such object exists,
the set should be "wrapped" using the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collections.html#synchronizedSet(java.util.Set<T>)`
method. This is best done at creation time, to prevent accidental
unsynchronized access:

```
 Set<MyEnum> s = Collections.synchronizedSet(EnumSet.noneOf(MyEnum.class));
 
```

Implementation note: All basic operations execute in constant time.
They are likely (though not guaranteed) to be much faster than their
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/HashSet.html` counterparts. Even bulk operations execute in
constant time if their argument is also an enum set.

This class is a member of the
[Java Collections Framework](https://developers.google.com/j2objc/javadoc/jre/openjdk-redirect.html?v=8&path=/technotes/guides/collections/index.html).

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumMap.html`

### Public Method Summary

|---|---|
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [allOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#allOf(java.lang.Class<E>))([Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<E\> elementType) Creates an enum set containing all of the elements in the specified element type. |
| [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#clone())() Returns a copy of this set. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [complementOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#complementOf(java.util.EnumSet<E>))([EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> s) Creates an enum set with the same element type as the specified enum set, initially containing all the elements of this type that are *not* contained in the specified set. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [copyOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#copyOf(java.util.EnumSet<E>))([EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> s) Creates an enum set with the same element type as the specified enum set, initially containing the same elements (if any). |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [copyOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#copyOf(java.util.Collection<E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<E\> c) Creates an enum set initialized from the specified collection. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [noneOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#noneOf(java.lang.Class<E>))([Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<E\> elementType) Creates an empty enum set with the specified element type. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E,%20E...))(E first, E... rest) Creates an enum set initially containing the specified elements. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E,%20E,%20E))(E e1, E e2, E e3) Creates an enum set initially containing the specified elements. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E,%20E))(E e1, E e2) Creates an enum set initially containing the specified elements. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E,%20E,%20E,%20E,%20E))(E e1, E e2, E e3, E e4, E e5) Creates an enum set initially containing the specified elements. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E,%20E,%20E,%20E))(E e1, E e2, E e3, E e4) Creates an enum set initially containing the specified elements. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [of](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#of(E))(E e) Creates an enum set initially containing the specified element. |
| static \<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> | [range](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#range(E,%20E))(E from, E to) Creates an enum set initially containing all of the elements in the range defined by the two specified endpoints. |

### Inherited Method Summary

From class [java.util.AbstractSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractSet.html)

|---|---|
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractSet.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this set for equality. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractSet.html#hashCode())() Returns the hash code value for this set. |
| boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractSet.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes from this set all of its elements that are contained in the specified collection (optional operation). |

From class [java.util.AbstractCollection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html)

|---|---|
| boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#add(E))(E e) Ensures that this collection contains the specified element (optional operation). This implementation always throws an UnsupportedOperationException. |
| boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this collection (optional operation). This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn. |
| void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#clear())() Removes all of the elements from this collection (optional operation). This implementation iterates over this collection, removing each element using the Iterator.remove operation. |
| boolean | [contains](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#contains(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Returns true if this collection contains the specified element. This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element. |
| boolean | [containsAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#containsAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Returns true if this collection contains all of the elements in the specified collection. This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. |
| boolean | [isEmpty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#isEmpty())() Returns true if this collection contains no elements. This implementation returns size() == 0. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#iterator())() Returns an iterator over the elements contained in this collection. |
| boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#remove(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Removes a single instance of the specified element from this collection, if it is present (optional operation). This implementation iterates over the collection looking for the specified element. |
| boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes all of this collection's elements that are also contained in the specified collection (optional operation). This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. |
| boolean | [retainAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#retainAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Retains only the elements in this collection that are contained in the specified collection (optional operation). This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. |
| abstract int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#size())() Returns the number of elements in this collection. |
| \<T\> T\[\] | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toArray(T[]))(T\[\] contents) Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. This implementation returns an array containing all the elements returned by this collection's iterator in the same order, stored in consecutive elements of the array, starting with index `0`. |
| [Object\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toArray())() Returns an array containing all of the elements in this collection. This implementation returns an array containing all the elements returned by this collection's iterator, in the same order, stored in consecutive elements of the array, starting with index `0`. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toString())() Returns a string representation of this collection. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.util.Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)

|---|---|
| abstract boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#add(E))(E e) Adds the specified element to this set if it is not already present (optional operation). |
| abstract boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this set if they're not already present (optional operation). |
| abstract void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#clear())() Removes all of the elements from this set (optional operation). |
| abstract boolean | [contains](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#contains(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Returns `true` if this set contains the specified element. |
| abstract boolean | [containsAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#containsAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Returns `true` if this set contains all of the elements of the specified collection. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this set for equality. |
| abstract int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#hashCode())() Returns the hash code value for this set. |
| abstract boolean | [isEmpty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#isEmpty())() Returns `true` if this set contains no elements. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#iterator())() Returns an iterator over the elements in this set. |
| abstract boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#remove(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Removes the specified element from this set if it is present (optional operation). |
| abstract boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes from this set all of its elements that are contained in the specified collection (optional operation). |
| abstract boolean | [retainAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#retainAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Retains only the elements in this set that are contained in the specified collection (optional operation). |
| abstract int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#size())() Returns the number of elements in this set (its cardinality). |
| [Spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html)\<E\> | [spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#spliterator())() Creates a `Spliterator` over the elements in this set. |
| abstract \<T\> T\[\] | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#toArray(T[]))(T\[\] a) Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. |
| abstract [Object\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html#toArray())() Returns an array containing all of the elements in this set. |

From interface [java.util.Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)

|---|---|
| abstract boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#add(E))(E e) Ensures that this collection contains the specified element (optional operation). |
| abstract boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this collection (optional operation). |
| abstract void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#clear())() Removes all of the elements from this collection (optional operation). |
| abstract boolean | [contains](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#contains(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Returns true if this collection contains the specified element. |
| abstract boolean | [containsAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#containsAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Returns true if this collection contains all of the elements in the specified collection. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this collection for equality. |
| abstract int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#hashCode())() Returns the hash code value for this collection. |
| abstract boolean | [isEmpty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#isEmpty())() Returns true if this collection contains no elements. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#iterator())() Returns an iterator over the elements in this collection. |
| [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<E\> | [parallelStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#parallelStream())() Returns a possibly parallel `Stream` with this collection as its source. |
| abstract boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#remove(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Removes a single instance of the specified element from this collection, if it is present (optional operation). |
| abstract boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes all of this collection's elements that are also contained in the specified collection (optional operation). |
| boolean | [removeIf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#removeIf(java.util.function.Predicate<?%20super%20E>))([Predicate](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Predicate.html)\<? super E\> filter) Removes all of the elements of this collection that satisfy the given predicate. |
| abstract boolean | [retainAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#retainAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Retains only the elements in this collection that are contained in the specified collection (optional operation). |
| abstract int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#size())() Returns the number of elements in this collection. |
| [Spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html)\<E\> | [spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#spliterator())() Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html` over the elements in this collection. |
| [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<E\> | [stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#stream())() Returns a sequential `Stream` with this collection as its source. |
| abstract \<T\> T\[\] | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#toArray(T[]))(T\[\] a) Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. |
| abstract [Object\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#toArray())() Returns an array containing all of the elements in this collection. |

From interface [java.lang.Iterable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html)

|---|---|
| void | [forEach](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#forEach(java.util.function.Consumer<?%20super%20T>))([Consumer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Consumer.html)\<? super T\> action) Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#iterator())() Returns an iterator over elements of type `T`. |
| [Spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html)\<E extends [Enum](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Enum.html)\<E\>\> | [spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#spliterator())() Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html` over the elements described by this `Iterable`. |

## Public Methods

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**allOf**
([Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<E\> elementType)

Creates an enum set containing all of the elements in the specified
element type.

##### Parameters

| elementType | the class object of the element type for this enum set |
|---|---|

##### Returns

- An enum set containing all the elements in the specified type.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if elementType is null |
|---|---|

#### public [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**clone**
()

Returns a copy of this set.

##### Returns

- a copy of this set

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**complementOf**
([EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> s)

Creates an enum set with the same element type as the specified enum
set, initially containing all the elements of this type that are
*not* contained in the specified set.

##### Parameters

| s | the enum set from whose complement to initialize this enum set |
|---|---|

##### Returns

- The complement of the specified set in this set

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if s is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**copyOf**
([EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\> s)

Creates an enum set with the same element type as the specified enum
set, initially containing the same elements (if any).

##### Parameters

| s | the enum set from which to initialize this enum set |
|---|---|

##### Returns

- A copy of the specified enum set.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if s is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**copyOf**
([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<E\> c)

Creates an enum set initialized from the specified collection. If
the specified collection is an EnumSet instance, this static
factory method behaves identically to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html#copyOf(java.util.EnumSet<E>)`.
Otherwise, the specified collection must contain at least one element
(in order to determine the new enum set's element type).

##### Parameters

| c | the collection from which to initialize this enum set |
|---|---|

##### Returns

- An enum set initialized from the given collection.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if c is not an EnumSet instance and contains no elements |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if c is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**noneOf**
([Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<E\> elementType)

Creates an empty enum set with the specified element type.

##### Parameters

| elementType | the class object of the element type for this enum set |
|---|---|

##### Returns

- An empty enum set of the specified type.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if elementType is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E first, E... rest)

Creates an enum set initially containing the specified elements.
This factory, whose parameter list uses the varargs feature, may
be used to create an enum set initially containing an arbitrary
number of elements, but it is likely to run slower than the overloadings
that do not use varargs.

##### Parameters

| first | an element that the set is to contain initially |
| rest | the remaining elements the set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified elements

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if any of the specified elements are null, or if rest is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E e1, E e2, E e3)

Creates an enum set initially containing the specified elements.

Overloadings of this method exist to initialize an enum set with
one through five elements. A sixth overloading is provided that
uses the varargs feature. This overloading may be used to create
an enum set initially containing an arbitrary number of elements, but
is likely to run slower than the overloadings that do not use varargs.

##### Parameters

| e1 | an element that this set is to contain initially |
| e2 | another element that this set is to contain initially |
| e3 | another element that this set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified elements

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if any parameters are null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E e1, E e2)

Creates an enum set initially containing the specified elements.

Overloadings of this method exist to initialize an enum set with
one through five elements. A sixth overloading is provided that
uses the varargs feature. This overloading may be used to create
an enum set initially containing an arbitrary number of elements, but
is likely to run slower than the overloadings that do not use varargs.

##### Parameters

| e1 | an element that this set is to contain initially |
| e2 | another element that this set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified elements

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if any parameters are null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E e1, E e2, E e3, E e4, E e5)

Creates an enum set initially containing the specified elements.

Overloadings of this method exist to initialize an enum set with
one through five elements. A sixth overloading is provided that
uses the varargs feature. This overloading may be used to create
an enum set initially containing an arbitrary number of elements, but
is likely to run slower than the overloadings that do not use varargs.

##### Parameters

| e1 | an element that this set is to contain initially |
| e2 | another element that this set is to contain initially |
| e3 | another element that this set is to contain initially |
| e4 | another element that this set is to contain initially |
| e5 | another element that this set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified elements

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if any parameters are null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E e1, E e2, E e3, E e4)

Creates an enum set initially containing the specified elements.

Overloadings of this method exist to initialize an enum set with
one through five elements. A sixth overloading is provided that
uses the varargs feature. This overloading may be used to create
an enum set initially containing an arbitrary number of elements, but
is likely to run slower than the overloadings that do not use varargs.

##### Parameters

| e1 | an element that this set is to contain initially |
| e2 | another element that this set is to contain initially |
| e3 | another element that this set is to contain initially |
| e4 | another element that this set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified elements

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if any parameters are null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**of**
(E e)

Creates an enum set initially containing the specified element.

Overloadings of this method exist to initialize an enum set with
one through five elements. A sixth overloading is provided that
uses the varargs feature. This overloading may be used to create
an enum set initially containing an arbitrary number of elements, but
is likely to run slower than the overloadings that do not use varargs.

##### Parameters

| e | the element that this set is to contain initially |
|---|---|

##### Returns

- an enum set initially containing the specified element

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if e is null |
|---|---|

#### public static [EnumSet](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EnumSet.html)\<E\>
**range**
(E from, E to)

Creates an enum set initially containing all of the elements in the
range defined by the two specified endpoints. The returned set will
contain the endpoints themselves, which may be identical but must not
be out of order.

##### Parameters

| from | the first element in the range |
| to | the last element in the range |
|---|---|

##### Returns

- an enum set initially containing all of the elements in the range defined by the two specified endpoints

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `from` or `to` are null |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `from.compareTo(to) > 0` |
|---|---|