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