|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.isi.stella.Stella_Object edu.isi.stella.StandardObject edu.isi.stella.AbstractIterator edu.isi.stella.Iterator edu.isi.stella.MemoizableIterator
public class MemoizableIterator
Iterator class with value buffering that can be used to memoize some
baseIterator
without having to generate all its values first. The
memoized iterator needs to be cloned to allow multiple iterations over
the collection represented by the memoized iterator. Use the following
idiom to memoize some arbitrary iterator and return a properly cloned value:
(clone-memoized-iterator
(memoize (...) <options>*
(new MEMOIZABLE-ITERATOR
:base-iterator <base-iterator>)))
This will ensure that <base-iterator> is exhausted exactly once even if
there are multiple clones for the same memoized value, and that each value
is generated as late as absolutely possible. THIS IS NOT YET THREAD SAFE!
Field Summary | |
---|---|
Iterator |
baseIterator
This slot is only needed to pass the base iterator to the constructor. |
Cons |
cursor
Trailing cursor to the list of values generated so far. |
Cons |
iteratorAndValues
Holds the base iterator and the values generated so far. |
Fields inherited from class edu.isi.stella.Iterator |
---|
value |
Fields inherited from class edu.isi.stella.AbstractIterator |
---|
firstIterationP |
Constructor Summary | |
---|---|
MemoizableIterator()
|
Method Summary | |
---|---|
static Stella_Object |
accessMemoizableIteratorSlotValue(MemoizableIterator self,
Symbol slotname,
Stella_Object value,
boolean setvalueP)
|
AbstractIterator |
allocateIterator()
Alias for cloneMemoizedIterator . |
static Iterator |
cloneMemoizedIterator(MemoizableIterator self)
Clone the memoized iterator self so it can be used to
iterate over the collection represented by self , while allowing to iterate
over it multiple times via multiple clones. |
void |
initializeMemoizableIterator()
|
static MemoizableIterator |
newMemoizableIterator(Iterator baseIterator)
|
boolean |
nextP()
Generate the next value of the memoized iterator self (or
one of its clones) by either using one of the values generated so far or by
generating and saving the next value of the baseIterator . |
Surrogate |
primaryType()
Returns the primary type of self . |
Methods inherited from class edu.isi.stella.Iterator |
---|
advance, concatenate, consify, emptyP, listify, memberP, pop, printClassList |
Methods inherited from class edu.isi.stella.AbstractIterator |
---|
accessAbstractIteratorSlotValue, length |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Iterator baseIterator
self
is initialized it will be cleared.
public Cons iteratorAndValues
public Cons cursor
iteratorAndValues
.
Constructor Detail |
---|
public MemoizableIterator()
Method Detail |
---|
public static MemoizableIterator newMemoizableIterator(Iterator baseIterator)
public boolean nextP()
self
(or
one of its clones) by either using one of the values generated so far or by
generating and saving the next value of the baseIterator
.
nextP
in class AbstractIterator
public AbstractIterator allocateIterator()
cloneMemoizedIterator
.
allocateIterator
in class AbstractIterator
public static Iterator cloneMemoizedIterator(MemoizableIterator self)
self
so it can be used to
iterate over the collection represented by self
, while allowing to iterate
over it multiple times via multiple clones.
self
-
public void initializeMemoizableIterator()
public static Stella_Object accessMemoizableIteratorSlotValue(MemoizableIterator self, Symbol slotname, Stella_Object value, boolean setvalueP)
public Surrogate primaryType()
Stella_Object
self
.
Gets defined automatically for every non-abstract subclass of OBJECT.
primaryType
in class Stella_Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |