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 int
final long
static final <T> UnfoldSpliterator
<T> Factory for instances ofUnfoldSpliterator
.final boolean
tryAdvance
(Consumer<? super T> action) trySplit()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 newUnfoldSpliterator
instance.- Parameters:
seed
- The initial value;may benull
.generator
- The generator.
-
-
Method Details
-
characteristics
- Specified by:
characteristics
in interfaceSpliterator<T>
-
estimateSize
- Specified by:
estimateSize
in 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:
tryAdvance
in interfaceSpliterator<T>
-
trySplit
- Specified by:
trySplit
in interfaceSpliterator<T>
-