import java.util.*;

public abstract class Modal 
{
	public Table execute(Table tab)
	{
		ArrayList newRowSet = new ArrayList();

		while(tab.getNoRowSet()!=0) /* go through all rows */
		{
			Row r = (Row) tab.removeRow(0); /* get next row */

			int st = r.getRow_st();
			int et = r.getRow_et();
			
			boolean keepRow = includeRow(st, et);
			
			if (keepRow)
			{
				st=setStartTime(st);
				et=setEndTime(et);

				r.putRow_time(st, et);
				newRowSet.add(r); /* add the row with the new (changed) time values */
			}
			
		}

		tab.setRowSet(newRowSet);

		boolean coalFlag=UserInterface.getCoal();
		if ( coalFlag )
		{
			AuxFuncs.coalesce(tab);
		}

		return tab;
	}

	abstract int setStartTime(int st);

	abstract int setEndTime(int et);

	abstract boolean includeRow(int st, int et);
}