public class TreeNode<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
addChild(T data)
Add data as a new child TreeNode to this node.
|
void |
addChild(TreeNode<T> child)
Add a TreeNode as a new child TreeNode
to this node.
|
ListADT<TreeNode<T>> |
getChildren()
Return the list of children.
|
T |
getData()
Return the data value associated with
this node.
|
boolean |
isLeaf()
Return true if this node is a leaf node (has no children)
|
void |
setData(T data)
Change the data associated with this node.
|
public TreeNode(T d)
public ListADT<TreeNode<T>> getChildren()
public void addChild(T data)
data
- the data for the new TreeNodepublic void addChild(TreeNode<T> child)
child
- a TreeNode with child datapublic T getData()
public void setData(T data)
data
- the new data item for this node.public boolean isLeaf()