/* * Member Methods */ public override Dependency Simplify() { if (IsEmpty()) { return(null); } AND newF = new AND(); IEnumerator e = GetDependencies(); while (e.MoveNext()) { Dependency d = ((Dependency)e.Current).Simplify(); if (d is FalseDependency) { return((Dependency)e.Current); } else if (d.IsFormula()) { Formula df = (Formula)d; if (d is AND) { // collapse nested AND formulas into each other IEnumerator e2 = df.GetDependencies(); while (e2.MoveNext()) { newF.AddDependency((Dependency)e2.Current); } } else if (d != null) { newF.AddDependency(d); } } else if (!(d is TrueDependency)) { // remove TrueDependencies from within an AND newF.AddDependency((Dependency)e.Current); } } if (newF.Count == 1) { return(newF[0]); } else if (newF.Count == 0) { return(null); } else { return(newF); } }
public override Dependency GetOppositeDependencies() { AND newF = new AND(); IEnumerator e = GetDependencies(); while (e.MoveNext()) { newF.AddDependency(((Dependency)e.Current).GetOppositeDependencies()); } return(newF); }