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>
Swappable internal implementation of an ImmutableSet.Builder.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSetBuilderImpl
(int expectedCapacity) SetBuilderImpl
(ImmutableSet.SetBuilderImpl<E> toCopy) Initializes this SetBuilderImpl with a copy of the deduped elements array from toCopy. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract ImmutableSet.SetBuilderImpl
<E> Adds e to this SetBuilderImpl, returning the updated result.(package private) final void
Adds e to the insertion-order array of deduplicated elements.(package private) abstract ImmutableSet
<E> build()
(package private) final 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 Details
-
dedupedElements
E[] dedupedElements -
distinct
int distinct
-
-
Constructor Details
-
SetBuilderImpl
SetBuilderImpl(int expectedCapacity) -
SetBuilderImpl
SetBuilderImpl(ImmutableSet.SetBuilderImpl<E> toCopy) Initializes this SetBuilderImpl with a copy of the deduped elements array from toCopy.
-
-
Method Details
-
ensureCapacity
private void ensureCapacity(int minCapacity) Resizes internal data structures if necessary to store the specified number of distinct elements. -
addDedupedElement
Adds e to the insertion-order array of deduplicated elements. Calls ensureCapacity. -
add
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
Adds all the elements from the specified SetBuilderImpl to this SetBuilderImpl. -
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
-