Beispiel #1
0
            private KeyDictionary PopulateSolutionDictionary(List <int> commonIntersections, List <sbyte[]> acceptedCombos, CancellationToken cancellationToken)
            {
                var kd = new KeyDictionary(0, sbyte.MinValue);

                Parallel.ForEach(acceptedCombos, (ac, state) =>
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        state.Break();
                    }
                    else
                    {
                        var onlyIntersectionDiffs = IntersectionPermuatations(ac.ToArray(), commonIntersections.ToArray());

                        Parallel.ForEach(onlyIntersectionDiffs, (i, innerState) =>
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                innerState.Break();
                            }
                            else
                            {
                                kd.SetSolution(i);
                            }
                        });
                    }
                });

                return(kd);
            }