package lrs.visitor; import lrs.*; /** * Sorts a list using the insertion sort technique. * The sorted list is returned. * @author SW */ public class InsertionSortLRS implements IAlgo { public static final InsertionSortLRS Singleton = new InsertionSortLRS(); private InsertionSortLRS() { } public Object emptyCase(LRStruct host, Object... nu) { return host; } public Object nonEmptyCase(LRStruct host, Object... nu) { host.getRest().execute(this); host.execute(InsertInOrderLRS.Singleton, host.removeFront()); return host; } }