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 object@Nullable public N getUserObject()
TreegetUserObject in interface Tree<N>public 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)
TreesortChildren in interface Tree<N>comparator - The comparator to be used for the sorting.public void clearChildren()
@Nullable public Tree<N> getParent()
Treepublic void setParent(MutableTree<N> parent)
parent - the new parentpublic List<Tree<N>> getChildren()
TreegetChildren in interface Tree<N>public int getChildCount()
TreegetChildCount in interface Tree<N>public boolean isRoot()
Treepublic boolean isLeaf()
Treepublic Tree<N> getRoot()
Treepublic List<Tree<N>> getPathToRoot()
TreegetPathToRoot in interface Tree<N>public List<N> getUserObjectPathToRoot()
TreegetUserObjectPathToRoot in interface Tree<N>public Set<N> getUserObjectClosure()
TreegetUserObjectClosure in interface Tree<N>public void dump(PrintWriter writer)
Treepublic void dump(PrintWriter writer, int indent)
Treepublic void setNodeRenderer(NodeRenderer<N> renderer)
TreesetNodeRenderer in interface Tree<N>renderer - the renderer to usepublic List<N> fillDepthFirst()
TreefillDepthFirst 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.