package lrs.visitor; import lrs.*; public class MergeSortHelper implements IAlgo { public static final MergeSortHelper Singleton = new MergeSortHelper (); private MergeSortHelper() { } /** * @param host * @param input LRStruct parent of host * @return null */ public Object nullCase(LRStruct host, Object input) { return null; // there is nothing to sort } /** * @param host * @param input LRStruct parent of host * @return null. */ public Object nonNullCase(LRStruct host, Object input) { LRStruct hostParent = (LRStruct)input; LRStruct sublist = (LRStruct)hostParent.execute (EveryOther.Singleton, null); hostParent.execute (MergeSorter.Singleton, null); sublist.execute (MergeSorter.Singleton, null); hostParent.execute (Merger.Singleton, sublist); return null; } }