|
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 | |
---|---|
com.sas.models.SimpleNodeInterface |
getNode()
Returns the current node. |
int |
getNodeIndex()
Returns the zero-based index associated with the current node. |
com.sas.models.SimpleNodeInterface[] |
getNodeParents()
Returns the parents of the current node. |
com.sas.models.TreeInterface |
getTree()
Returns the tree being traversed. |
boolean |
hasMoreNodes()
Tests if nextNode() has another node to return. |
com.sas.models.SimpleNodeInterface |
nextNode()
Returns the current node and advances to the next one. |
void |
reset()
Resets the iterator to the beginning of the tree. |
void |
setNode(com.sas.models.SimpleNodeInterface node)
Sets the current node. |
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()
com.sas.models.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()
com.sas.models.TreeInterface getTree()
com.sas.models.SimpleNodeInterface getNode()
setNode(com.sas.models.SimpleNodeInterface)
,
getNodeIndex()
,
getNodeParents()
void setNode(com.sas.models.SimpleNodeInterface node)
node
- the node to position on.getNode()
com.sas.models.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 |