Module hw06

Class AddToAlgo

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

public class AddToAlgo extends Object implements IListAlgo
Returns a copy of the list where the single integer parameter is added to all elements
  • Constructor Details

    • AddToAlgo

      public AddToAlgo()
  • Method Details

    • emptyCase

      public Object emptyCase(MTList host, Object... inp)
      Returns an empty list always
      Specified by:
      emptyCase in interface IListAlgo
      Parameters:
      inp - Not used in the base case
      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... inp)
      Returns a new NEList with the original first added to the given integer parameter, where the rest of the list is the AddToAlgo applied to the rest of the original list.
      Specified by:
      nonEmptyCase in interface IListAlgo
      Parameters:
      inp - inp[0] is the integer value to add to each element.
      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.