N
- type of elementspublic class MutableTree<N> extends Object implements Tree<N>
Constructor and Description |
---|
MutableTree(N userObject) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(MutableTree<N> child) |
void |
addChild(MutableTree<N> child,
Object edge) |
void |
clearChildren()
remove all children.
|
void |
dump(PrintWriter writer)
Dump.
|
void |
dump(PrintWriter writer,
int indent)
Dump.
|
List<N> |
fillDepthFirst()
Fill depth first.
|
int |
getChildCount()
A convenience method that gets the number of child nodes that this node
has.
|
List<Tree<N>> |
getChildren()
Gets the children of this tree node.
|
Object |
getEdge(Tree<N> child) |
int |
getMaxDepth() |
Tree<N> |
getParent()
Gets the parent of this tree node.
|
List<Tree<N>> |
getPathToRoot()
Gets the path to root.
|
Tree<N> |
getRoot()
A convenience method that gets the root of this tree.
|
int |
getSize() |
N |
getUserObject()
Gets the "content" of this tree node.
|
Set<N> |
getUserObjectClosure()
Gets the user object closure.
|
List<N> |
getUserObjectPathToRoot()
Gets the user object path to root.
|
boolean |
isLeaf()
A convenience method that determines if this node is a leaf node (because
it has no children).
|
boolean |
isRoot()
A convenience method that determines if this is a root node (because it
has no parent node).
|
void |
removeChild(MutableTree<N> child) |
void |
replace(MutableTree<N> tree) |
void |
setNodeRenderer(NodeRenderer<N> renderer)
Sets the node renderer.
|
void |
setParent(MutableTree<N> parent) |
void |
sortChildren(Comparator<Tree<N>> comparator)
Sorts the children using the specified comparator.
|
String |
toString() |
public MutableTree(N userObject)
userObject
- the user objectpublic N getUserObject()
Tree
getUserObject
in interface Tree<N>
public void setParent(MutableTree<N> parent)
parent
- the new parentpublic void addChild(MutableTree<N> child)
child
- child to addpublic void addChild(MutableTree<N> child, Object edge)
child
- child to addedge
- the edgepublic void removeChild(MutableTree<N> child)
child
- child to removepublic void sortChildren(Comparator<Tree<N>> comparator)
Tree
sortChildren
in interface Tree<N>
comparator
- The comparator to be used for the sorting.public void clearChildren()
public Tree<N> getParent()
Tree
public List<Tree<N>> getChildren()
Tree
getChildren
in interface Tree<N>
public int getChildCount()
Tree
getChildCount
in interface Tree<N>
public boolean isRoot()
Tree
public boolean isLeaf()
Tree
public Tree<N> getRoot()
Tree
public List<Tree<N>> getPathToRoot()
Tree
getPathToRoot
in interface Tree<N>
public List<N> getUserObjectPathToRoot()
Tree
getUserObjectPathToRoot
in interface Tree<N>
public Set<N> getUserObjectClosure()
Tree
getUserObjectClosure
in interface Tree<N>
public void dump(PrintWriter writer)
Tree
public void dump(PrintWriter writer, int indent)
Tree
public void setNodeRenderer(NodeRenderer<N> renderer)
Tree
setNodeRenderer
in interface Tree<N>
renderer
- the renderer to usepublic List<N> fillDepthFirst()
Tree
fillDepthFirst
in interface Tree<N>
public void replace(MutableTree<N> tree)
tree
- the node to put in place of this onepublic int getSize()
public int getMaxDepth()
Copyright © 2020 The University of Manchester. All rights reserved.