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 forImmutableNonEmptySets.A
NonEmptySetBuilderis immutable and all add operations return a newSetBuilder. To construct theImmutableNonEmptySet, callbuild().It is safe to continue adding to a
NonEmptySetBuildereven afterbuildis 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.Collectionto thisNonEmptySetBuilder.NonEmptySetBuilder<A>addAll(software.kes.enhancediterables.FiniteIterable<A> elements)Adds all elements in aFiniteIterableto thisNonEmptySetBuilder.ImmutableNonEmptySet<A>build()Builds a newImmutableNonEmptySet.static <A> NonEmptySetBuilder<A>builder(int initialCapacity, A first)Creates a newNonEmptySetBuilderwith 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.Collectionto thisNonEmptySetBuilder.- Specified by:
addAllin interfaceSetBuilder<A>- Parameters:
elements- the collection to add- Returns:
- a new
NonEmptySetBuilderwith the elements added
-
addAll
NonEmptySetBuilder<A> addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterableto thisNonEmptySetBuilder.Since
Sets areFiniteIterables, this method accepts anySet.- Specified by:
addAllin interfaceSetBuilder<A>- Parameters:
elements- theFiniteIterableto add- Returns:
- a new
NonEmptySetBuilderwith 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:
buildin 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 newNonEmptySetBuilderwith 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
-
-