package LRSVisitor;

import LRStructure.*;

public class LRSOrderedInsert implements IAlgo
{
	/** @SBGen Singleton Variable   */
	private static LRSOrderedInsert singleton = null;	/** @SBGen Singleton   */
	public static LRSOrderedInsert Singleton()
	{
		// SBgen: Ensure single instance
		if (singleton == null) 
			singleton = new LRSOrderedInsert();
		return(singleton);
		// SBgen: End singleton
	}
	/** @SBGen Constructor   */
	private LRSOrderedInsert()
	{
	}

	public Object nullCase(LRStruct host, Object param)
	{
		host.insertAsFirst(param);
    return null;
	}

	public Object nonNullCase(LRStruct host, Object param)
	{
	
		if (((Integer) host.getFirst()).intValue() > ((Integer) param).intValue()) 
		{	
			host.insertAsFirst(param);
		}
		else
		{
			host.getRest().execute(this, param);
		}
    return null;
	}
}

