001 package listFW.visitor;
002
003 import listFW.*;
004
005 /**
006 * Sums a IList<Integer> using a reverse accumulation (natural recursion) algorithm.
007 * @author Mathias Ricken - Copyright 2008 - All rights reserved.
008 */
009 public class SumIntList implements IListAlgo<Integer,Integer, Object> {
010
011 public Integer emptyCase(IMTList<? extends Integer> host, Object ... inp) {
012 return 0;
013 }
014 public Integer nonEmptyCase(INEList<? extends Integer> host, Object ... inp) {
015 return host.getFirst() + host.getRest().execute(this);
016 }
017 }