|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.filespace.LookAheadEnum
javafe.filespace.TreeWalker
This class provides a way to enumerate all the nodes of a given Tree in depth-first pre-order using lexical ordering on siblings. I.e., X preceeds X.A, which in turn preceeds X.B. The first node in the list will be the root note of the Tree. It also allows enumerating a Tree's direct children in sorted order (based on their labels).
Guarantee: Returned elements are always non-null Trees.
Field Summary | |
protected java.util.Enumeration |
remainingChildren
The remaining children we have yet to start processing: |
protected java.util.Enumeration |
remainingNodes
The remaining nodes from the child we are currently processing: |
Constructor Summary | |
TreeWalker(Tree T)
From a Tree create an enumeration that enumerates all of the Tree's nodes (including the root node first). |
Method Summary | |
protected java.lang.Object |
calcNextElement()
* Calculating the next element: * * |
private static Tree[] |
getSortedChildren(Tree T)
Return a sorted list of a Tree's direct children: |
boolean |
hasMoreElements()
|
static void |
main(java.lang.String[] args)
A simple test driver. |
java.lang.Object |
nextElement()
|
private static void |
sort(Tree[] a)
|
static java.util.Enumeration |
sortedChildren(Tree T)
Enumerate a Tree's direct children in sorted order (of labels). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Enumeration remainingChildren
protected java.util.Enumeration remainingNodes
Constructor Detail |
public TreeWalker(Tree T)
Method Detail |
protected java.lang.Object calcNextElement()
calcNextElement
in class LookAheadEnum
public static java.util.Enumeration sortedChildren(Tree T)
Guarantee: The resulting enumeration never yields null as an element.
private static Tree[] getSortedChildren(Tree T)
private static void sort(Tree[] a)
public static void main(java.lang.String[] args)
public final boolean hasMoreElements()
hasMoreElements
in interface java.util.Enumeration
public final java.lang.Object nextElement()
nextElement
in interface java.util.Enumeration
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |