Package com.google.common.primitives
Class ImmutableLongArray.Builder
- java.lang.Object
-
- com.google.common.primitives.ImmutableLongArray.Builder
-
- Enclosing class:
- ImmutableLongArray
public static final class ImmutableLongArray.Builder extends java.lang.Object
A builder forImmutableLongArray
instances; obtained usingImmutableLongArray.builder(int)
.
-
-
Constructor Summary
Constructors Constructor Description Builder(int initialCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableLongArray.Builder
add(long value)
Appendsvalue
to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray.Builder
addAll(long[] values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray.Builder
addAll(ImmutableLongArray values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray.Builder
addAll(java.lang.Iterable<java.lang.Long> values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray.Builder
addAll(java.util.Collection<java.lang.Long> values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray.Builder
addAll(java.util.stream.LongStream stream)
Appends all values fromstream
, in order, to the end of the values the builtImmutableLongArray
will contain.ImmutableLongArray
build()
Returns a new immutable array.private void
ensureRoomFor(int numberToAdd)
private static int
expandedCapacity(int oldCapacity, int minCapacity)
-
-
-
Method Detail
-
add
public ImmutableLongArray.Builder add(long value)
Appendsvalue
to the end of the values the builtImmutableLongArray
will contain.
-
addAll
public ImmutableLongArray.Builder addAll(long[] values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.
-
addAll
public ImmutableLongArray.Builder addAll(java.lang.Iterable<java.lang.Long> values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.
-
addAll
public ImmutableLongArray.Builder addAll(java.util.Collection<java.lang.Long> values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.
-
addAll
public ImmutableLongArray.Builder addAll(java.util.stream.LongStream stream)
Appends all values fromstream
, in order, to the end of the values the builtImmutableLongArray
will contain.
-
addAll
public ImmutableLongArray.Builder addAll(ImmutableLongArray values)
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.
-
ensureRoomFor
private void ensureRoomFor(int numberToAdd)
-
expandedCapacity
private static int expandedCapacity(int oldCapacity, int minCapacity)
-
build
public ImmutableLongArray build()
Returns a new immutable array. The builder can continue to be used after this call, to append more values and build again.Performance note: the returned array is backed by the same array as the builder, so no data is copied as part of this step, but this may occupy more memory than strictly necessary. To copy the data to a right-sized backing array, use
.build().trimmed()
.
-
-