Module hw06

Class CopyAlgo

java.lang.Object
provided.listFW.visitors.CopyAlgo
All Implemented Interfaces:
IListAlgo

public class CopyAlgo extends Object implements IListAlgo
Returns a copy of the list
  • Constructor Details

    • CopyAlgo

      public CopyAlgo()
  • Method Details

    • emptyCase

      public Object emptyCase(MTList host, Object... nu)
      Returns an MTList always.
      Specified by:
      emptyCase in interface IListAlgo
      Parameters:
      nu - Not used
      host - the MTList that is executing this algorithm.
      Returns:
      result from calling this method. The type of the result is problem-specific and may be null.
    • nonEmptyCase

      public Object nonEmptyCase(NEList host, Object... nu)
      Returns a new NEList where first is the original first and rest is a copy of the original rest.
      Specified by:
      nonEmptyCase in interface IListAlgo
      Parameters:
      nu - Not used
      host - the NEList that is executing this algorithm
      Returns:
      result from calling this method. The type of the result is problem-specific and may be null.