java.util

Class EnumSet<T,extends,Enum,T>

Implemented Interfaces:
Cloneable, Collection<E>, Iterable<E>, Serializable, Set<E>

public class EnumSet<T,extends,Enum,T>
extends AbstractSet<E>
implements Cloneable, Serializable

Since:
1.5
See Also:
Serialized Form

Method Summary

boolean
add(T val)
boolean
addAll(T> c)
void
clear()
Clear the collection, such that a subsequent call to isEmpty() would return true.
EnumSet
clone()
boolean
contains(Object o)
Test whether this collection contains a given object as one of its elements.
boolean
containsAll(Collection c)
Test whether this collection contains every element in a given collection.
static
extends Enum> EnumSet allOf(Class eltType)
static
extends Enum> EnumSet complementOf(EnumSet other)
static
extends Enum> EnumSet copyOf(Collection other)
static
extends Enum> EnumSet copyOf(EnumSet other)
static
extends Enum> EnumSet noneOf(Class eltType)
static
extends Enum> EnumSet of(T first)
static
extends Enum> EnumSet of(T first, T second)
static
extends Enum> EnumSet of(T first, T second, T third)
static
extends Enum> EnumSet of(T first, T second, T third, T fourth)
static
extends Enum> EnumSet of(T first, T second, T third, T fourth, T fifth)
static
extends Enum> EnumSet of(T first, T... rest)
static
extends Enum> EnumSet range(T from, T to)
Iterator
iterator()
Obtain an Iterator over this collection.
boolean
remove(Object o)
Remove a single occurrence of an object from this collection.
boolean
removeAll(Collection c)
Remove all elements of a given collection from this collection.
boolean
retainAll(Collection c)
Remove all elements of this collection that are not contained in a given collection.
int
size()
Get the number of elements in this collection.

Methods inherited from class java.util.AbstractSet<E>

equals, hashCode, removeAll

Methods inherited from class java.util.AbstractCollection<E>

T[] toArray, add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

add

public boolean add(T val)

addAll

public boolean addAll(T> c)

clear

public void clear()
Clear the collection, such that a subsequent call to isEmpty() would return true.
Specified by:
clear in interface Set<E>
clear in interface Collection<E>
Overrides:
clear in interface AbstractCollection<E>
Throws:
UnsupportedOperationException - if this collection does not support the clear operation.

clone

public EnumSet clone()
Overrides:
clone in interface Object

contains

public boolean contains(Object o)
Test whether this collection contains a given object as one of its elements.
Specified by:
contains in interface Set<E>
contains in interface Collection<E>
Overrides:
contains in interface AbstractCollection<E>
Parameters:
o - the element to look for.
Returns:
true if this collection contains at least one element e such that o == null ? e == null : o.equals(e).
Throws:
ClassCastException - if the type of o is not a valid type for this collection.
NullPointerException - if o is null and this collection doesn't support null values.

containsAll

public boolean containsAll(Collection c)
Test whether this collection contains every element in a given collection.
Specified by:
containsAll in interface Set<E>
containsAll in interface Collection<E>
Overrides:
containsAll in interface AbstractCollection<E>
Parameters:
c - the collection to test for.
Returns:
true if for every element o in c, contains(o) would return true.
Throws:
ClassCastException - if the type of any element in c is not a valid type for this collection.
NullPointerException - if some element of c is null and this collection does not support null values.
NullPointerException - if c itself is null.

extends Enum> EnumSet allOf

public static extends Enum> EnumSet allOf(Class eltType)

extends Enum> EnumSet complementOf

public static extends Enum> EnumSet complementOf(EnumSet other)

extends Enum> EnumSet copyOf

public static extends Enum> EnumSet copyOf(Collection other)

extends Enum> EnumSet copyOf

public static extends Enum> EnumSet copyOf(EnumSet other)

extends Enum> EnumSet noneOf

public static extends Enum> EnumSet noneOf(Class eltType)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first,
                                                T second)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first,
                                                T second,
                                                T third)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first,
                                                T second,
                                                T third,
                                                T fourth)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first,
                                                T second,
                                                T third,
                                                T fourth,
                                                T fifth)

extends Enum> EnumSet of

public static extends Enum> EnumSet of(T first,
                                                T... rest)

extends Enum> EnumSet range

public static extends Enum> EnumSet range(T from,
                                                   T to)

iterator

public Iterator iterator()
Obtain an Iterator over this collection.
Specified by:
iterator in interface Set<E>
iterator in interface Collection<E>
iterator in interface Iterable<E>
Overrides:
iterator in interface AbstractCollection<E>
Returns:
an Iterator over the elements of this collection, in any order.

remove

public boolean remove(Object o)
Remove a single occurrence of an object from this collection. That is, remove an element e, if one exists, such that o == null ? e == null : o.equals(e).
Specified by:
remove in interface Set<E>
remove in interface Collection<E>
Overrides:
remove in interface AbstractCollection<E>
Parameters:
o - the object to remove.
Returns:
true if the collection changed as a result of this call, that is, if the collection contained at least one occurrence of o.
Throws:
UnsupportedOperationException - if this collection does not support the remove operation.
ClassCastException - if the type of o is not a valid type for this collection.
NullPointerException - if o is null and the collection doesn't support null values.

removeAll

public boolean removeAll(Collection c)
Remove all elements of a given collection from this collection. That is, remove every element e such that c.contains(e).
Specified by:
removeAll in interface Set<E>
removeAll in interface Collection<E>
Overrides:
removeAll in interface AbstractSet<E>
Parameters:
c - The collection of objects to be removed.
Returns:
true if this collection was modified as a result of this call.
Throws:
UnsupportedOperationException - if this collection does not support the removeAll operation.
ClassCastException - if the type of any element in c is not a valid type for this collection.
NullPointerException - if some element of c is null and this collection does not support removing null values.
NullPointerException - if c itself is null.

retainAll

public boolean retainAll(Collection c)
Remove all elements of this collection that are not contained in a given collection. That is, remove every element e such that !c.contains(e).
Specified by:
retainAll in interface Set<E>
retainAll in interface Collection<E>
Overrides:
retainAll in interface AbstractCollection<E>
Parameters:
c - The collection of objects to be retained.
Returns:
true if this collection was modified as a result of this call.
Throws:
UnsupportedOperationException - if this collection does not support the retainAll operation.
ClassCastException - if the type of any element in c is not a valid type for this collection.
NullPointerException - if some element of c is null and this collection does not support retaining null values.
NullPointerException - if c itself is null.

size

public int size()
Get the number of elements in this collection.
Specified by:
size in interface Set<E>
size in interface Collection<E>
Overrides:
size in interface AbstractCollection<E>
Returns:
the number of elements in the collection.

EnumSet.java - Set of enum objects Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.