3909N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A specialized {@link Set} implementation for use with enum types. All of 0N/A * the elements in an enum set must come from a single enum type that is 0N/A * specified, explicitly or implicitly, when the set is created. Enum sets 0N/A * are represented internally as bit vectors. This representation is 0N/A * extremely compact and efficient. The space and time performance of this 0N/A * class should be good enough to allow its use as a high-quality, typesafe 0N/A * alternative to traditional <tt>int</tt>-based "bit flags." Even bulk 0N/A * operations (such as <tt>containsAll</tt> and <tt>retainAll</tt>) should 0N/A * run very quickly if their argument is also an enum set. 0N/A * <p>The iterator returned by the <tt>iterator</tt> method traverses the 0N/A * elements in their <i>natural order</i> (the order in which the enum 0N/A * constants are declared). The returned iterator is <i>weakly 0N/A * consistent</i>: it will never throw {@link ConcurrentModificationException} 0N/A * and it may or may not show the effects of any modifications to the set that 0N/A * occur while the iteration is in progress. 0N/A * <p>Null elements are not permitted. Attempts to insert a null element 0N/A * will throw {@link NullPointerException}. Attempts to test for the 0N/A * presence of a null element or to remove one will, however, function 0N/A * <P>Like most collection implementations, <tt>EnumSet</tt> is not 0N/A * synchronized. If multiple threads access an enum set concurrently, and at 0N/A * least one of the threads modifies the set, it should be synchronized 0N/A * externally. This is typically accomplished by synchronizing on some 0N/A * object that naturally encapsulates the enum set. If no such object exists, 0N/A * the set should be "wrapped" using the {@link Collections#synchronizedSet} 0N/A * method. This is best done at creation time, to prevent accidental 0N/A * unsynchronized access: 0N/A * Set<MyEnum> s = Collections.synchronizedSet(EnumSet.noneOf(MyEnum.class)); 0N/A * <p>Implementation note: All basic operations execute in constant time. 0N/A * They are likely (though not guaranteed) to be much faster than their 0N/A * {@link HashSet} counterparts. Even bulk operations execute in 0N/A * constant time if their argument is also an enum set. 0N/A * <p>This class is a member of the 0N/A * Java Collections Framework</a>. 0N/A * @author Josh Bloch 0N/A * The class of all the elements of this set. 0N/A * All of the values comprising T. (Cached for performance.) 0N/A * Creates an empty enum set with the specified element type. 0N/A * @param elementType the class object of the element type for this enum 0N/A * @throws NullPointerException if <tt>elementType</tt> is null 0N/A * Creates an enum set containing all of the elements in the specified 0N/A * @param elementType the class object of the element type for this enum 0N/A * @throws NullPointerException if <tt>elementType</tt> is null 0N/A * Adds all of the elements from the appropriate enum type to this enum 0N/A * set, which is empty prior to the call. 0N/A * Creates an enum set with the same element type as the specified enum 0N/A * set, initially containing the same elements (if any). 0N/A * @param s the enum set from which to initialize this enum set 0N/A * @throws NullPointerException if <tt>s</tt> is null 0N/A * Creates an enum set initialized from the specified collection. If 0N/A * the specified collection is an <tt>EnumSet</tt> instance, this static 0N/A * factory method behaves identically to {@link #copyOf(EnumSet)}. 0N/A * Otherwise, the specified collection must contain at least one element 0N/A * (in order to determine the new enum set's element type). 0N/A * @param c the collection from which to initialize this enum set 0N/A * @throws IllegalArgumentException if <tt>c</tt> is not an 0N/A * <tt>EnumSet</tt> instance and contains no elements 0N/A * @throws NullPointerException if <tt>c</tt> is null 0N/A * Creates an enum set with the same element type as the specified enum 0N/A * set, initially containing all the elements of this type that are 0N/A * <i>not</i> contained in the specified set. 0N/A * @param s the enum set from whose complement to initialize this enum set 0N/A * @throws NullPointerException if <tt>s</tt> is null 0N/A * Creates an enum set initially containing the specified element. 0N/A * Overloadings of this method exist to initialize an enum set with 0N/A * one through five elements. A sixth overloading is provided that 0N/A * uses the varargs feature. This overloading may be used to create 0N/A * an enum set initially containing an arbitrary number of elements, but 0N/A * is likely to run slower than the overloadings that do not use varargs. 0N/A * @param e the element that this set is to contain initially 0N/A * @throws NullPointerException if <tt>e</tt> is null 0N/A * @return an enum set initially containing the specified element 0N/A * Creates an enum set initially containing the specified elements. 0N/A * Overloadings of this method exist to initialize an enum set with 0N/A * one through five elements. A sixth overloading is provided that 0N/A * uses the varargs feature. This overloading may be used to create 0N/A * an enum set initially containing an arbitrary number of elements, but 0N/A * is likely to run slower than the overloadings that do not use varargs. 0N/A * @param e1 an element that this set is to contain initially 0N/A * @param e2 another element that this set is to contain initially 0N/A * @throws NullPointerException if any parameters are null 0N/A * @return an enum set initially containing the specified elements 0N/A * Creates an enum set initially containing the specified elements. 0N/A * Overloadings of this method exist to initialize an enum set with 0N/A * one through five elements. A sixth overloading is provided that 0N/A * uses the varargs feature. This overloading may be used to create 0N/A * an enum set initially containing an arbitrary number of elements, but 0N/A * is likely to run slower than the overloadings that do not use varargs. 0N/A * @param e1 an element that this set is to contain initially 0N/A * @param e2 another element that this set is to contain initially 0N/A * @param e3 another element that this set is to contain initially 0N/A * @throws NullPointerException if any parameters are null 0N/A * @return an enum set initially containing the specified elements 0N/A * Creates an enum set initially containing the specified elements. 0N/A * Overloadings of this method exist to initialize an enum set with 0N/A * one through five elements. A sixth overloading is provided that 0N/A * uses the varargs feature. This overloading may be used to create 0N/A * an enum set initially containing an arbitrary number of elements, but 0N/A * is likely to run slower than the overloadings that do not use varargs. 0N/A * @param e1 an element that this set is to contain initially 0N/A * @param e2 another element that this set is to contain initially 0N/A * @param e3 another element that this set is to contain initially 0N/A * @param e4 another element that this set is to contain initially 0N/A * @throws NullPointerException if any parameters are null 0N/A * @return an enum set initially containing the specified elements 0N/A * Creates an enum set initially containing the specified elements. 0N/A * Overloadings of this method exist to initialize an enum set with 0N/A * one through five elements. A sixth overloading is provided that 0N/A * uses the varargs feature. This overloading may be used to create 0N/A * an enum set initially containing an arbitrary number of elements, but 0N/A * is likely to run slower than the overloadings that do not use varargs. 0N/A * @param e1 an element that this set is to contain initially 0N/A * @param e2 another element that this set is to contain initially 0N/A * @param e3 another element that this set is to contain initially 0N/A * @param e4 another element that this set is to contain initially 0N/A * @param e5 another element that this set is to contain initially 0N/A * @throws NullPointerException if any parameters are null 0N/A * @return an enum set initially containing the specified elements 0N/A * Creates an enum set initially containing the specified elements. 0N/A * This factory, whose parameter list uses the varargs feature, may 0N/A * be used to create an enum set initially containing an arbitrary 0N/A * number of elements, but it is likely to run slower than the overloadings 0N/A * that do not use varargs. 0N/A * @param first an element that the set is to contain initially 0N/A * @param rest the remaining elements the set is to contain initially 0N/A * @throws NullPointerException if any of the specified elements are null, 0N/A * or if <tt>rest</tt> is null 0N/A * @return an enum set initially containing the specified elements 0N/A * Creates an enum set initially containing all of the elements in the 0N/A * range defined by the two specified endpoints. The returned set will 0N/A * contain the endpoints themselves, which may be identical but must not 0N/A * @param from the first element in the range 0N/A * @param to the last element in the range 0N/A * @throws NullPointerException if {@code from} or {@code to} are null 0N/A * @throws IllegalArgumentException if {@code from.compareTo(to) > 0} 0N/A * @return an enum set initially containing all of the elements in the 0N/A * range defined by the two specified endpoints 0N/A * Adds the specified range to this enum set, which is empty prior 0N/A * Returns a copy of this set. 0N/A * @return a copy of this set 0N/A * Complements the contents of this enum set. 0N/A * Throws an exception if e is not of the correct type for this enum set. 0N/A * Returns all of the values comprising E. 0N/A * The result is uncloned, cached, and shared by all callers. 0N/A * This class is used to serialize all EnumSet instances, regardless of 0N/A * implementation type. It captures their "logical contents" and they 0N/A * are reconstructed using public static factories. This is necessary 0N/A * to ensure that the existence of a particular implementation type is 0N/A * an implementation detail. 0N/A * The element type of this enum set. 0N/A * The elements contained in this enum set. 500N/A // readObject method for the serialization proxy pattern 500N/A // See Effective Java, Second Ed., Item 78.