Module org.tquadrat.foundation.base
Class UnfoldSpliterator<T>
java.lang.Object
org.tquadrat.foundation.stream.internal.UnfoldSpliterator<T>
- Type Parameters:
T- The type of the stream elements.
- All Implemented Interfaces:
Spliterator<T>
@ClassVersion(sourceVersion="$Id: UnfoldSpliterator.java 1060 2023-09-24 19:21:40Z tquadrat $")
@API(status=INTERNAL,
since="0.0.7")
public final class UnfoldSpliterator<T>
extends Object
implements Spliterator<T>
An implementation of
Spliterator
that which takes a seed value and applies a generator to create the next
value, feeding each new value back into the generator to create subsequent
values. If the generator returns
Optional.empty(),
then there are no more values.- Author:
- Dominic Fox
- Modified by:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: UnfoldSpliterator.java 1060 2023-09-24 19:21:40Z tquadrat $
- Since:
- 0.0.7
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.stream.internal.UnfoldSpliterator"
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier and TypeFieldDescriptionThe current value.The generator.Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal longstatic final <T> UnfoldSpliterator<T> Factory for instances ofUnfoldSpliterator.final booleantryAdvance(Consumer<? super T> action) trySplit()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
forEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
m_Current
The current value. -
m_Generator
The generator.
-
-
Constructor Details
-
UnfoldSpliterator
Creates a newUnfoldSpliteratorinstance.- Parameters:
seed- The initial value;may benull.generator- The generator.
-
-
Method Details
-
characteristics
- Specified by:
characteristicsin interfaceSpliterator<T>
-
estimateSize
- Specified by:
estimateSizein interfaceSpliterator<T>
-
over
Factory for instances ofUnfoldSpliterator.- Type Parameters:
T- The type of the stream elements.- Parameters:
seed- The initial value;may benull.generator- The generator.- Returns:
- The new instance.
-
tryAdvance
- Specified by:
tryAdvancein interfaceSpliterator<T>
-
trySplit
- Specified by:
trySplitin interfaceSpliterator<T>
-
