001 002 package brs; 003 004 /** 005 * Represents all extrinsic algorithms on a <code>BiTree<code> as a visitor to 006 * the BiTree host structure. The BiTree host will make the appropriate call on 007 * this IVisitor's methods. 008 * Since BiTree is a mutable data structure, we require an exact match for 009 * the data type (BiTree<T>, not BiTree<? extends T>). 010 * @author Dung X. Nguyen - Copyright 2001 - All rights reserved. 011 * @author Mathias Ricken - Copyright 2008 - All rights reserved. 012 */ 013 public abstract interface IVisitor<T,R,P> { 014 /** 015 * Called by the host when the host is empty. 016 * @param host an empty BiTree on which this IVisitor operates. 017 * @param inp the vararg input needed by this IVisitor to perform its task. 018 * @return Object the output of this algorithm on the host. 019 */ 020 public abstract R emptyCase(BiTree<T> host, P... inp); 021 022 /** 023 * Called by the host when the host is not empty. 024 * @param host a non-empty BiTree on which this IVisitor operates. 025 * @param inp the vararg input needed by this IVisitor to perform its task. 026 * @return Object the output of this algorithm on the host. 027 */ 028 public abstract R nonEmptyCase(BiTree<T> host, P... inp); 029 } 030