/// <summary> /// Schedules the unscheduled talks. /// </summary> /// <param name="unscheduledTalks">The unscheduled talks.</param> public bool ScheduleTalks(List<ITalk> unscheduledTalks) { while (RemainingDuration > 0) { if (unscheduledTalks.Count == 0) break; /* To handle the case when talks remain after utilizing the buffers. Just send * in the unscheduled talks total time if it is less than remaining duration.*/ int remainingUnscheduledTime = unscheduledTalks.Sum(talk => talk.Duration); int remainingDuration = Math.Min(remainingUnscheduledTime, RemainingDuration); var scheduledTalks = TalkScheduler.Instance.ScheduleTalks(unscheduledTalks, remainingDuration); if (scheduledTalks == null) return false;//Condition met when there is no subsets with exact sum. AddTalks(scheduledTalks, unscheduledTalks); } return true; }