private static List <CASE> GetResults(CAR car1) { List <CASE> l_case = new List <CASE>(); var xcase = new CASE(); xcase.Add(car1); l_case.Add(xcase); if (car1.NextCARs != null) { if (true) //cover all { foreach (var car in car1.NextCARs) { if (!xcase.Exists(car)) { xcase.Add(car); } else { xcase = new CASE(); l_case.Add(xcase); xcase.Add(car1); xcase.Add(car); } } } } return(l_case); }
public object Clone() { var new_case = new CASE(); new_case.CARS = this.CARS.ToList(); new_case.IsEnd = this.IsEnd; new_case.ID = Guid.NewGuid(); return(new_case); }
public bool BuildNext() { //get end cars if (this.LCASE.Count == 0) { var xcase = new CASE(); this.LCASE.Add(new CASE(this.StartCAR)); this.Degree = 1; return(true); } var cases = this.LCASE.FindAll(t => !t.IsEnd && t.EndCAR.NextCARs.Count > 0).ToList(); if (cases.Count == 0) { cases.Clear(); return(false); } foreach (var xcase in cases) { var xcase_clone = xcase.Clone() as CASE; var endCase = xcase.EndCAR; for (var i = 0; i < endCase.NextCARs.Count; i++) { var crn = endCase.NextCARs[i]; if (i == 0) { var xcase0 = this.LCASE.Find(t => t.ID == xcase.ID); xcase0.Add(crn); } else { var xcase_clone1 = xcase_clone.Clone() as CASE; xcase_clone1.Add(crn); this.LCASE.Add(xcase_clone1); } } xcase_clone.CARS.Clear(); } this.Degree++; cases.Clear(); return(true); }