final class TreeTopDownEnumerator extends Object implements Enumeration<TreeNode>
Modifier and Type | Field and Description |
---|---|
private ListIterator<TreeNode> |
iterator
an iterator of the above list
|
private ArrayList<TreeNode> |
list
List of nodes in preorder
|
Constructor and Description |
---|
TreeTopDownEnumerator(TreeNode root)
constructor: it creates the list of nodes
|
Modifier and Type | Method and Description |
---|---|
private void |
DFS(TreeNode node)
A preorder depth first traversal, adding nodes to the list
|
boolean |
hasMoreElements()
any elements left?
|
TreeNode |
nextElement()
returns the next element in the list iterator
|
private final ListIterator<TreeNode> iterator
TreeTopDownEnumerator(TreeNode root)
root
- Root of the tree to traversepublic boolean hasMoreElements()
hasMoreElements
in interface Enumeration<TreeNode>
public TreeNode nextElement()
nextElement
in interface Enumeration<TreeNode>