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:
Serializable,Iterable<E>,Collection<E>,Set<E>
Implementation of
ImmutableSet with exactly one element.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableSet
ImmutableSet.Builder<E>, ImmutableSet.CachingAsList<E>, ImmutableSet.Indexed<E> -
Field Summary
FieldsFields inherited from class com.google.common.collect.ImmutableSet
MAX_TABLE_SIZE, SPLITERATOR_CHARACTERISTICS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasList()Returns anImmutableListcontaining the same elements, in the same order, as this collection.boolean(package private) intcopyIntoArray(Object[] dst, int offset) Copies the contents of this immutable collection into the specified array at the specified offset.final inthashCode()(package private) booleanReturnstrueif this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.iterator()Returns an unmodifiable iterator across the elements in this collection.intsize()toString()Methods inherited from class com.google.common.collect.ImmutableSet
builder, builderWithExpectedSize, chooseTableSize, copyOf, copyOf, copyOf, copyOf, equals, isHashCodeFast, of, of, of, of, of, of, of, toImmutableSet, writeReplaceMethods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractCollection
containsAll, isEmptyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
element
-
-
Constructor Details
-
SingletonImmutableSet
SingletonImmutableSet(E element)
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Specified by:
containsin classImmutableCollection<E>
-
iterator
Description copied from class:ImmutableCollectionReturns an unmodifiable iterator across the elements in this collection. -
asList
Description copied from class:ImmutableCollectionReturns anImmutableListcontaining the same elements, in the same order, as this collection.Performance note: in most cases this method can return quickly without actually copying anything. The exact circumstances under which the copy is performed are undefined and subject to change.
- Overrides:
asListin classImmutableCollection<E>
-
isPartialView
boolean isPartialView()Description copied from class:ImmutableCollectionReturnstrueif 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 whethercopyOfimplementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialViewin classImmutableCollection<E>
-
copyIntoArray
Description copied from class:ImmutableCollectionCopies the contents of this immutable collection into the specified array at the specified offset. Returnsoffset + size().- Overrides:
copyIntoArrayin classImmutableCollection<E>
-
hashCode
public final int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceSet<E>- Overrides:
hashCodein classImmutableSet<E>
-
toString
- Overrides:
toStringin classAbstractCollection<E>
-