Package com.google.common.collect
Class SingletonImmutableSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableSet<E>
-
- com.google.common.collect.SingletonImmutableSet<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Set<E>
@GwtCompatible(serializable=true, emulated=true) final class SingletonImmutableSet<E> extends ImmutableSet<E>
Implementation ofImmutableSet
with exactly one element.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableSet
ImmutableSet.Builder<E>, ImmutableSet.Indexed<E>
-
-
Field Summary
Fields Modifier and Type Field Description private int
cachedHashCode
(package private) E
element
-
Fields inherited from class com.google.common.collect.ImmutableSet
HASH_FLOODING_FPP, MAX_RUN_MULTIPLIER, MAX_TABLE_SIZE, SPLITERATOR_CHARACTERISTICS
-
-
Constructor Summary
Constructors Constructor Description SingletonImmutableSet(E element)
SingletonImmutableSet(E element, int hashCode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.Object target)
(package private) int
copyIntoArray(java.lang.Object[] dst, int offset)
Copies the contents of this immutable collection into the specified array at the specified offset.(package private) ImmutableList<E>
createAsList()
int
hashCode()
(package private) boolean
isHashCodeFast()
Returnstrue
if thehashCode()
method runs quickly.(package private) boolean
isPartialView()
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.UnmodifiableIterator<E>
iterator()
Returns an unmodifiable iterator across the elements in this collection.int
size()
java.lang.String
toString()
-
Methods inherited from class com.google.common.collect.ImmutableSet
asList, builder, builderWithExpectedSize, chooseTableSize, copyOf, copyOf, copyOf, copyOf, equals, hashFloodingDetected, maxRunBeforeFallback, of, of, of, of, of, of, of, rebuildHashTable, toImmutableSet, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
element
final transient E element
-
cachedHashCode
private transient int cachedHashCode
-
-
Method Detail
-
size
public int size()
-
contains
public boolean contains(java.lang.Object target)
- Specified by:
contains
in interfacejava.util.Collection<E>
- Specified by:
contains
in interfacejava.util.Set<E>
- Specified by:
contains
in classImmutableCollection<E>
-
iterator
public UnmodifiableIterator<E> iterator()
Description copied from class:ImmutableCollection
Returns an unmodifiable iterator across the elements in this collection.
-
createAsList
ImmutableList<E> createAsList()
- Overrides:
createAsList
in classImmutableSet<E>
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollection
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whethercopyOf
implementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialView
in classImmutableCollection<E>
-
copyIntoArray
int copyIntoArray(java.lang.Object[] dst, int offset)
Description copied from class:ImmutableCollection
Copies the contents of this immutable collection into the specified array at the specified offset. Returnsoffset + size()
.- Overrides:
copyIntoArray
in classImmutableCollection<E>
-
hashCode
public final int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<E>
- Specified by:
hashCode
in interfacejava.util.Set<E>
- Overrides:
hashCode
in classImmutableSet<E>
-
isHashCodeFast
boolean isHashCodeFast()
Description copied from class:ImmutableSet
Returnstrue
if thehashCode()
method runs quickly.- Overrides:
isHashCodeFast
in classImmutableSet<E>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
-