package listFW.visitor; import listFW.*; import listFW.factory.*; import listFW.visitor.*; /** * Returns the even-indexed elements of the host. * @author DXN */ public class EvenIndexed implements IListAlgo { private IListFactory _fact; public EvenIndexed(IListFactory f) { _fact = f; } public Object emptyCase(IEmptyList host, Object nu) { return host; } /** */ public Object nonEmptyCase(INEList host, Object input) { IList evenRest = (IList)host.getRest().execute(new OddIndexed(_fact), null); return _fact.makeNEList(host.getFirst(), evenRest); } }