T - tree node typepublic class Tree<T> extends Object
| Constructor and Description |
|---|
Tree()
create an empty tree
|
Tree(T value) |
Tree(Tree<T> parent,
T value,
List<Tree<T>> childrenlist) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(Tree<T> child) |
long |
depth() |
List<Tree<T>> |
getchildren() |
Set<Tree<T>> |
getLeaves() |
Tree<T> |
getParent() |
T |
getValue() |
long |
level() |
void |
print()
print tree
|
void |
remove()
remove current node and all its children
|
void |
removeChild(Tree<T> child) |
long |
size() |
public Tree(T value)
value - of the new nodepublic Tree()
public void remove()
public T getValue()
public void print()
public long size()
public long depth()
public long level()
Copyright © 2018. All rights reserved.