Package com.google.common.primitives
Class ImmutableLongArray.Builder
java.lang.Object
com.google.common.primitives.ImmutableLongArray.Builder
- Enclosing class:
ImmutableLongArray
A builder for
ImmutableLongArray
instances; obtained using ImmutableLongArray.builder(int)
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(long value) Appendsvalue
to the end of the values the builtImmutableLongArray
will contain.addAll
(long[] values) Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.addAll
(ImmutableLongArray values) Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.addAll
(Collection<Long> values) Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain.addAll
(LongStream stream) Appends all values fromstream
, in order, to the end of the values the builtImmutableLongArray
will contain.build()
Returns a new immutable array.private void
ensureRoomFor
(int numberToAdd) private static int
expandedCapacity
(int oldCapacity, int minCapacity)
-
Field Details
-
array
private long[] array -
count
private int count
-
-
Constructor Details
-
Builder
Builder(int initialCapacity)
-
-
Method Details
-
add
Appendsvalue
to the end of the values the builtImmutableLongArray
will contain. -
addAll
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain. -
addAll
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain. -
addAll
Appendsvalues
, in order, to the end of the values the builtImmutableLongArray
will contain. -
addAll
Appends all values fromstream
, in order, to the end of the values the builtImmutableLongArray
will contain. -
addAll
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
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()
.
-