public void Start(StartDelegate dlg) { foreach (KeyValuePair <string, ArrayList> entry in dic) { foreach (TimeElement i in entry.Value) { if (!tt.CheckOverlap(i)) { tt.Add(i); } dlg(tt); tt.Del(i); } } }
private void bStart_Click(object sender, EventArgs e) { // 웹 강의 삭제 List <ListViewItem> lvil = new List <ListViewItem>(getLviArray()); for (int i = 0; i < lvil.Count;) { if (TimeParser.Get(lvil[i].SubItems[8].Text).te.Count == 0) { DelInIndex(lvil[i].SubItems[0].Text); lvil.RemoveAt(i); } else { i++; } } result.Clear(); AccessTable = new TimeTable(); stack.Clear(); if (subject_group.Count > 1) { subject_group.Sort((v1, v2) => v2.Count.CompareTo(v1.Count)); for (int i = 0; i < subject_group[0].Count; i++) { stack.Push(subject_group[0][i].index); AccessTable.Add(subject_group[0][i]); Iterate(1); stack.Pop(); AccessTable.Del(subject_group[0][i]); if (escape) { break; } } } result = result.OrderBy(a => Guid.NewGuid()).ToList(); if (result.Count > maxShowCount) { result.RemoveRange(maxShowCount, result.Count - maxShowCount); } StringBuilder builder = new StringBuilder(); foreach (string r in result) { builder.Append(r + '\n'); } System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"combinations.txt", builder.ToString()); escape = false; Program.m.ActivateTTListButton(); MessageBox.Show("생성완료!\n생성횟수: " + result.Count, Version.Name, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void Iterate(int iter) { if (escape) { return; } if (subject_group.Count == iter) { StringBuilder builder = new StringBuilder(); foreach (string s in stack) { builder.Append(s + '|'); } result.Add(builder.ToString()); if (result.Count >= maxPannelCount) { escape = true; } return; } for (int i = 0; i < subject_group[iter].Count; i++) { if (AccessTable.CheckOverlap(subject_group[iter][i])) { continue; } stack.Push(subject_group[iter][i].index); AccessTable.Add(subject_group[iter][i]); Iterate(iter + 1); stack.Pop(); AccessTable.Del(subject_group[iter][i]); if (escape) { return; } } }