package list.dl.algo; import list.dl.DLList; /** * Counts the number of elements to the left the host. */ public class LeftCount implements IAlgoLeft { final public static LeftCount Singleton = new LeftCount(); private LeftCount() { } /** * @param hostList * @param inputParam * @return */ public Object leftEndCase(DLList hostList, Object inputParam) { return new Integer (0); } /** * @param hostList * @param inputParam * @return */ public Object dataNodeCase(DLList hostList, Object inputParam) { Integer restCount = (Integer) hostList.getLeftRest ().executeLeft (this, null); return new Integer (1 + restCount.intValue ()); } }