package lrs.visitor;

import lrs.*;

// This visitor appends a value to the end of a list

public class LRSAppend implements IAlgo

{

  public static LRSAppend Singleton = new LRSAppend();



 private LRSAppend()

 {

 }



    public Object emptyCase(LRStruct host, Object... param)

    {

        // The empty node is the end of the list, so insert the new data here.

        host.insertFront(param[0]);

  return(null);

    }



    public Object nonEmptyCase(LRStruct host, Object... param)

    {

        // The non-empty node is not the end of the list, so recurse.

        return host.getRest().execute(this,param);

    }

}

