public abstract class IlvPreorderIterator<E> extends Object implements Iterator<E>
IlvPreorderIterator
is an abstract class that provides traversal
over a generic tree structure of objects in preorder. Concrete subclasses must
simply provide an implementation of getChildren
that properly
accounts for the type of nodes being traversed.Modifier | Constructor and Description |
---|---|
protected |
IlvPreorderIterator()
Constructs a new
IlvPreorderIterator without initializing it. |
|
IlvPreorderIterator(E root)
Constructs a new
IlvPreorderIterator that starts traversing the
subtree of objects that descends from the specified root . |
Modifier and Type | Method and Description |
---|---|
protected abstract Iterator<E> |
getChildren(E parent)
Returns an iterator over the child nodes of the specified parent object.
|
boolean |
hasNext()
Returns whether the iteration has more elements.
|
protected void |
init(E root)
Initializes the iterator to traverse the subtree of objects that descends from the
specified
root . |
protected void |
initTraversalStack()
Deprecated.
Beginning with Rogue Wave JViews 7.5, override the
init(E) method
instead in order to customize iterator initialization. |
E |
next()
Returns the next element in the iteration.
|
void |
remove()
Removes from the underlying collection the last object returned by the
iterator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public IlvPreorderIterator(E root)
IlvPreorderIterator
that starts traversing the
subtree of objects that descends from the specified root
.root
- The root of the subtree that the iterator will traverse, or
null
to denote an empty tree leading to an empty iterator.protected IlvPreorderIterator()
IlvPreorderIterator
without initializing it.
This constructor is provided as a convenience for subclasses that must perform
specialized initialization. Therefore, if your iterator implementation invokes this
constructor, you must explicitly invoke the init(E)
method.protected void init(E root)
root
. This method is invoked by the constructor and can be
overridden by subclasses to add additional initialization. Overrides of this method
must call super
.root
- The root of the subtree that the iterator will traverse, or
null
to denote an empty tree leading to an empty iterator.@Deprecated protected void initTraversalStack()
init(E)
method
instead in order to customize iterator initialization.protected abstract Iterator<E> getChildren(E parent)
parent
- The parent object.parent
's children.public boolean hasNext()
true
if next()
would return an element
rather than throwing an exception.)public E next()
next
in interface Iterator<E>
NoSuchElementException
- if the iteration has no more elements.public void remove()
next
.
The method is optional and currently throws an unconditional
UnsupportedOperationException
.
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.