E - type of shared elementsfinal class SharingEnumerator<E> extends AbstractEnumerator<E>
Enumerator sharing the elements of a common
ShareableEnumerator.
Sharing enumerators get spawned by ShareableEnumerator instances with
the purpose of sharing independently an enumerable sequence without
triggering the original enumeration multiple times.
A ShareableEnumerator enters its shared mode once it starts
spawning sharing enumerators. When spawned SharingEnumerator
instances start enumerating, the common ShareableEnumerator enters
its shared enumerating mode and further sharing is not possible.
SharingEnumerator instances can enumerate the shared elements
independently because the ShareableEnumerator behind them buffers
the elements being shared. Allowing too much divergence between the sharing
enumerators may lead to buffer overflows.
Enumerator,
AbstractEnumerator,
ShareableEnumerator| Constructor and Description |
|---|
SharingEnumerator(ShareableEnumerator<E> sharedSource,
Enumerator<E> cachedSource)
Creates a
SharingEnumerator instance that shares the elements
of sharedSource via cachedSource. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup()
Cleans up the internals of the current enumerator when enumeration
ends.
|
protected boolean |
internalHasNext()
Returns whether the enumerator has more elements.
|
protected E |
internalNext()
Returns the next enumerated element.
|
enumerating, hasNext, nextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitallMatch, anyMatch, append, as, asEnumerable, asEnumeration, asFiltered, asOptional, asShareable, asSpliterator, asStream, asSupplier, asTolerant, asTolerant, choiceOf, choiceOf, collect, concat, concat, concat, concat, concat, concat, concatOn, contains, count, distinct, elementAt, elementsEqual, empty, filter, first, flatMap, forEach, iterate, last, limit, limitWhile, map, map, max, min, noneMatch, of, of, of, of, of, of, of, ofLateBinding, ofLazyEnumeration, ofLazyIterable, ofLazyIterator, ofLazySpliterator, ofLazyStream, on, peek, prepend, prepend, prepend, prepend, prepend, prepend, prependOn, range, rangeClosed, rangeInt, rangeIntClosed, rangeLong, rangeLongClosed, reduce, reduce, repeat, repeatAll, repeatAll, repeatEach, reverse, single, skip, skipWhile, sorted, sorted, take, takeWhile, toArray, toList, toMap, toSet, union, union, union, union, union, union, unionOn, zipAll, zipAny, zipBoth, zipLeft, zipRightforEachRemaining, removepublic SharingEnumerator(ShareableEnumerator<E> sharedSource, Enumerator<E> cachedSource)
SharingEnumerator instance that shares the elements
of sharedSource via cachedSource.sharedSource - owner ShareableEnumerator instance that
needs to be notified that the shared enumeration has commenced.cachedSource - Enumerator instance resulted from calling
AbstractEnumerable.enumerator().protected boolean internalHasNext()
AbstractEnumerator
This method is the internal counterpart of AbstractEnumerator.hasNext().
internalHasNext in class AbstractEnumerator<E>AbstractEnumerator.next()protected E internalNext()
AbstractEnumerator
This method is the internal counterpart of AbstractEnumerator.hasNext()
internalNext in class AbstractEnumerator<E>protected void cleanup()
AbstractEnumeratorBy default this method does nothing.
cleanup in class AbstractEnumerator<E>AbstractEnumerator.hasNext(),
AbstractEnumerator.next(),
AbstractEnumerator.internalHasNext(),
AbstractEnumerator.internalNext()Copyright © 2016. All rights reserved.