151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/* 24c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it 651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as 751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation. Oracle designates this 851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided 951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code. 1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT 1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that 1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code). 1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version 1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation, 1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any 2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions. 2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage java.util; 2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/** 2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * A collection that contains no duplicate elements. More formally, sets 3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * contain no pair of elements <code>e1</code> and <code>e2</code> such that 3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>e1.equals(e2)</code>, and at most one null element. As implied by 3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * its name, this interface models the mathematical <i>set</i> abstraction. 3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The <tt>Set</tt> interface places additional stipulations, beyond those 3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * inherited from the <tt>Collection</tt> interface, on the contracts of all 3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * constructors and on the contracts of the <tt>add</tt>, <tt>equals</tt> and 3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>hashCode</tt> methods. Declarations for other inherited methods are 3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * also included here for convenience. (The specifications accompanying these 3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * declarations have been tailored to the <tt>Set</tt> interface, but they do 4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * not contain any additional stipulations.) 4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The additional stipulation on constructors is, not surprisingly, 4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that all constructors must create a set that contains no duplicate elements 4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (as defined above). 4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>Note: Great care must be exercised if mutable objects are used as set 4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements. The behavior of a set is not specified if the value of an object 4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is changed in a manner that affects <tt>equals</tt> comparisons while the 4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object is an element in the set. A special case of this prohibition is 5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that it is not permissible for a set to contain itself as an element. 5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>Some set implementations have restrictions on the elements that 5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * they may contain. For example, some implementations prohibit null elements, 5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and some have restrictions on the types of their elements. Attempting to 5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * add an ineligible element throws an unchecked exception, typically 5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>NullPointerException</tt> or <tt>ClassCastException</tt>. Attempting 5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to query the presence of an ineligible element may throw an exception, 5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or it may simply return false; some implementations will exhibit the former 5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * behavior and some will exhibit the latter. More generally, attempting an 6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * operation on an ineligible element whose completion would not result in 6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the insertion of an ineligible element into the set may throw an 6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * exception or it may succeed, at the option of the implementation. 6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Such exceptions are marked as "optional" in the specification for this 6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * interface. 6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>This interface is a member of the 67d2449bb576ad1e3a3877364e5e1ae28625f69e35Yi Kong * <a href="{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/collections/index.html"> 6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Java Collections Framework</a>. 6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param <E> the type of elements maintained by this set 7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author Josh Bloch 7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author Neal Gafter 7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Collection 7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see List 7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SortedSet 7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see HashSet 7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see TreeSet 7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see AbstractSet 8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Collections#singleton(java.lang.Object) 8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Collections#EMPTY_SET 8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic interface Set<E> extends Collection<E> { 8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // Query Operations 8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 8851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 8951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns the number of elements in this set (its cardinality). If this 9051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns 9151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>Integer.MAX_VALUE</tt>. 9251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 9351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the number of elements in this set (its cardinality) 9451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 9551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int size(); 9651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 9751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 9851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns <tt>true</tt> if this set contains no elements. 9951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 10051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set contains no elements 10151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 10251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean isEmpty(); 10351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 10451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 10551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns <tt>true</tt> if this set contains the specified element. 10651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * More formally, returns <tt>true</tt> if and only if this set 10751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * contains an element <tt>e</tt> such that 10851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>(o==null ? e==null : o.equals(e))</tt>. 10951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 11051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param o element whose presence in this set is to be tested 11151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set contains the specified element 11251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the type of the specified element 11351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is incompatible with this set 11451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 11551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified element is null and this 11651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set does not permit null elements 11751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 11851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 11951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean contains(Object o); 12051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 12151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 12251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns an iterator over the elements in this set. The elements are 12351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * returned in no particular order (unless this set is an instance of some 12451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * class that provides a guarantee). 12551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 12651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return an iterator over the elements in this set 12751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 12851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski Iterator<E> iterator(); 12951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 13051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 13151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns an array containing all of the elements in this set. 13251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If this set makes any guarantees as to what order its elements 13351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are returned by its iterator, this method must return the 13451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements in the same order. 13551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 13651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The returned array will be "safe" in that no references to it 13751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are maintained by this set. (In other words, this method must 13851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * allocate a new array even if this set is backed by an array). 13951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The caller is thus free to modify the returned array. 14051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 14151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>This method acts as bridge between array-based and collection-based 14251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * APIs. 14351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 14451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return an array containing all the elements in this set 14551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 14651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski Object[] toArray(); 14751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 14851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 14951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns an array containing all of the elements in this set; the 15051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * runtime type of the returned array is that of the specified array. 15151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the set fits in the specified array, it is returned therein. 15251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Otherwise, a new array is allocated with the runtime type of the 15351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified array and the size of this set. 15451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 15551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>If this set fits in the specified array with room to spare 15651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (i.e., the array has more elements than this set), the element in 15751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the array immediately following the end of the set is set to 15851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>null</tt>. (This is useful in determining the length of this 15951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set <i>only</i> if the caller knows that this set does not contain 16051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * any null elements.) 16151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 16251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>If this set makes any guarantees as to what order its elements 16351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are returned by its iterator, this method must return the elements 16451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in the same order. 16551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 16651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>Like the {@link #toArray()} method, this method acts as bridge between 16751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * array-based and collection-based APIs. Further, this method allows 16851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * precise control over the runtime type of the output array, and may, 16951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under certain circumstances, be used to save allocation costs. 17051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 17151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>Suppose <tt>x</tt> is a set known to contain only strings. 17251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The following code can be used to dump the set into a newly allocated 17351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * array of <tt>String</tt>: 17451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 17551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <pre> 17651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * String[] y = x.toArray(new String[0]);</pre> 17751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 17851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Note that <tt>toArray(new Object[0])</tt> is identical in function to 17951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>toArray()</tt>. 18051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 18151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param a the array into which the elements of this set are to be 18251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * stored, if it is big enough; otherwise, a new array of the same 18351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * runtime type is allocated for this purpose. 18451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return an array containing all the elements in this set 18551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ArrayStoreException if the runtime type of the specified array 18651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not a supertype of the runtime type of every element in this 18751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set 18851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified array is null 18951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 19051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski <T> T[] toArray(T[] a); 19151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 19251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 19351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // Modification Operations 19451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 19551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 19651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Adds the specified element to this set if it is not already present 19751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (optional operation). More formally, adds the specified element 19851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>e</tt> to this set if the set contains no element <tt>e2</tt> 19951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such that 20051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>(e==null ? e2==null : e.equals(e2))</tt>. 20151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If this set already contains the element, the call leaves the set 20251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unchanged and returns <tt>false</tt>. In combination with the 20351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * restriction on constructors, this ensures that sets never contain 20451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * duplicate elements. 20551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 20651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The stipulation above does not imply that sets must accept all 20751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements; sets may refuse to add any particular element, including 20851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>null</tt>, and throw an exception, as described in the 20951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specification for {@link Collection#add Collection.add}. 21051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Individual set implementations should clearly document any 21151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * restrictions on the elements that they may contain. 21251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 21351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param e element to be added to this set 21451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set did not already contain the specified 21551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * element 21651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>add</tt> operation 21751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 21851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the class of the specified element 21951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * prevents it from being added to this set 22051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified element is null and this 22151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set does not permit null elements 22251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if some property of the specified element 22351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * prevents it from being added to this set 22451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 22551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean add(E e); 22651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 22751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 22851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 22951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Removes the specified element from this set if it is present 23051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (optional operation). More formally, removes an element <tt>e</tt> 23151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such that 23251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>(o==null ? e==null : o.equals(e))</tt>, if 23351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this set contains such an element. Returns <tt>true</tt> if this set 23451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * contained the element (or equivalently, if this set changed as a 23551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * result of the call). (This set will not contain the element once the 23651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * call returns.) 23751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 23851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param o object to be removed from this set, if present 23951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set contained the specified element 24051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the type of the specified element 24151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is incompatible with this set 24251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 24351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified element is null and this 24451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set does not permit null elements 24551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 24651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>remove</tt> operation 24751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 24851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 24951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean remove(Object o); 25051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 25151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 25251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // Bulk Operations 25351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 25451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 25551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns <tt>true</tt> if this set contains all of the elements of the 25651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection. If the specified collection is also a set, this 25751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method returns <tt>true</tt> if it is a <i>subset</i> of this set. 25851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 25951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param c collection to be checked for containment in this set 26051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set contains all of the elements of the 26151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection 26251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the types of one or more elements 26351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in the specified collection are incompatible with this 26451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set 26551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 26651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified collection contains one 26751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or more null elements and this set does not permit null 26851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements 26951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>), 27051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or if the specified collection is null 27151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #contains(Object) 27251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 27351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean containsAll(Collection<?> c); 27451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 27551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 27651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Adds all of the elements in the specified collection to this set if 27751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * they're not already present (optional operation). If the specified 27851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * collection is also a set, the <tt>addAll</tt> operation effectively 27951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * modifies this set so that its value is the <i>union</i> of the two 28051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * sets. The behavior of this operation is undefined if the specified 28151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * collection is modified while the operation is in progress. 28251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 28351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param c collection containing elements to be added to this set 28451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set changed as a result of the call 28551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 28651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>addAll</tt> operation 28751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 28851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the class of an element of the 28951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection prevents it from being added to this set 29051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified collection contains one 29151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or more null elements and this set does not permit null 29251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements, or if the specified collection is null 29351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if some property of an element of the 29451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection prevents it from being added to this set 29551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #add(Object) 29651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 29751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean addAll(Collection<? extends E> c); 29851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 29951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 30051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retains only the elements in this set that are contained in the 30151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection (optional operation). In other words, removes 30251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * from this set all of its elements that are not contained in the 30351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection. If the specified collection is also a set, this 30451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * operation effectively modifies this set so that its value is the 30551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <i>intersection</i> of the two sets. 30651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 30751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param c collection containing elements to be retained in this set 30851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set changed as a result of the call 30951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>retainAll</tt> operation 31051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 31151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the class of an element of this set 31251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is incompatible with the specified collection 31351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 31451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if this set contains a null element and the 31551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection does not permit null elements 31651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>), 31751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or if the specified collection is null 31851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #remove(Object) 31951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 32051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean retainAll(Collection<?> c); 32151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 32251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 32351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Removes from this set all of its elements that are contained in the 32451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection (optional operation). If the specified 32551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * collection is also a set, this operation effectively modifies this 32651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set so that its value is the <i>asymmetric set difference</i> of 32751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the two sets. 32851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 32951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param c collection containing elements to be removed from this set 33051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if this set changed as a result of the call 33151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>removeAll</tt> operation 33251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 33351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws ClassCastException if the class of an element of this set 33451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is incompatible with the specified collection 33551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>) 33651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if this set contains a null element and the 33751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection does not permit null elements 33851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<a href="Collection.html#optional-restrictions">optional</a>), 33951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or if the specified collection is null 34051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #remove(Object) 34151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #contains(Object) 34251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 34351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean removeAll(Collection<?> c); 34451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 34551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 34651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Removes all of the elements from this set (optional operation). 34751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The set will be empty after this call returns. 34851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 34951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws UnsupportedOperationException if the <tt>clear</tt> method 35051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not supported by this set 35151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 35251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void clear(); 35351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 35451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 35551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // Comparison and hashing 35651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 35751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 35851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Compares the specified object with this set for equality. Returns 35951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>true</tt> if the specified object is also a set, the two sets 36051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * have the same size, and every member of the specified set is 36151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * contained in this set (or equivalently, every member of this set is 36251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * contained in the specified set). This definition ensures that the 36351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * equals method works properly across different implementations of the 36451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * set interface. 36551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 36651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param o object to be compared for equality with this set 36751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <tt>true</tt> if the specified object is equal to this set 36851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 36951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean equals(Object o); 37051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 37151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 37251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns the hash code value for this set. The hash code of a set is 37351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * defined to be the sum of the hash codes of the elements in the set, 37451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * where the hash code of a <tt>null</tt> element is defined to be zero. 37551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This ensures that <tt>s1.equals(s2)</tt> implies that 37651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt> 37751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and <tt>s2</tt>, as required by the general contract of 37851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link Object#hashCode}. 37951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 38051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the hash code value for this set 38151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Object#equals(Object) 38251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Set#equals(Object) 38351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 38451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int hashCode(); 3854c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath 3864c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath /** 3874c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * Creates a {@code Spliterator} over the elements in this set. 3884c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 3894c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <p>The {@code Spliterator} reports {@link Spliterator#DISTINCT}. 3904c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * Implementations should document the reporting of additional 3914c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * characteristic values. 3924c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 3934c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @implSpec 3944c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * The default implementation creates a 3954c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator 3964c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * from the set's {@code Iterator}. The spliterator inherits the 3974c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <em>fail-fast</em> properties of the set's iterator. 3984c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <p> 3994c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * The created {@code Spliterator} additionally reports 4004c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * {@link Spliterator#SIZED}. 4014c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 4024c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @implNote 4034c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * The created {@code Spliterator} additionally reports 4044c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * {@link Spliterator#SUBSIZED}. 4054c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 4064c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @return a {@code Spliterator} over the elements in this set 4074c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @since 1.8 4084c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath */ 4094c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath @Override 4104c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath default Spliterator<E> spliterator() { 4114c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath return Spliterators.spliterator(this, Spliterator.DISTINCT); 4124c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath } 41351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski} 414