package listFW.visitor; import listFW.*; /** * Reverses a particular kind of list only * @author Mathias Ricken - Copyright 2008 - All rights reserved. */ public class ReverseList implements IListAlgo, IListFactory> { public IMTList emptyCase(IMTList host, IListFactory ... fac) { return fac[0].makeEmptyList(); } @SuppressWarnings("unchecked") public INEList nonEmptyCase(INEList host, final IListFactory ... fac) { return host.getRest().execute(new IListAlgo, INEList>() { public INEList emptyCase(IMTList h, INEList ... acc) { return acc[0]; } public INEList nonEmptyCase(INEList h, INEList... acc) { return h.getRest().execute(this, fac[0].makeNEList(h.getFirst(), acc[0])); } }, fac[0].makeNEList(host.getFirst(), fac[0].makeEmptyList())); } }