private void InitWorkingData(out int mirsCount, out int partiesCountTable1, out bool[] workingPartyFlagsTable1, out int[,] votesTable1, out int[] _mirVotesCountTable1, out int[] _partyVotesCountTable1, out decimal[] _mirMandateQuotesTable1)
{
mirsCount = _mirsAll.Count();
partiesCountTable1 = _partiesAll.Count();
workingPartyFlagsTable1 = new bool[partiesCountTable1];
for (int i = 0; i < partiesCountTable1; i++)
{
workingPartyFlagsTable1[i] = true;
}
//associate index from array to mir
Dictionary<int, int> mirIndeces = new Dictionary<int, int>();
for (int i = 0; i < mirsCount; i++)
{
mirIndeces.Add(_mirsAll[i].Id, i);
}
//associate index from array to mir
Dictionary<int, int> partyIndecesTable1 = new Dictionary<int, int>();
for (int i = 0; i < partiesCountTable1; i++)
{
partyIndecesTable1.Add(_partiesAll[i].Id, i);
}
//fill votes table
votesTable1 = new int[mirsCount, partiesCountTable1];//all votes per party per mir
foreach (var vote in _votesAll)
{
votesTable1[mirIndeces[vote.MirId], partyIndecesTable1[vote.PartyId]] = vote.Count;
}
//set initial mir mandates available
_mirMandatesAvailable = _mirsAll.Select(mir => mir.MandatesLimit).ToArray();
//calculate mir and partyVotes votes
_mirVotesCountTable1 = new int[mirsCount];
_partyVotesCountTable1 = new int[partiesCountTable1];
for (int i = 0; i < mirsCount; i++)
{
for (int j = 0; j < partiesCountTable1; j++)
{
_mirVotesCountTable1[i] += votesTable1[i, j];
_partyVotesCountTable1[j] += votesTable1[i, j];
}
}
//calculate _mirMandateQuote
_mirMandateQuotesTable1 = new decimal[mirsCount];
for (int i = 0; i < mirsCount; i++)
{
if (_mirMandatesAvailable[i] == 0)
{
_mirMandateQuotesTable1[i] = 0;
}
else
{
_mirMandateQuotesTable1[i] = (decimal)_mirVotesCountTable1[i] / _mirMandatesAvailable[i];
}
}
}