Package at.jku.ssw.fp.coll
Class FSet.Builder<E>
- java.lang.Object
-
- at.jku.ssw.fp.coll.FSet.Builder<E>
-
- Type Parameters:
E
- the type of the elements
public static class FSet.Builder<E> extends Object
Mutable builder for building functional sets. It internally uses a mutable linked list for collecting the elements. Then allows to create the immutable functional list with the collected elements.
-
-
Field Summary
Fields Modifier and Type Field Description private LinkedList<E>
list
The mutable linked list for collecting the elements.
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder()
Private constructor for creating an empty builder.private
Builder(E[] es)
Private constructor for creating a builder with the provided elements already collected.private
Builder(Iterable<? extends E> es)
Private constructor for creating a builder where the elements in the provided iterable get collected.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(E e)
Adds an element to the builder, if not already contained.FSet<E>
build()
Creates an functional set from the collected elements.static <E> FSet.Builder<E>
create()
Creates a new builder for collecting elements and building a functional set.static <E> FSet.Builder<E>
of(E... es)
Creates a builder with the provided elements already collected.static <E> FSet.Builder<E>
of(Iterable<? extends E> es)
Creates a builder with the provided elements already collected.
-
-
-
Field Detail
-
list
private final LinkedList<E> list
The mutable linked list for collecting the elements.
-
-
Constructor Detail
-
Builder
private Builder()
Private constructor for creating an empty builder.
-
Builder
private Builder(E[] es)
Private constructor for creating a builder with the provided elements already collected.- Parameters:
es
- the elements to collect
-
-
Method Detail
-
of
public static <E> FSet.Builder<E> of(E... es)
Creates a builder with the provided elements already collected.- Type Parameters:
E
- the element type- Parameters:
es
- the elements to collect- Returns:
- the builder with the elements collected
-
of
public static <E> FSet.Builder<E> of(Iterable<? extends E> es)
Creates a builder with the provided elements already collected.- Type Parameters:
E
- the element type- Parameters:
es
- the elements to collect- Returns:
- the builder with the elements collected
-
create
public static <E> FSet.Builder<E> create()
Creates a new builder for collecting elements and building a functional set.- Type Parameters:
E
- the element type- Returns:
- a new builder
-
add
public void add(E e)
Adds an element to the builder, if not already contained.- Parameters:
e
- the element to add
-
-