|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfc.util.Tree
public class Tree
Implements a simple Tree data structure. The tree is made up of nodes. Each node has an associated object holding the data for that node and has zero (0) or arbitrary more children.
Depending on the application, leaf data can be collectively stored as part of the data for a node or spread out among child (leaf) nodes. For example, if the tree represents a directory structure, files (leaf data) for a directory can be stored as part of that directory's node itself or as part of additional child nodes under that directory node (1 file per child node). Such additional child nodes should be used for leaf data if there is some chance/need of converting those leaf nodes to non-leaf nodes in the future.
This class provides operations common to all trees. Tree based data structures can be built on top of this class.
Nested Class Summary | |
---|---|
static class |
Tree.IterationOrder
|
static class |
Tree.Node
|
Constructor Summary | |
---|---|
Tree()
Constructs a new tree |
|
Tree(java.lang.String name)
Constructs a new tree with the specified name |
Method Summary | |
---|---|
Tree.Node |
createRootNode(java.lang.Object data)
Creates and returns the root node for this tree. |
Tree.Node |
getRootNode()
Returns the root node of this tree. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Tree()
public Tree(java.lang.String name)
name
- the name of this treeMethod Detail |
---|
public Tree.Node createRootNode(java.lang.Object data)
data
- the data object associated with this nodepublic Tree.Node getRootNode()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |