Package com.google.common.collect
Class ImmutableCollection.ArrayBasedBuilder<E>
- java.lang.Object
-
- com.google.common.collect.ImmutableCollection.Builder<E>
-
- com.google.common.collect.ImmutableCollection.ArrayBasedBuilder<E>
-
- Direct Known Subclasses:
ImmutableList.Builder
,ImmutableSet.Builder
- Enclosing class:
- ImmutableCollection<E>
abstract static class ImmutableCollection.ArrayBasedBuilder<E> extends ImmutableCollection.Builder<E>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.Object[]
contents
(package private) int
size
-
Fields inherited from class com.google.common.collect.ImmutableCollection.Builder
DEFAULT_INITIAL_CAPACITY
-
-
Constructor Summary
Constructors Constructor Description ArrayBasedBuilder(int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableCollection.ArrayBasedBuilder<E>
add(E element)
Addselement
to theImmutableCollection
being built.ImmutableCollection.Builder<E>
add(E... elements)
Adds each element ofelements
to theImmutableCollection
being built.ImmutableCollection.Builder<E>
addAll(java.lang.Iterable<? extends E> elements)
Adds each element ofelements
to theImmutableCollection
being built.private void
ensureCapacity(int minCapacity)
Expand the absolute capacity of the builder so it can accept at least the specified number of elements without being resized.-
Methods inherited from class com.google.common.collect.ImmutableCollection.Builder
addAll, build, expandedCapacity
-
-
-
-
Method Detail
-
ensureCapacity
private void ensureCapacity(int minCapacity)
Expand the absolute capacity of the builder so it can accept at least the specified number of elements without being resized.
-
add
public ImmutableCollection.ArrayBasedBuilder<E> add(E element)
Description copied from class:ImmutableCollection.Builder
Addselement
to theImmutableCollection
being built.Note that each builder class covariantly returns its own type from this method.
- Specified by:
add
in classImmutableCollection.Builder<E>
- Parameters:
element
- the element to add- Returns:
- this
Builder
instance
-
add
public ImmutableCollection.Builder<E> add(E... elements)
Description copied from class:ImmutableCollection.Builder
Adds each element ofelements
to theImmutableCollection
being built.Note that each builder class overrides this method in order to covariantly return its own type.
- Overrides:
add
in classImmutableCollection.Builder<E>
- Parameters:
elements
- the elements to add- Returns:
- this
Builder
instance
-
addAll
public ImmutableCollection.Builder<E> addAll(java.lang.Iterable<? extends E> elements)
Description copied from class:ImmutableCollection.Builder
Adds each element ofelements
to theImmutableCollection
being built.Note that each builder class overrides this method in order to covariantly return its own type.
- Overrides:
addAll
in classImmutableCollection.Builder<E>
- Parameters:
elements
- the elements to add- Returns:
- this
Builder
instance
-
-