D
- the type of the trees data elementspublic class Tree<D> extends Object implements Serializable
Constructor and Description |
---|
Tree()
Construct an empty Tree.
|
Tree(D data)
Construct a Tree with a single data element
|
Tree(D data,
List<Tree<D>> children)
Construct a Tree with a data element and a list of children.
|
Modifier and Type | Method and Description |
---|---|
void |
add(D childData)
Add a new tree with the data element as (last) child of the tree.
|
void |
addTree(Tree<D> child)
Add a tree as last child of the tree.
|
List<Tree<D>> |
getChildren()
Get the trees children
|
D |
getData()
Get the data element of the tree.
|
boolean |
hasChildren()
Determine if a tree has children.
|
void |
removeChildren()
Prune a tree.
|
void |
setChildren(List<Tree<D>> children)
Set the trees children.
|
void |
setData(D data)
Set the trees data element.
|
String |
toString() |
public Tree()
public Tree(D data)
data
- the datapublic List<Tree<D>> getChildren()
public boolean hasChildren()
public void setChildren(List<Tree<D>> children)
children
- the new children of the tree.public void addTree(Tree<D> child)
child
- the new last child of the tree.public void add(D childData)
childData
- the data of the new last child of the tree.public void removeChildren()
public D getData()
public void setData(D data)
data
- the new data element of the tree.@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.