- Type Parameters:
E- The type of elements in this set.
- All Superinterfaces:
Collection<E>,Iterable<E>,Set<E>
- All Known Implementing Classes:
LazySetImpl
@ClassVersion(sourceVersion="$Id: LazySet.java 1032 2022-04-10 17:27:44Z tquadrat $")
@API(status=STABLE,
since="0.0.5")
public sealed interface LazySet<E>
extends Set<E>
permits LazySetImpl<E>
The interface for a
Set
that will be initialised only when required.- Note:
-
- There is no implementation of a
map()method in this interface because it is assumed that this would be confusing: such amap()method would operate on the whole list that is wrapped by this value, and not on an entry as one would expect. Refer to .
- There is no implementation of a
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: LazySet.java 1032 2022-04-10 17:27:44Z tquadrat $
- Since:
- 0.0.5
- See Also:
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.util.LazySet"
-
Method Summary
Modifier and TypeMethodDescriptionvoidIf thisLazySetinstance has been initialised already, the providedConsumerwill be executed; otherwise nothing happens.voidinit()Forces the initialisation of thisLazySetinstance.booleanChecks whether thisLazySetinstance has been initialised already.static <E> LazySet<E> Creates a newLazySetinstance that is already initialised.static <E> LazySet<E> Creates a newLazySetinstance that uses the given supplier to initialise.static <E> LazySet<E> Creates a newLazySetinstance that uses the given supplier to create the internal map, but that supplier does not provide values on initialisation.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
ifPresent
If thisLazySetinstance has been initialised already, the providedConsumerwill be executed; otherwise nothing happens.- Parameters:
consumer- The consumer.
-
init
void init()Forces the initialisation of thisLazySetinstance. -
isPresent
boolean isPresent()Checks whether thisLazySetinstance has been initialised already.- Returns:
trueif the instance was initialised,falseotherwise.
-
of
Creates a newLazySetinstance that is already initialised.- Type Parameters:
E- The type of elements in this set.- Parameters:
value- The value.- Returns:
- The new instance.
-
use
Creates a newLazySetinstance that uses the given supplier to create the internal map, but that supplier does not provide values on initialisation.- Type Parameters:
E- The type of elements in this set.- Parameters:
supplier- The supplier that initialises for the new instance ofLazySetwhen needed.- Returns:
- The new instance.
-
use
@API(status=STABLE, since="0.0.5") static <E> LazySet<E> use(boolean doPopulate, Supplier<? extends Set<E>> supplier) Creates a newLazySetinstance that uses the given supplier to initialise.- Type Parameters:
E- The type of elements in this set.- Parameters:
doPopulate-trueif the provided supplier will put entries to the set on initialisation,falseif it will create an empty set.supplier- The supplier that initialises for the new instance ofLazySetwhen needed.- Returns:
- The new instance.
-
