private static bool[] AddYesNoSelection(bool[] selections, string yesNoVote, ContestMap contestMap) { var yesNoExists = contestMap.SelectionMap.TryGetValue(yesNoVote, out var yesNoIndex); if (yesNoExists) { selections[yesNoIndex] = true; } return(selections); }
private static bool[] AddNullProtectionVotes(bool[] selections, ContestMap contestMap) { for (var i = contestMap.NullVoteStartIndex; i <= contestMap.EndIndex; i++) { if (selections .Where((selection, index) => contestMap.StartIndex <= index && index <= contestMap.EndIndex) .Count(selected => selected) >= contestMap.ExpectedNumberOfSelected) { return(selections); } selections[i] = true; } return(selections); }
private static bool[] AddCandidateSelections(bool[] selections, Candidate[] candidateVotes, ContestMap contestMap) { var writeInIndex = contestMap.WriteInStartIndex; foreach (var candidateVote in candidateVotes) { var candidateExists = contestMap.SelectionMap.TryGetValue(candidateVote.Id, out var candidateIndex); if (candidateExists) { selections[candidateIndex] = true; } else // Write In { selections[writeInIndex] = true; writeInIndex++; } } return(selections); }