listFW.visitor
Class InsertInOrderWithFactory

java.lang.Object
  extended by listFW.visitor.InsertInOrderWithFactory
All Implemented Interfaces:
IListAlgo

public class InsertInOrderWithFactory
extends Object
implements IListAlgo

Inserts an Integer into an ordered host list, assuming the host list contains only Integer objects. Has no knowledge of how IList is implemented. Must make use of a list factory (IListFactory) to create IList objects instead of calling the constructors of concrete subclasses directly.


Constructor Summary
InsertInOrderWithFactory(IListFactory lf)
           
 
Method Summary
 Object emptyCase(IMTList host, Object inp)
          Simply makes a new non-empty list with the given inp parameter as first.
 Object nonEmptyCase(INEList host, Object inp)
          Recur!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InsertInOrderWithFactory

public InsertInOrderWithFactory(IListFactory lf)
Method Detail

emptyCase

public Object emptyCase(IMTList host,
                        Object inp)
Simply makes a new non-empty list with the given inp parameter as first.

Specified by:
emptyCase in interface IListAlgo
Parameters:
host - an empty IList.
inp - an Integer to be inserted in order into host.
Returns:
result from calling this method. The type of the result is problem-specific and may be null.

nonEmptyCase

public Object nonEmptyCase(INEList host,
                           Object inp)
Recur!

Specified by:
nonEmptyCase in interface IListAlgo
Parameters:
host - a non-empty IList.
inp - an Integer to be inserted in order into host.
Returns:
result from calling this method. The type of the result is problem-specific and may be null.