Package software.kes.collectionviews
Interface VectorBuilder<A>
-
- Type Parameters:
A
- the element type
- All Known Subinterfaces:
NonEmptyVectorBuilder<A>
public interface VectorBuilder<A>
A builder forImmutableVector
s.A
VectorBuilder
is immutable and all add operations return a newVectorBuilder
. To construct theImmutableVector
, callbuild()
.It is safe to continue adding to a
VectorBuilder
even afterbuild
is called. It is also safe to "fork" aVectorBuilder
, 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>
add(A element)
Adds an element to thisVectorBuilder
.VectorBuilder<A>
addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisVectorBuilder
.VectorBuilder<A>
addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisVectorBuilder
.NonEmptyVectorBuilder<A>
addAll(software.kes.enhancediterables.NonEmptyFiniteIterable<A> elements)
Adds all elements in aNonEmptyFiniteIterable
to thisVectorBuilder
.ImmutableVector<A>
build()
Builds a newImmutableVector
.static <A> VectorBuilder<A>
builder()
Creates a newVectorBuilder
.static <A> VectorBuilder<A>
builder(int initialCapacity)
Creates a newVectorBuilder
with an initial capacity hint.
-
-
-
Method Detail
-
add
NonEmptyVectorBuilder<A> add(A element)
Adds an element to thisVectorBuilder
.- Parameters:
element
- the element to add- Returns:
- a new
NonEmptyVectorBuilder
with the element added
-
addAll
VectorBuilder<A> addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisVectorBuilder
.- Parameters:
elements
- the collection to add- Returns:
- a new
VectorBuilder
with the elements added
-
addAll
VectorBuilder<A> addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisVectorBuilder
.Since
Vector
s areFiniteIterable
s, this method accepts anyVector
.- Parameters:
elements
- theFiniteIterable
to add- Returns:
- a new
VectorBuilder
with the elements added
-
addAll
NonEmptyVectorBuilder<A> addAll(software.kes.enhancediterables.NonEmptyFiniteIterable<A> elements)
Adds all elements in aNonEmptyFiniteIterable
to thisVectorBuilder
.Since
NonEmptyVector
s areNonEmptyFiniteIterable
s, this method accepts anyNonEmptyVector
.- Parameters:
elements
- theNonEmptyFiniteIterable
to add- Returns:
- a new
NonEmptyVectorBuilder
with the elements added
-
build
ImmutableVector<A> build()
Builds a newImmutableVector
.It is safe to call this at any point, and it safe to continue adding elements after calling this.
- Returns:
- an
ImmutableVector
.
-
builder
static <A> VectorBuilder<A> builder()
Creates a newVectorBuilder
.- Type Parameters:
A
- the element type- Returns:
- an empty
VectorBuilder
-
builder
static <A> VectorBuilder<A> builder(int initialCapacity)
Creates a newVectorBuilder
with an initial capacity hint.- Type Parameters:
A
- the element type- Parameters:
initialCapacity
- an initial capacity hint. Must be >= 0.- Returns:
- an empty
VectorBuilder
-
-