package lrs.visitor;



import lrs.*;

import logic.*;





public class LRSOrderedInsert implements IAlgo

{

 public static LRSOrderedInsert Singleton = new LRSOrderedInsert();



 private LRSOrderedInsert()

 {

 }



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

 {

  host.insertFront(param[0]);

    return null;

 }



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

 {

 

   BooleanFactory.Singleton.makeBoolean(((Integer) host.getFirst()) > ((Integer) param[0])).

     execute( new IBooleanAlgo() {

     public Object trueCase(IBoolean h, Object... inp) {

       return host.insertFront(param[0]);

     }

     public Object falseCase(IBoolean h, Object... inp) {

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

     }

   });

   

//  if (((Integer) host.getFirst()).intValue() > ((Integer) param[0]).intValue()) 

//  { 

//   host.insertFront(param);

//  }

//  else

//  {

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

//  }

    return null;

 }

}



