implementazione di linked tree. manca il tostring
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package tree;
|
||||
|
||||
import position.NodePositionList;
|
||||
import position.Position;
|
||||
import position.PositionList;
|
||||
|
||||
@@ -13,13 +14,15 @@ public class TreeNode<E> implements TreePosition<E> {
|
||||
|
||||
private E element = null;
|
||||
private TreePosition<E> parent = null;
|
||||
private PositionList<Position<E>> children= null;
|
||||
private PositionList<Position<E>> children= new NodePositionList<Position<E>>();
|
||||
|
||||
|
||||
public TreeNode(E in_element, TreePosition<E> in_parent, PositionList<Position<E>> in_children ){
|
||||
element = in_element;
|
||||
parent = in_parent;
|
||||
children = in_children;
|
||||
if (in_children != null){
|
||||
children = in_children;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +38,9 @@ public class TreeNode<E> implements TreePosition<E> {
|
||||
|
||||
@Override
|
||||
public void setChildren(PositionList<Position<E>> c) {
|
||||
children = c;
|
||||
if (c != null){
|
||||
children = c;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user