package listFW.visitor; import listFW.*; public class Invert implements IListAlgo { private IListFactory _fact; public Invert(IListFactory f) { _fact = f; } public Object emptyCase(IEmptyList host, Object nu) { return host; } public Object nonEmptyCase(INEList host, Object nu) { IList accRev = _fact.makeNEList(host.getFirst(), _fact.makeEmptyList()); return host.getRest ().execute(new IListAlgo() { public Object emptyCase(IEmptyList h, Object acc) { // TO DO return acc; } public Object nonEmptyCase(INEList h, Object acc) { //TO DO return h.getRest().execute (this, _fact.makeNEList(h.getFirst(), (IList)acc)); } } // end of anonymous local inner class , accRev); // accumulated reverse passed to the helper as input. } }