public class DFIterator<E extends Traversable> extends IRIterator<E>
DepthFirstIterator, which supports
depth-first iteration over a specific type when requested. Unlike DepthFirstIterator, DFIterator does not allocate internal storage
to place next items to be searched for; it performs memory-less search by
visiting the node in the IR tree to find the next item to be returned.| Constructor and Description |
|---|
DFIterator(Traversable root)
Constructs a new iterator that returns any traversable nodes during
iteration.
|
DFIterator(Traversable root,
java.lang.Class<? extends Traversable> c)
Constructs a new iterator that returns the specified IR type during
iteration.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<E> |
getList()
Returns a list of traversed elements of type
E using the current
iterator. |
boolean |
hasNext()
Checks if there is a next element of the requested type.
|
E |
next()
Returns the next IR node.
|
void |
pruneOn(java.lang.Class<? extends Traversable> c)
Considers the specified IR class type as one whose child nodes are not
visited during iteration.
|
void |
reset()
Initializes the iterator by placing the first item to be returned for a
call to
next(). |
void |
setNext(E next)
Forces the specified traversable element
next to be returned when
next() is called. |
next, next, nextExcept, removepublic DFIterator(Traversable root)
root - the initial node for the iteration.public DFIterator(Traversable root, java.lang.Class<? extends Traversable> c)
root - the initial node for the iteration.c - the IR class type to be iterated over.public boolean hasNext()
hasNext in interface java.util.Iterator<E extends Traversable>hasNext in class IRIterator<E extends Traversable>public E next()
next in interface java.util.Iterator<E extends Traversable>next in class IRIterator<E extends Traversable>java.util.NoSuchElementException - no more elements found.public void pruneOn(java.lang.Class<? extends Traversable> c)
c - the IR node type to be pruned on.public void reset()
next().reset in class IRIterator<E extends Traversable>public java.util.List<E> getList()
E using the current
iterator.