T
- Type of the value object stored in the node.public class TreeNodeImpl<T> extends Object implements TreeNode<T>
Modifier and Type | Field and Description |
---|---|
List<TreeNode<T>> |
children
The list of child nodes.
|
T |
value
The value of the node.
|
Constructor and Description |
---|
TreeNodeImpl()
Construct an empty node.
|
TreeNodeImpl(T value)
Construct a node holding the given value.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(TreeNode<T> tn)
Add a child node.
|
List<TreeNode<T>> |
getChildren()
Get all children
|
T |
getValue() |
boolean |
isLeaf()
Does this tree node contain no children
|
Iterator<TreeNode<T>> |
iterator() |
void |
removeChild(TreeNode<T> tn)
Remove a child node (if it exists)
|
void |
setValue(T value)
Set the node value
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public TreeNodeImpl()
public TreeNodeImpl(T value)
value
- the value.public void setValue(T value)
TreeNode
public List<TreeNode<T>> getChildren()
TreeNode
getChildren
in interface TreeNode<T>
public void addChild(TreeNode<T> tn)
TreeNode
public void removeChild(TreeNode<T> tn)
TreeNode
removeChild
in interface TreeNode<T>
tn
- the child node to removepublic boolean isLeaf()
TreeNode