/// <summary> /// Конструктор для класса, генерирующий /// Def и Use множества по базовому блоку /// </summary> /// <param name="block">Базовый блок</param> public DUSets(BasicBlock block) { this.Block = block; DSet = new DSet(); USet = new USet(); BuildDUSets(); }
public int GetAttributeRedundancy(SCPAttribute attribute) { if (USet == null) { return(0); } return(USet.Where(u => u == attribute.Tag).Count()); }
public void RemoveSet(SCPSet set) { set.Attributes.ForEach(a => { int frequency = USet.Count(i => i == a.Tag); if (frequency - 1 == 0) { a.Visit = false; } }); if (set.Attributes.Where(a => a.Visit == false).Count() > 0) { CriticalList.Add(set); } Sets.Remove(Sets.Find(s => s.Tag.ToString() == set.Tag.ToString())); }
public bool IsSubset(SCPSet set) { if (USet == null) { return(false); } HashSet <int> universal = new HashSet <int>(); USet.ForEach(u => universal.Add(u)); HashSet <int> subset = new HashSet <int>(); set.Attributes.ForEach(a => subset.Add(a.Tag)); bool r = subset.IsSubsetOf(universal); return(r); }
public void ComputeAttributeRedundancyPrice() { Sets.ForEach(set => { set.Attributes.ForEach(a => { if (USet.Exists(u => u == a.Tag)) { a.Cost = 0; USet.Where(u => u == a.Tag).ToList().ForEach(i => { double price = 0; SCPSet ts = Sets.Find(s => s.Tag == i); if (ts != null) { price = ts.Cost / ts.Attributes.Count; } a.Cost += price; }); } }); }); }