001 package lrs.visitor; 002 003 import lrs.*; 004 import logic.*; 005 006 007 public class LRSOrderedInsert implements IAlgo 008 { 009 public static LRSOrderedInsert Singleton = new LRSOrderedInsert(); 010 011 private LRSOrderedInsert() 012 { 013 } 014 015 public Object emptyCase(LRStruct host, Object... param) 016 { 017 host.insertFront(param[0]); 018 return null; 019 } 020 021 public Object nonEmptyCase(final LRStruct host, final Object... param) 022 { 023 024 BooleanFactory.Singleton.makeBoolean(((Integer) host.getFirst()) > ((Integer) param[0])). 025 execute( new IBooleanAlgo() { 026 public Object trueCase(IBoolean h, Object... inp) { 027 return host.insertFront(param[0]); 028 } 029 public Object falseCase(IBoolean h, Object... inp) { 030 return host.getRest().execute(LRSOrderedInsert.this, param); 031 } 032 }); 033 034 // if (((Integer) host.getFirst()).intValue() > ((Integer) param[0]).intValue()) 035 // { 036 // host.insertFront(param); 037 // } 038 // else 039 // { 040 // host.getRest().execute(this, param); 041 // } 042 return null; 043 } 044 } 045