oracle.ide.util
Interface TreeIterator
- All Superinterfaces:
- java.util.Iterator
- All Known Implementing Classes:
- TreeIteratorABDC, TreeIteratorDBCA, TreeIteratorLeaves, TreeIteratorACBD
- public interface TreeIterator
- extends java.util.Iterator
This interface specifies the TreeIterator.
The implementation names for this interface have the name TreeIteratorXXXX
where the XXXX letters represent the order of the returned nodes and each
X is A, B, C or D.
If you consider a tree with the form, and the returned order is
A, B, C and D, the iterator will be called TreeIteratorABCD.
A
/ \
B C
/
D
Example:
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
DefaultMutableTreeNode d = new DefaultMutableTreeNode("D");
a.add(b);
a.add(c);
b.add(d);
TreeIterator i = new TreeIteratorABDC(a);
while(i.hasNext())
System.err.println(i.nextNode());
The output will be
A
B
D
C
Note: Not all the possible TreeIterators are implemented yet. If
you need one, ...
Method Summary |
boolean |
hasNext()
|
java.lang.Object |
next()
|
javax.swing.tree.TreeNode |
nextNode()
same as next but returns the TreeNode |
void |
remove()
|
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator
nextNode
public javax.swing.tree.TreeNode nextNode()
- same as next but returns the TreeNode