// File: Visitor.java
// A Visitor visits the root of a (sub)tree.
// Copyright (C) 2006, 2008 Gregory D. Weber

/** A Visitor<E> visits the nodes of a BinaryTree<E>,
    and may have result type R. 
    If there is no result, you can use Void for R. */

public class Visitor<E,R> {

    // The result field can be used as an accumulator
    // in subclasses of Visitor
    protected R result;

    public Visitor () { 
	result = null;
    }

    public void visit (E item) { System.out.print(item + " "); }

    public R getResult () {
	return result;
    }

}
