Package software.kes.collectionviews
Interface NonEmptySetBuilder<A>
-
- Type Parameters:
A
- the element type
- All Superinterfaces:
SetBuilder<A>
public interface NonEmptySetBuilder<A> extends SetBuilder<A>
A builder forImmutableNonEmptySet
s.A
NonEmptySetBuilder
is immutable and all add operations return a newSetBuilder
. To construct theImmutableNonEmptySet
, callbuild()
.It is safe to continue adding to a
NonEmptySetBuilder
even afterbuild
is called. It is also safe to "fork" aNonEmptySetBuilder
, 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 NonEmptySetBuilder<A>
addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisNonEmptySetBuilder
.NonEmptySetBuilder<A>
addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisNonEmptySetBuilder
.ImmutableNonEmptySet<A>
build()
Builds a newImmutableNonEmptySet
.static <A> NonEmptySetBuilder<A>
builder(int initialCapacity, A first)
Creates a newNonEmptySetBuilder
with an initial capacity hint.static <A> NonEmptySetBuilder<A>
builder(A first)
Creates a newNonEmptySetBuilder
.-
Methods inherited from interface software.kes.collectionviews.SetBuilder
add, addAll
-
-
-
-
Method Detail
-
addAll
NonEmptySetBuilder<A> addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collection
to thisNonEmptySetBuilder
.- Specified by:
addAll
in interfaceSetBuilder<A>
- Parameters:
elements
- the collection to add- Returns:
- a new
NonEmptySetBuilder
with the elements added
-
addAll
NonEmptySetBuilder<A> addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterable
to thisNonEmptySetBuilder
.Since
Set
s areFiniteIterable
s, this method accepts anySet
.- Specified by:
addAll
in interfaceSetBuilder<A>
- Parameters:
elements
- theFiniteIterable
to add- Returns:
- a new
NonEmptySetBuilder
with the elements added
-
build
ImmutableNonEmptySet<A> build()
Builds a newImmutableNonEmptySet
.It is safe to call this at any point, and it safe to continue adding elements after calling this.
- Specified by:
build
in interfaceSetBuilder<A>
- Returns:
- an
ImmutableNonEmptySet
.
-
builder
static <A> NonEmptySetBuilder<A> builder(A first)
Creates a newNonEmptySetBuilder
.- Type Parameters:
A
- the element type- Parameters:
first
- the first element- Returns:
- an empty
SetBuilder
-
builder
static <A> NonEmptySetBuilder<A> builder(int initialCapacity, A first)
Creates a newNonEmptySetBuilder
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
SetBuilder
-
-