Esempio n. 1
0
        private List <Candidate> getRandomCandidates(List <Candidate> candList)
        {
            List <Candidate> participants = new List <Candidate>();

            for (int i = 0; i < TournamentSize; i++)
            {
                int index = RandomSelector.Next(0, candList.Count() - 1);
                participants.Add(candList[index]);
            }
            return(participants);
        }
        private ConcurrentQueue <Candidate> getRandomCandidates(List <Candidate> candList)
        {
            ConcurrentQueue <Candidate> participants = new ConcurrentQueue <Candidate>();

            Parallel.For(0, TournamentSize, i => {
                int index = RandomSelector.Next(0, candList.Count() - 1);
                participants.Enqueue(candList[index]);
            });

            return(participants);
        }