package listFW.visitor; import listFW.*; /** * Counts the number of non-negative integers in the host list. * @author DXN */ public class NonNegCount implements IListAlgo { public Object emptyCase(IEmptyList host, Object inp) { return new Integer(0); } public Object nonEmptyCase(INEList host, Object inp) { int f = ((Integer)host.getFirst()).intValue(); Integer rCount = (Integer)host.getRest().execute(this, null); if (0 <= f) { return new Integer(1 + rCount.intValue()); } return rCount; } }