internal IEnumerable <HlaMsr1> GeneralizationList(HlaMsr1Factory hlaMsr1Factory) { HashSet <string> warningSetToIgnore = new HashSet <string>(); SpecialFunctions.CheckCondition(IsGround, "Can only get generalization list for ground hlas"); if (Name.Length == 5) { yield return(this); } if (Name.Length >= 3) { string twoDigit = Name.Substring(0, 3); if (HlaMsr1Factory.MoreThan100.ContainsKey(twoDigit)) { twoDigit = ClassName + HlaMsr1Factory.MoreThan100[twoDigit]; } yield return((HlaMsr1)hlaMsr1Factory.GetGroundOrAbstractInstance(twoDigit, ref warningSetToIgnore)); Debug.Assert(warningSetToIgnore.Count == 0); // real assert } yield return((HlaMsr1)hlaMsr1Factory.GetGroundOrAbstractInstance(ClassName, ref warningSetToIgnore)); Debug.Assert(warningSetToIgnore.Count == 0); // real assert }
public static IEnumerable <PidAndHlaSet> GetEnumerationSparse(TextReader inputTextReader) { string previousPid = null; Dictionary <string, List <HlaMsr1> > classToHlaList = null; HashSet <string> warningSet = null; foreach (var pidAndHlaRecord in SpecialFunctions.ReadDelimitedFile(inputTextReader, new { pid = "", hla = "" }, new char[] { '\t' }, true)) { string pid = pidAndHlaRecord.pid; if (previousPid != pid) { if (previousPid != null) { PidAndHlaSet pidAndHlaSet = CreatePidAndHlaSet(previousPid, classToHlaList, warningSet); yield return(pidAndHlaSet); } previousPid = pid; classToHlaList = new Dictionary <string, List <HlaMsr1> >(); warningSet = new HashSet <string>(); } HlaMsr1 hlaMsr1 = (HlaMsr1)HlaMsr1Factory444.GetGroundOrAbstractInstance(pidAndHlaRecord.hla, ref warningSet); List <HlaMsr1> hlaList = classToHlaList.GetValueOrDefault(hlaMsr1.ClassName); hlaList.Add(hlaMsr1); } if (previousPid != null) { PidAndHlaSet pidAndHlaSet = CreatePidAndHlaSet(previousPid, classToHlaList, warningSet); yield return(pidAndHlaSet); } }
internal IEnumerable <HlaMsr1> TermList(HlaMsr1Factory hlaMsr1Factory) { //!!!this could be made faster by skipping the factory calls when it is the same as the current HLA and for when there are no "/"'s HashSet <string> warningSetToIgnore = new HashSet <string>(); HlaMsr1 newHla = (HlaMsr1)hlaMsr1Factory.GetGroundOrAbstractInstance(ToString(/*withParens*/ true), ref warningSetToIgnore); foreach (var nameAndOri in newHla.NameAndOriList) { yield return((HlaMsr1)hlaMsr1Factory.GetGroundOrAbstractInstance(nameAndOri.Value, ref warningSetToIgnore)); } }
public static void UnitTest() { HlaMsr1Factory hlaMsr1Factory = HlaMsr1Factory.GetFactory(new int[] { 4, 4, 4 }); HashSet <string> warningSet = new HashSet <string>(); SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234/B23", ref warningSet).ToString() == "B1234/B23"); hlaMsr1Factory.GetGroundOrAbstractInstance("BND", ref warningSet); Hla hla5 = hlaMsr1Factory.GetGroundOrAbstractInstance("B", ref warningSet); SpecialFunctions.CheckCondition(hla5.ToString() == "B"); Hla hla3 = hlaMsr1Factory.GetGroundOrAbstractInstance("C1234", ref warningSet); SpecialFunctions.CheckCondition(hla3.ToString() == "C1234"); SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234", ref warningSet).ToString() == "B1234"); SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("C1234/C12/C", ref warningSet).ToString() == "C"); Hla hla7 = hlaMsr1Factory.GetGroundOrAbstractInstance("C1234N", ref warningSet); SpecialFunctions.CheckCondition(hla7.ToString() == "C1234"); Hla hla6 = hlaMsr1Factory.GetGroundOrAbstractInstance("C12", ref warningSet); SpecialFunctions.CheckCondition(hla6.ToString() == "C12"); Hla hla1 = hlaMsr1Factory.GetGroundOrAbstractInstance("A74", ref warningSet); SpecialFunctions.CheckCondition(hla1.ToString() == "A74"); Hla hla2 = hlaMsr1Factory.GetGroundOrAbstractInstance("A7412", ref warningSet); SpecialFunctions.CheckCondition(hla2.ToString() == "A74"); SpecialFunctions.CheckCondition(hla6.IsMoreGeneralThan(hla7)); // assert SpecialFunctions.CheckCondition(!hla6.IsMoreGeneralThan(hla2)); // assert SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("A12345678", ref warningSet).ToString() == "A1234"); SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B95", ref warningSet).ToString() == "B15"); SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B15/B9512", ref warningSet).ToString() == "B15"); Hla hla4 = hlaMsr1Factory.GetGroundOrAbstractInstance("A02/A9299", ref warningSet); SpecialFunctions.CheckCondition(hla4.ToString() == "A02"); SpecialFunctions.CheckCondition(hla3.IsGround); // assert SpecialFunctions.CheckCondition(hla1.IsGround); // assert SpecialFunctions.CheckCondition(!hla4.IsGround); // assert SpecialFunctions.CheckCondition(!hla5.IsGround); // assert SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("A1200", ref warningSet).ToString() == "A12"); SpecialFunctions.CheckCondition(!hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234/B23", ref warningSet).IsGround); }