Package com.google.common.collect
Class ImmutableSet.SetBuilderImpl<E>
- java.lang.Object
-
- com.google.common.collect.ImmutableSet.SetBuilderImpl<E>
-
- Direct Known Subclasses:
ImmutableSet.EmptySetBuilderImpl
,ImmutableSet.JdkBackedSetBuilderImpl
,ImmutableSet.RegularSetBuilderImpl
- Enclosing class:
- ImmutableSet<E>
private abstract static class ImmutableSet.SetBuilderImpl<E> extends java.lang.Object
Swappable internal implementation of an ImmutableSet.Builder.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) E[]
dedupedElements
(package private) int
distinct
-
Constructor Summary
Constructors Constructor Description SetBuilderImpl(int expectedCapacity)
SetBuilderImpl(ImmutableSet.SetBuilderImpl<E> toCopy)
Initializes this SetBuilderImpl with a copy of the deduped elements array from toCopy.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract ImmutableSet.SetBuilderImpl<E>
add(E e)
Adds e to this SetBuilderImpl, returning the updated result.(package private) void
addDedupedElement(E e)
Adds e to the insertion-order array of deduplicated elements.(package private) abstract ImmutableSet<E>
build()
(package private) ImmutableSet.SetBuilderImpl<E>
combine(ImmutableSet.SetBuilderImpl<E> other)
Adds all the elements from the specified SetBuilderImpl to this SetBuilderImpl.(package private) abstract ImmutableSet.SetBuilderImpl<E>
copy()
Creates a new copy of this SetBuilderImpl.private void
ensureCapacity(int minCapacity)
Resizes internal data structures if necessary to store the specified number of distinct elements.(package private) ImmutableSet.SetBuilderImpl<E>
review()
Call this before build().
-
-
-
Field Detail
-
dedupedElements
E[] dedupedElements
-
distinct
int distinct
-
-
Constructor Detail
-
SetBuilderImpl
SetBuilderImpl(int expectedCapacity)
-
SetBuilderImpl
SetBuilderImpl(ImmutableSet.SetBuilderImpl<E> toCopy)
Initializes this SetBuilderImpl with a copy of the deduped elements array from toCopy.
-
-
Method Detail
-
ensureCapacity
private void ensureCapacity(int minCapacity)
Resizes internal data structures if necessary to store the specified number of distinct elements.
-
addDedupedElement
final void addDedupedElement(E e)
Adds e to the insertion-order array of deduplicated elements. Calls ensureCapacity.
-
add
abstract ImmutableSet.SetBuilderImpl<E> add(E e)
Adds e to this SetBuilderImpl, returning the updated result. Only use the returned SetBuilderImpl, since we may switch implementations if e.g. hash flooding is detected.
-
combine
final ImmutableSet.SetBuilderImpl<E> combine(ImmutableSet.SetBuilderImpl<E> other)
Adds all the elements from the specified SetBuilderImpl to this SetBuilderImpl.
-
copy
abstract ImmutableSet.SetBuilderImpl<E> copy()
Creates a new copy of this SetBuilderImpl. Modifications to that SetBuilderImpl will not affect this SetBuilderImpl or sets constructed from this SetBuilderImpl via build().
-
review
ImmutableSet.SetBuilderImpl<E> review()
Call this before build(). Does a final check on the internal data structures, e.g. shrinking unnecessarily large structures or detecting previously unnoticed hash flooding.
-
build
abstract ImmutableSet<E> build()
-
-