|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
public interface TreeIteratorInterface
Defines an interface for different tree traversal algorithms, for example preorder traversal, inorder traversal, and postorder traversal.
Each node in the tree is identified by a zero-based integer index, thus the first node, as defined by the traversal algorithm, is assigned index zero and the last node is assigned an index equal to one less than the total number of nodes in the tree.
Nodes can be visited in succession using the standard
enumeration methods
hasMoreElements() and nextElement(), or
by jumping to a specific index via setNodeIndex().
In either case, the current node is always accessible via
getNode().
TreeIterator| Method Summary | |
|---|---|
abstract SimpleNodeInterface |
getNode()
Returns the current node. |
abstract int |
getNodeIndex()
Returns the zero-based index associated with the current node. |
abstract SimpleNodeInterface[] |
getNodeParents()
Returns the parents of the current node. |
abstract TreeInterface |
getTree()
Returns the tree being traversed. |
abstract boolean |
hasMoreNodes()
Tests if nextNode() has another node to return. |
abstract SimpleNodeInterface |
nextNode()
Returns the current node and advances to the next one. |
abstract void |
reset()
Resets the iterator to the beginning of the tree. |
abstract void |
setNode(SimpleNodeInterface node)
Sets the current node. |
abstract void |
setNodeIndex(int newIndex)
Sets the current node via index. |
| Method Detail |
|---|
boolean hasMoreNodes()
nextNode() has another node to return.
Implementation note: hasMoreElements() should be
implemented as a final method that calls this one.
true if there is another node, and
false otherwise.nextNode()SimpleNodeInterface nextNode()
java.util.NoSuchElementException if there isn't
a current node;
to avoid check hasMoreNodes() before calling this.
Implementation note: nextNode() should be
implemented as a final method that calls this one.
SimpleNodeInterface instance; will never be
null.hasMoreNodes()void reset()
TreeInterface getTree()
SimpleNodeInterface getNode()
setNode(com.sas.models.SimpleNodeInterface),
getNodeIndex(),
getNodeParents()void setNode(SimpleNodeInterface node)
node - the node to position on.getNode()SimpleNodeInterface[] getNodeParents()
getNode()int getNodeIndex()
getNode(),
setNodeIndex(int)void setNodeIndex(int newIndex)
newIndex - the zero-based index of the node to position on.getNodeIndex()
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||