E - Type of iterated elements from the base CloseableIteratorR - Type of transformed elements available for retrieval@PublicAPI @Beta public class MemoizingIterator<E,R> extends CloseableAbstractIterator<OrderedElement<E>> implements MemoizedSparseCollection<R>
CloseableIterator with the availability of retrieval of a transformation of the iterated elements.
Typical application is to remember SMILES structure sources of Molecules imported with a MolImporter.
It is recommended to access the memoized items use only after AbstractIterator.hasNext() is false. Otherwise new
structure might be collected upon the next AbstractIterator.hasNext() or AbstractIterator.next() invocation.
Please note that this class is marked with @Beta annotation, so it can be subject of incompatible changes or removal in later releases.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected OrderedElement<E> |
computeNext() |
R |
getMemoized(int i)
Get a non-missing memoiozed.
|
Function<Integer,R> |
getMemoizedFunction()
Function to access captured non-missing memoizeds. |
Optional<R> |
getMemoizedIfPresent(int i)
Get item when present.
|
R |
getMemoizedOrDefault(int i,
R defaultValue)
Get item when present or a default value when missing.
|
Function<Integer,R> |
getMemoizedOrDefaultFunction(R defaultValue)
Function to access present items with a default value for missing items. |
int |
size()
Collected items count.
|
endOfData, hasNext, next, peekremoveclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittransformforEachRemaining, hasNext, next, removeprotected OrderedElement<E> computeNext()
computeNext in class AbstractIterator<OrderedElement<E>>public void close()
close in interface CloseableIterator<OrderedElement<E>>close in interface Closeableclose in interface AutoCloseablepublic int size()
MemoizedSparseCollectionsize in interface MemoizedSparseCollection<R>public Optional<R> getMemoizedIfPresent(int i)
MemoizedSparseCollectiongetMemoizedIfPresent in interface MemoizedSparseCollection<R>i - Index which refers to either a missing or a present elementpublic R getMemoized(int i)
MemoizedSparseCollectiongetMemoized in interface MemoizedSparseCollection<R>i - Index of an item which is not missingpublic Function<Integer,R> getMemoizedFunction()
MemoizedSparseCollectionFunction to access captured non-missing memoizeds.getMemoizedFunction in interface MemoizedSparseCollection<R>Function of Integer to the memoized type T which delegates to
MemoizedSparseCollection.getMemoized(int)public R getMemoizedOrDefault(int i, R defaultValue)
MemoizedSparseCollectiongetMemoizedOrDefault in interface MemoizedSparseCollection<R>i - Index which refers to either a missing or a present elementdefaultValue - value for return when missingpublic Function<Integer,R> getMemoizedOrDefaultFunction(R defaultValue)
MemoizedSparseCollectionFunction to access present items with a default value for missing items.getMemoizedOrDefaultFunction in interface MemoizedSparseCollection<R>defaultValue - Value to return for missing items.Function of Integer to the memoized type T which delegates to
MemoizedSparseCollection.getMemoizedOrDefault(int, java.lang.Object)