package tvark.beans;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import tvark.model.Lesson;

public class ScheduleBean {
	
	private Map<List<Lesson>[][], List<Integer>> mLessonNumbers = new HashMap<List<Lesson>[][], List<Integer>>() {
		/**
		 * 
		 */
		private static final long serialVersionUID = -898754757079318663L;

		@Override
		public List<Integer> get(Object pKey) {
			List<?>[][] schedule = (List<?>[][]) pKey;
			int minLesson = Integer.MAX_VALUE;
			int maxLesson = Integer.MIN_VALUE;
			
			for (int i = 0; i < schedule.length; ++i) {
				for (int j = 0; j < schedule[i].length; ++j) {
					if (schedule[i][j] != null && !((List<?>) schedule[i][j]).isEmpty()) {
						minLesson = Math.min(minLesson, j);
						maxLesson = Math.max(maxLesson, j);
					}										
				}
			}
			List<Integer> result = new ArrayList<Integer>(); 
			for (int i = minLesson; i <= maxLesson; ++i) {
				result.add(i);
			}
			return result;
		}
		
	};
	
	public Map<List<Lesson>[][], List<Integer>> getLessonNumbers() {
		return mLessonNumbers;
	}

}
