| Constructor and Description |
|---|
TreeIterator(T parent, boolean includeRoot)
Creates a new
TreeIterator
|
| Modifier and Type | Method and Description |
|---|---|
T |
getRoot()
Returns the root this iterator is searching.
|
boolean |
hasNext()
Returns
true if there are more values in this iterator.
|
protected boolean |
isReturnValue(T node)
Return true if this node can be returned by this iterator.
|
protected abstract T[] |
listChildren(T parent)
List the children of a parent this object should iterate over.
|
T |
next()
Returns the next node in this iterator.
|
void |
remove()
Throws an UnsupportedOperationException().
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic TreeIterator(T parent, boolean includeRoot)
TreeIterator
parent - the root to begin searching in.
includeRoot - whether the first argument should be one of the values returned by this iterator
protected abstract T[] listChildren(T parent)
(In fact too much filtering at this step can be a problem. For example: if a file iterator wants to only return files with a certain extension this method still needs to return directories, or the iterator won't search deep enough.)
This may return null, or include null elements in the return array.
protected boolean isReturnValue(T node)
next() to return.
The implementation is simply to return true.
node - a possible return value for
next()
false if this is unacceptable and we have to keep searching.
public T getRoot()
public boolean hasNext()
true if there are more values in this iterator.
public T next()
public void remove()