|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
V
- type of values in tree nodespublic interface Tree<V>
Tree
is a value with an ordered collection of subtrees of the same type as the main tree.
Nested Class Summary | |
---|---|
static interface |
Tree.ExceptionThrowingTreeVisitor<V,E extends java.lang.Exception>
An ExceptionThrowingTreeVisitor is used to visit a tree when the Tree.ExceptionThrowingTreeVisitor.visit(Tree) implementation
needs to be able to throw a checked Exception . |
static interface |
Tree.TreeVisitor<V>
Tree.TreeVisitor is an interface used to visit a tree and, at the option of the visitor, its children and so
on recursively. |
Method Summary | ||
---|---|---|
Tree<V> |
addChild(Tree<V> child)
Adds a new child tree to this node's children. |
|
java.util.List<Tree<V>> |
getChildren()
Returns a list of this tree's children (not copies of the children). |
|
Tree<V> |
getParent()
Returns this tree's parent. |
|
V |
getValue()
Returns the tree's value. |
|
boolean |
removeChild(Tree<V> child)
Removes the first occurrence of the given child tree from this node's children. |
|
int |
size()
Returns the number of nodes in the tree. |
|
|
visit(Tree.ExceptionThrowingTreeVisitor<V,E> visitor)
Traverse this Tree in preorder (see below) and call the visit method of the given
Tree.ExceptionThrowingTreeVisitor at each node. |
|
void |
visit(Tree.TreeVisitor<V> visitor)
Traverse this Tree in preorder (see below) and call the visit method of the given Tree.TreeVisitor at
each node. |
Method Detail |
---|
V getValue()
null
.
null
java.util.List<Tree<V>> getChildren()
null
.
Tree<V> addChild(Tree<V> child)
child
- the child tree to add
boolean removeChild(Tree<V> child)
true
if the
child was found and removed, otherwise false
.
child
- the child tree to remove
true
if the child tree was removed successfully, otherwise false
.List.remove(java.lang.Object)
Tree<V> getParent()
null
.
void visit(Tree.TreeVisitor<V> visitor)
Tree
in preorder (see below) and call the visit method of the given Tree.TreeVisitor
at
each node. The visitor determines whether the children of each visited tree should also be visited.
Preorder traversal visits the tree and then visits, in preorder, each child of the tree.
visitor
- a Tree.TreeVisitor
<E extends java.lang.Exception> void visit(Tree.ExceptionThrowingTreeVisitor<V,E> visitor) throws E extends java.lang.Exception
Tree
in preorder (see below) and call the visit method of the given
Tree.ExceptionThrowingTreeVisitor
at each node. The visitor determines whether the children of each visited
tree should also be visited.
Preorder traversal visits the tree and then visits, in preorder, each child of the tree.
E
- type of exception possibly thrownvisitor
- the tree's visitor
E
- if an error occurs when visiting the tree
E extends java.lang.Exception
int size()
null
nodes in the tree
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |