私はリストを持っています
List<FirstIterationCapacitors> FirstIteration = new List<FirstIterationCapacitors>(); // A set of Solution capacitors object
これがそのクラスです
class FirstIterationCapacitors
{
public int Iteration { get; set; }
public int CapacitorALocation { get; set; }
public int CapacitorBLocation { get; set; }
public int CapacitorCLocation { get; set; }
}
今、私は2番目のリストを持っています
List<PossibleSolutionCapacitors> PossibleSolution = new List<PossibleSolutionCapacitors>(); // Possible Solution capacitors object
ここにそのクラスがあります
class PossibleSolutionCapacitors
{
public int CapacitorALocation { get; set; }
public int CapacitorBLocation { get; set; }
public int CapacitorCLocation { get; set; }
}
PossibleSolution の特定の行 (つまり、行 2) について、次のことを確認する必要があります。
- PossibleSolution.CapacitorALocation が FirstIteration.CapacitorALocation (反復 X に等しい) または FirstIteration.CapacitorBLocation (反復 X に等しい) または FirstIteration.CapacitorCLocation (反復 X に等しい) に存在しません。
また
- PossibleSolution.CapacitorBLocation が FirstIteration.CapacitorALocation (反復 X に等しい) または FirstIteration.CapacitorBLocation (反復 X に等しい) または FirstIteration.CapacitorCLocation (反復 X に等しい) に存在しません。
また
- PossibleSolution.CapacitorCLocation が FirstIteration.CapacitorALocation (反復 X に等しい) または FirstIteration.CapacitorBLocation (反復 X に等しい) または FirstIteration.CapacitorCLocation (反復 X に等しい) に存在しません。
理想的には、条件が true/false の場合は true false を示すブール値
これは私がこれまでに試したことですが、うまくいきません
int D = 4; // The row i care about
int E = PossibleSolution[D].CapacitorALocation;
int F = PossibleSolution[D].CapacitorBLocation;
int G = PossibleSolution[D].CapacitorCLocation;
var fixedSet = new HashSet<int>() {E};
if (!FirstIteration.Any(x => fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation })))
{
fixedSet = new HashSet<int>() {F};
if (!FirstIteration.Any(x => fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation })))
{
fixedSet = new HashSet<int>() {G};
if (!FirstIteration.Any(x => fixedSet.SetEquals(new[] { x.CapacitorALocation, x.CapacitorBLocation, x.CapacitorCLocation })))
{
//Match does not exist so do some real work here ......
}
}
}
ありがとう、ダモ