Boy_Scouts_Scheduler.GreedyAlgorithm.GreedyScheduler.convertTimeSlotsToDaySlots C# (CSharp) Method

convertTimeSlotsToDaySlots() private static method

private static convertTimeSlotsToDaySlots ( IEnumerable T ) : void
T IEnumerable
return void
        private static void convertTimeSlotsToDaySlots(IEnumerable<Models.TimeSlot> T)
        {
            List<Availability> A = new List<Availability>();
            int i, j;

            int minDay = 1 << 30;
            Dictionary<int, bool> lunch = new Dictionary<int,bool>();

            foreach (Models.TimeSlot t in T)
            {
                int dayNumber = (int)t.Start.DayOfWeek;

                minDay = Math.Min(minDay, dayNumber);

                for (i = 0; i < A.Count; i++)
                {
                    if (A[i].DayNumber == dayNumber)
                    {
                        A[i].Slots.Add(t.ID);
                        break;
                    }
                }

                if (i == A.Count)
                    A.Add(new Availability(dayNumber, new List<int>(new int[] { t.ID })));

                if (t.isGeneral)
                    lunch.Add(t.ID, true);
            }

            for (i = 0; i < A.Count; i++)
            {
                nSlots[ A[i].DayNumber ] = A[i].Slots.Count;

                for (j = 0; j < A[i].Slots.Count; j++)
                {
                    int D = A[i].DayNumber - minDay + 1;
                    int S = j + 1;
                    timeSlotsDaySlotsPairs[A[i].Slots[j]] = new KeyValuePair<int, int>(D,S);
                    daySlotsTimeSlotsPairs[D, S] = A[i].Slots[j];

                    if (lunch.ContainsKey(A[i].Slots[j]))
                        lunchSlot[D] = S;
                }
            }

            for (i = 0; i < MAXD; i++)
                totalTimeSlots += nSlots[i];
        }