Package com.google.common.collect
Class ImmutableSet.RegularSetBuilderImpl<E>
- java.lang.Object
-
- com.google.common.collect.ImmutableSet.SetBuilderImpl<E>
-
- com.google.common.collect.ImmutableSet.RegularSetBuilderImpl<E>
-
- Enclosing class:
- ImmutableSet<E>
private static final class ImmutableSet.RegularSetBuilderImpl<E> extends ImmutableSet.SetBuilderImpl<E>
Default implementation of the guts of ImmutableSet.Builder, creating an open-addressed hash table and deduplicating elements as they come, so it only allocates O(max(distinct, expectedCapacity)) rather than O(calls to add).This implementation attempts to detect hash flooding, and if it's identified, falls back to JdkBackedSetBuilderImpl.
-
-
Field Summary
Fields Modifier and Type Field Description private int
expandTableThreshold
private int
hashCode
private java.lang.Object[]
hashTable
private int
maxRunBeforeFallback
-
Fields inherited from class com.google.common.collect.ImmutableSet.SetBuilderImpl
dedupedElements, distinct
-
-
Constructor Summary
Constructors Constructor Description RegularSetBuilderImpl(int expectedCapacity)
RegularSetBuilderImpl(ImmutableSet.RegularSetBuilderImpl<E> toCopy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ImmutableSet.SetBuilderImpl<E>
add(E e)
Adds e to this SetBuilderImpl, returning the updated result.(package private) ImmutableSet<E>
build()
(package private) ImmutableSet.SetBuilderImpl<E>
copy()
Creates a new copy of this SetBuilderImpl.(package private) void
ensureTableCapacity(int minCapacity)
(package private) ImmutableSet.SetBuilderImpl<E>
review()
Call this before build().-
Methods inherited from class com.google.common.collect.ImmutableSet.SetBuilderImpl
addDedupedElement, combine
-
-
-
-
Constructor Detail
-
RegularSetBuilderImpl
RegularSetBuilderImpl(int expectedCapacity)
-
RegularSetBuilderImpl
RegularSetBuilderImpl(ImmutableSet.RegularSetBuilderImpl<E> toCopy)
-
-
Method Detail
-
ensureTableCapacity
void ensureTableCapacity(int minCapacity)
-
add
ImmutableSet.SetBuilderImpl<E> add(E e)
Description copied from class:ImmutableSet.SetBuilderImpl
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.- Specified by:
add
in classImmutableSet.SetBuilderImpl<E>
-
copy
ImmutableSet.SetBuilderImpl<E> copy()
Description copied from class:ImmutableSet.SetBuilderImpl
Creates a new copy of this SetBuilderImpl. Modifications to that SetBuilderImpl will not affect this SetBuilderImpl or sets constructed from this SetBuilderImpl via build().- Specified by:
copy
in classImmutableSet.SetBuilderImpl<E>
-
review
ImmutableSet.SetBuilderImpl<E> review()
Description copied from class:ImmutableSet.SetBuilderImpl
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.- Overrides:
review
in classImmutableSet.SetBuilderImpl<E>
-
build
ImmutableSet<E> build()
- Specified by:
build
in classImmutableSet.SetBuilderImpl<E>
-
-