/// <summary> /// 根据给定的中性丢失类型候选者,以及给定的组合数,得到该组合数的所有组合方式 /// </summary> /// <param name="nlTypes"></param> /// <param name="numberOfCombination"></param> /// <returns></returns> public List <INeutralLossType> GetCombinationValues(IEnumerable <INeutralLossType> nlTypes, int numberOfCombination) { List <INeutralLossType> result = new List <INeutralLossType>(); if (nlTypes.Count() >= numberOfCombination) { if (numberOfCombination == 1) { return(nlTypes.Distinct().ToList()); } var subTypes = nlTypes.Skip(1); INeutralLossType firstType = nlTypes.First(); List <INeutralLossType> subs = GetCombinationValues(subTypes, numberOfCombination - 1); foreach (INeutralLossType aType in subs) { CombinedNeutralLossType curType = new CombinedNeutralLossType(aType); if (curType.InsertNeutralLossType(firstType)) { AddToDistinctList(result, curType); } } List <INeutralLossType> combinedSubTypes = GetCombinationValues(subTypes, numberOfCombination); foreach (INeutralLossType aType in combinedSubTypes) { AddToDistinctList(result, aType); } } return(result); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } CombinedNeutralLossType other = (CombinedNeutralLossType)obj; return(mass == other.mass && name == other.name); }