151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/* 24c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * Copyright (c) 2000, 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 * <p>Hash table and linked list implementation of the <tt>Set</tt> interface, 3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * with predictable iteration order. This implementation differs from 3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>HashSet</tt> in that it maintains a doubly-linked list running through 3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * all of its entries. This linked list defines the iteration ordering, 3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * which is the order in which elements were inserted into the set 3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (<i>insertion-order</i>). Note that insertion order is <i>not</i> affected 3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * if an element is <i>re-inserted</i> into the set. (An element <tt>e</tt> 3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is reinserted into a set <tt>s</tt> if <tt>s.add(e)</tt> is invoked when 3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>s.contains(e)</tt> would return <tt>true</tt> immediately prior to 3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the invocation.) 3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>This implementation spares its clients from the unspecified, generally 4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * chaotic ordering provided by {@link HashSet}, without incurring the 4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * increased cost associated with {@link TreeSet}. It can be used to 4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * produce a copy of a set that has the same order as the original, regardless 4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * of the original set's implementation: 4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <pre> 4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * void foo(Set s) { 4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Set copy = new LinkedHashSet(s); 4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ... 4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * } 5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </pre> 5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This technique is particularly useful if a module takes a set on input, 5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * copies it, and later returns results whose order is determined by that of 5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the copy. (Clients generally appreciate having things returned in the same 5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * order they were presented.) 5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>This class provides all of the optional <tt>Set</tt> operations, and 5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * permits null elements. Like <tt>HashSet</tt>, it provides constant-time 5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * performance for the basic operations (<tt>add</tt>, <tt>contains</tt> and 5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <tt>remove</tt>), assuming the hash function disperses elements 6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * properly among the buckets. Performance is likely to be just slightly 6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * below that of <tt>HashSet</tt>, due to the added expense of maintaining the 6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * linked list, with one exception: Iteration over a <tt>LinkedHashSet</tt> 6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * requires time proportional to the <i>size</i> of the set, regardless of 6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * its capacity. Iteration over a <tt>HashSet</tt> is likely to be more 6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * expensive, requiring time proportional to its <i>capacity</i>. 6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>A linked hash set has two parameters that affect its performance: 6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <i>initial capacity</i> and <i>load factor</i>. They are defined precisely 6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * as for <tt>HashSet</tt>. Note, however, that the penalty for choosing an 7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * excessively high value for initial capacity is less severe for this class 7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * than for <tt>HashSet</tt>, as iteration times for this class are unaffected 7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by capacity. 7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p><strong>Note that this implementation is not synchronized.</strong> 7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If multiple threads access a linked hash set concurrently, and at least 7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * one of the threads modifies the set, it <em>must</em> be synchronized 7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * externally. This is typically accomplished by synchronizing on some 7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object that naturally encapsulates the set. 7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If no such object exists, the set should be "wrapped" using the 8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * {@link Collections#synchronizedSet Collections.synchronizedSet} 8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method. This is best done at creation time, to prevent accidental 8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unsynchronized access to the set: <pre> 8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Set s = Collections.synchronizedSet(new LinkedHashSet(...));</pre> 8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The iterators returned by this class's <tt>iterator</tt> method are 8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <em>fail-fast</em>: if the set is modified at any time after the iterator 8851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is created, in any way except through the iterator's own <tt>remove</tt> 8951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method, the iterator will throw a {@link ConcurrentModificationException}. 9051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Thus, in the face of concurrent modification, the iterator fails quickly 9151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and cleanly, rather than risking arbitrary, non-deterministic behavior at 9251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * an undetermined time in the future. 9351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 9451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed 9551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * as it is, generally speaking, impossible to make any hard guarantees in the 9651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * presence of unsynchronized concurrent modification. Fail-fast iterators 9751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * throw <tt>ConcurrentModificationException</tt> on a best-effort basis. 9851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Therefore, it would be wrong to write a program that depended on this 9951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * exception for its correctness: <i>the fail-fast behavior of iterators 10051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be used only to detect bugs.</i> 10151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 10251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>This class is a member of the 103d2449bb576ad1e3a3877364e5e1ae28625f69e35Yi Kong * <a href="{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/collections/index.html"> 10451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Java Collections Framework</a>. 10551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 10651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param <E> the type of elements maintained by this set 10751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 10851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author Josh Bloch 10951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Object#hashCode() 11051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Collection 11151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Set 11251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see HashSet 11351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see TreeSet 11451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Hashtable 11551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 11651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 11751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 11851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic class LinkedHashSet<E> 11951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski extends HashSet<E> 12051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski implements Set<E>, Cloneable, java.io.Serializable { 12151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 12251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski private static final long serialVersionUID = -2851667679971038690L; 12351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 12451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 12551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Constructs a new, empty linked hash set with the specified initial 12651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * capacity and load factor. 12751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 12851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param initialCapacity the initial capacity of the linked hash set 12951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param loadFactor the load factor of the linked hash set 13051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if the initial capacity is less 13151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * than zero, or if the load factor is nonpositive 13251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 13351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public LinkedHashSet(int initialCapacity, float loadFactor) { 13451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super(initialCapacity, loadFactor, true); 13551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 13651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 13751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 13851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Constructs a new, empty linked hash set with the specified initial 13951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * capacity and the default load factor (0.75). 14051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 14151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param initialCapacity the initial capacity of the LinkedHashSet 14251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws IllegalArgumentException if the initial capacity is less 14351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * than zero 14451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 14551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public LinkedHashSet(int initialCapacity) { 14651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super(initialCapacity, .75f, true); 14751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 14851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 14951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 15051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Constructs a new, empty linked hash set with the default initial 15151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * capacity (16) and load factor (0.75). 15251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 15351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public LinkedHashSet() { 15451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super(16, .75f, true); 15551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 15651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 15751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 15851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Constructs a new linked hash set with the same elements as the 15951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified collection. The linked hash set is created with an initial 16051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * capacity sufficient to hold the elements in the specified collection 16151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and the default load factor (0.75). 16251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 16351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param c the collection whose elements are to be placed into 16451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this set 16551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws NullPointerException if the specified collection is null 16651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 16751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public LinkedHashSet(Collection<? extends E> c) { 16851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super(Math.max(2*c.size(), 11), .75f, true); 16951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski addAll(c); 17051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 1714c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath 1724c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath /** 1734c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em> 1744c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * and <em>fail-fast</em> {@code Spliterator} over the elements in this set. 1754c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 1764c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <p>The {@code Spliterator} reports {@link Spliterator#SIZED}, 1774c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * {@link Spliterator#DISTINCT}, and {@code ORDERED}. Implementations 1784c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * should document the reporting of additional characteristic values. 1794c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 1804c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @implNote 1814c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * The implementation creates a 1824c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator 1834c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * from the set's {@code Iterator}. The spliterator inherits the 1844c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * <em>fail-fast</em> properties of the set's iterator. 1854c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * The created {@code Spliterator} additionally reports 1864c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * {@link Spliterator#SUBSIZED}. 1874c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * 1884c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @return a {@code Spliterator} over the elements in this set 1894c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath * @since 1.8 1904c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath */ 1914c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath @Override 1924c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath public Spliterator<E> spliterator() { 1934c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath return Spliterators.spliterator(this, Spliterator.DISTINCT | Spliterator.ORDERED); 1944c89023ef86f29fa9add7db2574f2169fe842577Narayan Kamath } 19551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski} 196