riordinato alcuni package e creato una prima implementazione di set e mergetemplate

This commit is contained in:
2014-05-17 21:19:18 +02:00
parent 867a7c1a53
commit 4dab60c3fa
10 changed files with 254 additions and 9 deletions

View File

@@ -0,0 +1,41 @@
package utility.euler_tour;
import tree.binarytree.*;
import position.Position;
public abstract class EulerTour<E, R> {
protected BinaryTree<E> tree;
public abstract R execute(BinaryTree<E> T);
protected void init(BinaryTree<E> T) { tree = T; }
protected R eulerTour(Position<E> v) {
TourResult<R> r = new TourResult<R>();
visitLeft(v, r);
if (tree.hasLeft(v))
r.left = eulerTour(tree.left(v));
visitBelow(v, r);
if (tree.hasRight(v))
r.right = eulerTour(tree.right(v));
visitRight(v, r);
return r.out;
}
protected void visitLeft(Position<E> v, TourResult<R> r) {}
protected void visitBelow(Position<E> v, TourResult<R> r) {}
protected void visitRight(Position<E> v, TourResult<R> r) {}
public class TourResult<R> {
public R left;
public R right;
public R out;
}
}