Package software.kes.collectionviews
Interface SetBuilder<A>
-
- Type Parameters:
A- the element type
- All Known Subinterfaces:
NonEmptySetBuilder<A>
public interface SetBuilder<A>A builder forImmutableSets.A
SetBuilderis immutable and all add operations return a newSetBuilder. To construct theImmutableSet, callbuild().It is safe to continue adding to a
SetBuildereven afterbuildis called. It is also safe to "fork" aSetBuilder, 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>add(A element)Adds an element to thisSetBuilder.SetBuilder<A>addAll(java.util.Collection<A> elements)Adds all elements in ajava.util.Collectionto thisSetBuilder.SetBuilder<A>addAll(software.kes.enhancediterables.FiniteIterable<A> elements)Adds all elements in aFiniteIterableto thisSetBuilder.NonEmptySetBuilder<A>addAll(software.kes.enhancediterables.NonEmptyFiniteIterable<A> elements)Adds all elements in aNonEmptyFiniteIterableto thisSetBuilder.ImmutableSet<A>build()Builds a newImmutableSet.static <A> SetBuilder<A>builder()Creates a newSetBuilder.static <A> SetBuilder<A>builder(int initialCapacity)Creates a newSetBuilderwith an initial capacity hint.
-
-
-
Method Detail
-
add
NonEmptySetBuilder<A> add(A element)
Adds an element to thisSetBuilder.- Parameters:
element- the element to add- Returns:
- a new
NonEmptySetBuilderwith the element added
-
addAll
SetBuilder<A> addAll(java.util.Collection<A> elements)
Adds all elements in ajava.util.Collectionto thisSetBuilder.- Parameters:
elements- the collection to add- Returns:
- a new
SetBuilderwith the elements added
-
addAll
SetBuilder<A> addAll(software.kes.enhancediterables.FiniteIterable<A> elements)
Adds all elements in aFiniteIterableto thisSetBuilder.Since
Sets areFiniteIterables, this method accepts anySet.- Parameters:
elements- theFiniteIterableto add- Returns:
- a new
SetBuilderwith the elements added
-
addAll
NonEmptySetBuilder<A> addAll(software.kes.enhancediterables.NonEmptyFiniteIterable<A> elements)
Adds all elements in aNonEmptyFiniteIterableto thisSetBuilder.Since
NonEmptyVectors areNonEmptyFiniteIterables, this method accepts anyNonEmptyVector.- Parameters:
elements- theNonEmptyFiniteIterableto add- Returns:
- a new
NonEmptySetBuilderwith the elements added
-
build
ImmutableSet<A> build()
Builds a newImmutableSet.It is safe to call this at any point, and it safe to continue adding elements after calling this.
- Returns:
- an
ImmutableSet.
-
builder
static <A> SetBuilder<A> builder()
Creates a newSetBuilder.- Type Parameters:
A- the element type- Returns:
- an empty
SetBuilder
-
builder
static <A> SetBuilder<A> builder(int initialCapacity)
Creates a newSetBuilderwith an initial capacity hint.- Type Parameters:
A- the element type- Parameters:
initialCapacity- an initial capacity hint. Must be >= 0.- Returns:
- an empty
SetBuilder
-
-