Package software.kes.collectionviews
Interface NonEmptyVectorBuilder<A>
-
- Type Parameters:
A
- the element type
- All Superinterfaces:
VectorBuilder<A>
public interface NonEmptyVectorBuilder<A> extends VectorBuilder<A>
A builder forImmutableNonEmptyVector
s.A
NonEmptyVectorBuilder
is immutable and all add operations return a newVectorBuilder
. To construct theImmutableNonEmptyVector
, callbuild()
.It is safe to continue adding to a
NonEmptyVectorBuilder
even afterbuild
is called. It is also safe to "fork" aNonEmptyVectorBuilder
, but be aware that internal copies may be made when doing so.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description NonEmptyVectorBuilder<A>
addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisNonEmptyVectorBuilder
.NonEmptyVectorBuilder<A>
addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisNonEmptyVectorBuilder
.ImmutableNonEmptyVector<A>
build()
Builds a newImmutableNonEmptyVector
.static <A> NonEmptyVectorBuilder<A>
builder(int initialCapacity, A first)
Creates a newNonEmptyVectorBuilder
with an initial capacity hint.static <A> NonEmptyVectorBuilder<A>
builder(A first)
Creates a newNonEmptyVectorBuilder
.-
Methods inherited from interface software.kes.collectionviews.VectorBuilder
add, addAll
-
-
-
-
Method Detail
-
addAll
NonEmptyVectorBuilder<A> addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisNonEmptyVectorBuilder
.- Specified by:
addAll
in interfaceVectorBuilder<A>
- Parameters:
elements
- the collection to add- Returns:
- a new
NonEmptyVectorBuilder
with the elements added
-
addAll
NonEmptyVectorBuilder<A> addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisNonEmptyVectorBuilder
.Since
Vector
s areFiniteIterable
s, this method accepts anyVector
.- Specified by:
addAll
in interfaceVectorBuilder<A>
- Parameters:
elements
- theFiniteIterable
to add- Returns:
- a new
NonEmptyVectorBuilder
with the elements added
-
build
ImmutableNonEmptyVector<A> build()
Builds a newImmutableNonEmptyVector
.It is safe to call this at any point, and it safe to continue adding elements after calling this.
- Specified by:
build
in interfaceVectorBuilder<A>
- Returns:
- an
ImmutableNonEmptyVector
.
-
builder
static <A> NonEmptyVectorBuilder<A> builder(A first)
Creates a newNonEmptyVectorBuilder
.- Type Parameters:
A
- the element type- Parameters:
first
- the first element- Returns:
- an empty
VectorBuilder
-
builder
static <A> NonEmptyVectorBuilder<A> builder(int initialCapacity, A first)
Creates a newNonEmptyVectorBuilder
with an initial capacity hint.- Type Parameters:
A
- the element type- Parameters:
initialCapacity
- an initial capacity hint. Must be >= 0.first
- the first element- Returns:
- an empty
VectorBuilder
-
-