T - the set element typepublic class ImmutableSet<T> extends ImmutableCollection<T> implements Set<T>
Set.| Constructor and Description |
|---|
ImmutableSet(Set<T> set)
Construct an
ImmutableSet from another Set (helps with deserializing). |
ImmutableSet(T[] array)
Construct an
ImmutableSet with the given array (using the entire array). |
ImmutableSet(T[] array,
int length)
Construct an
ImmutableSet with the given array and length. |
| Modifier and Type | Method and Description |
|---|---|
static <TT> ImmutableSet<TT> |
emptySet()
Get an empty
ImmutableSet. |
boolean |
equals(Object other)
Compares the specified object with this set for equality.
|
int |
hashCode()
Returns the hash code value for this set.
|
static <TT> ImmutableSet<TT> |
setOf(TT[] array)
Get an
ImmutableSet using the supplied array. |
static <TT> ImmutableSet<TT> |
setOf(TT[] array,
int length)
Get an
ImmutableSet using the supplied array. |
contains, contains, get, iterator, toArray, toArrayadd, addAll, containsAll, remove, removeAll, retainAll, toStringclear, isEmpty, sizeclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArrayparallelStream, removeIf, streampublic ImmutableSet(T[] array, int length)
ImmutableSet with the given array and length.array - the arraylength - the length (the number of array items to be considered part of the set)IndexOutOfBoundsException - if the length is less than 0 or greater than the array lengthpublic ImmutableSet(T[] array)
ImmutableSet with the given array (using the entire array).array - the arraypublic boolean equals(Object other)
true if the specified object is also a
set, the two sets have the same size, and every member of the specified set is contained in this set (or
equivalently, every member of this set is contained in the specified set). This definition ensures that the
equals method works properly across different implementations of the set interface.public int hashCode()
null element is defined to be zero. This ensures that
s1.equals(s2) implies that s1.hashCode() == s2.hashCode() for any two sets s1 and
s2, as required by the general contract of Object.hashCode().public static <TT> ImmutableSet<TT> emptySet()
ImmutableSet. This avoids a memory allocation if the set is empty.TT - the element typepublic static <TT> ImmutableSet<TT> setOf(TT[] array)
ImmutableSet using the supplied array. If the array length is zero, the empty set is returned.TT - the element typearray - the arraypublic static <TT> ImmutableSet<TT> setOf(TT[] array, int length)
ImmutableSet using the supplied array. If the array length is zero, the empty set is returned.TT - the element typearray - the arraylength - the length (the number of array items to be considered part of the set)Copyright © 2023. All rights reserved.