Type Parameters:
E - the type of elements maintained by this set
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
JobStateReasons, LinkedHashSet

  • Constructor Summary

    Constructors

    HashSet()

    Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).

    HashSet(int initialCapacity)

    Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).

    HashSet(int initialCapacity, float loadFactor)

    Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.

    Constructs a new set containing the elements in the specified collection.

  • Method Summary

    boolean

    add(E e)

    Adds the specified element to this set if it is not already present.

    void

    clear()

    Removes all of the elements from this set.

    clone()

    Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.

    boolean

    Returns true if this set contains the specified element.

    boolean

    isEmpty()

    Returns true if this set contains no elements.

    iterator()

    Returns an iterator over the elements in this set.

    newHashSet(int numElements)

    Creates a new, empty HashSet suitable for the expected number of elements.

    boolean

    Removes the specified element from this set if it is present.

    int

    size()

    Returns the number of elements in this set (its cardinality).

    toArray()

    Returns an array containing all of the elements in this collection.

    <T> T[]

    toArray(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.

    Methods declared in class AbstractSet

    equals, hashCode, removeAll

    boolean

    Compares the specified object with this set for equality.

    int

    Returns the hash code value for this set.

    boolean

    Removes from this set all of its elements that are contained in the specified collection (optional operation).

    Methods declared in class AbstractCollection

    addAll, containsAll, retainAll, toArray, toArray, toString

    boolean

    Adds all of the elements in the specified collection to this collection (optional operation).

    boolean

    Returns true if this collection contains all of the elements in the specified collection.

    boolean

    Retains only the elements in this collection that are contained in the specified collection (optional operation).

    Returns an array containing all of the elements in this collection.

    <T> T[]

    Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

    Returns a string representation of this collection.

    Methods declared in class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    protected void

    Deprecated, for removal: This API element is subject to removal in a future version.

    Returns the runtime class of this Object.

    final void

    Wakes up a single thread that is waiting on this object's monitor.

    final void

    Wakes up all threads that are waiting on this object's monitor.

    final void

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    final void

    wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void

    wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    Methods declared in interface Collection

    parallelStream, removeIf, stream, toArray

    Returns a possibly parallel Stream with this collection as its source.

    default boolean

    Removes all of the elements of this collection that satisfy the given predicate (optional operation).

    Returns a sequential Stream with this collection as its source.

    default <T> T[]

    Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

    Methods declared in interface Iterable

    forEach

    default void

    Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

    Methods declared in interface Set

    addAll, containsAll, retainAll

    boolean

    Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

    boolean

    Returns true if this set contains all of the elements of the specified collection.

    boolean

    Retains only the elements in this set that are contained in the specified collection (optional operation).

  • Constructor Details

    • HashSet

    • HashSet

    • HashSet

    • HashSet

  • Method Details

    • iterator

    • size

    • isEmpty

    • contains

    • add

    • remove

    • clear

    • clone

    • spliterator

    • toArray

    • toArray

    • newHashSet