Class SplitMapUncertainIterator<T,K,R>
java.lang.Object
com.github.basking2.sdsai.itrex.iterators.splitjoin.SplitMapUncertainIterator<T,K,R>
- All Implemented Interfaces:
UncertainIterator<UncertainIterator<R>>
public class SplitMapUncertainIterator<T,K,R>
extends Object
implements UncertainIterator<UncertainIterator<R>>
Split an iterator's elements across an UncertainIterator.
This produces an object that may be processed and given to
JoinUncertainIteratorsIterator
.
This object's operation is to take input elements from an iterator and pass them to
"child" iterators. Because we never know if a child iterator will get another element from the source stream,
based on the splitFunction, the child iterators must all be UncertainIterators.
On calls to hasNext() an element is pulled from the input stream. It is checked if it will produce a new
output iterator. If it will, then we create and stage that output iterator to be returned on
the next call to next(). If the next element pulled maps to an existing iterator
we return MAYBE from hasNext() and no element is available from next().
Recall that MAYBE should be considered FALSE until data is drawn from another source.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.basking2.sdsai.itrex.iterators.splitjoin.UncertainIterator
UncertainIterator.HAS_NEXT
-
Constructor Summary
ConstructorDescriptionSplitMapUncertainIterator
(Iterator<T> inputs, Function<T, K> splitFunction, MappingIterator.Mapper<T, R> mapper) -
Method Summary
Modifier and TypeMethodDescriptionhasNext()
Calling this populates iterators.next()
Get the next value or throwNoSuchElementException
.
-
Constructor Details
-
SplitMapUncertainIterator
-
-
Method Details
-
hasNext
Calling this populates iterators. If this returns MAYBE then a new element was enqueued into another iterator. If this returns TRUE then a new element caused a new iterator to be creatd. If this returns FALSE then no inputs remain. Whatever is in the output iterators is all the work that remains.- Specified by:
hasNext
in interfaceUncertainIterator<T>
- Returns:
- If there is another iterator to be fetched.
-
next
Description copied from interface:UncertainIterator
Get the next value or throwNoSuchElementException
.- Specified by:
next
in interfaceUncertainIterator<T>
- Returns:
- The next element.
-