private bool IsBlocked(FeatureStruct realizationalFS, FeatureStruct syntacticFS, HashSet <Tuple <FeatureStruct, FeatureStruct> > visited) { Tuple <FeatureStruct, FeatureStruct> pair = Tuple.Create(realizationalFS, syntacticFS); if (visited.Contains(pair)) { return(true); } visited.Add(pair); foreach (Feature f in realizationalFS.Features) { if (!syntacticFS.ContainsFeature(f)) { return(false); } var cf = f as ComplexFeature; if (cf != null) { FeatureStruct realFS = realizationalFS.GetValue(cf); FeatureStruct synFS = syntacticFS.GetValue(cf); if (!IsBlocked(realFS, synFS, visited)) { return(false); } } } return(true); }
private bool ContainsFeature(FeatureStruct fs, Feature feature, ISet <FeatureStruct> visited) { if (visited.Contains(fs)) { return(false); } if (fs.ContainsFeature(feature)) { return(true); } if (fs.Features.OfType <ComplexFeature>().Any(cf => ContainsFeature(fs.GetValue(cf), feature, visited))) { return(true); } return(false); }
private bool ContainsFeature(FeatureStruct fs, Feature feature, ISet<FeatureStruct> visited) { if (visited.Contains(fs)) return false; if (fs.ContainsFeature(feature)) return true; if (fs.Features.OfType<ComplexFeature>().Any(cf => ContainsFeature(fs.GetValue(cf), feature, visited))) return true; return false; }