import edu.neu.ccs.demeterf.*; /** * This class will calculate the total weight of the CSP Formula * */ //public class HeightCalculator extends TUCombiner, Augmentor //{ class Height extends IDba{ int update(NodeInt n, int i){ System.out.println(" height increased " + (i+1)); return i+1; } int combine(NodeInt t, int d, int l, int r){ return Math.max(l,r); } // int combine(EmptyInt l){ return 0; } int combine(Object n, int i){ return i; } int combine(BSTInt n, int i){ return i; } int combine(BSTInt t) { System.out.println("never ========================="); return 0; } static int height (Object o) { return new Traversal(new Height()). traverse(o,0); } } class XYZ extends IDba{ int update(NodeInt n, int i){ return i+1; } int combine(NodeInt t, int d, int l, int r){ return Math.max(l,r); } int combine(Object n, int i){ return i; } int combine(BSTInt n, int i){ return i; } static int xyz (Object o) { return new Traversal(new XYZ()). traverse(o,0); } } class Height2 extends IDb{ int combine(NodeInt t, int d, int l, int r){ int n= Math.max(l,r) + 1; System.out.println(" height increased " + n); return n;} int combine(BSTInt l){ return 0; } int combine(Object n, int i){ return i; } static int height (Object o) { return new Traversal(new Height2()). traverse(o); } } class Incr extends IDf{ int apply(int i){ return i+1; } static BSTInt incr (Object o) { return new Traversal(new Incr()). traverse(o); } } class Sum extends IDb{ int combine(NodeInt t, int d, int l, int r){ return d+r+l; } int combine(BSTInt l){ return 0; } int combine(Object n, int i){ return i; } static int sum (Object o) { return new Traversal(new Sum()). traverse(o); } }