estimateMissingJudgments method

List<int> estimateMissingJudgments()

Internal? Returns how many judgments are missing, for each proposal, to get a balanced poll tally. Can only return positive integers (0 is considered positive).

Implementation

List<int> estimateMissingJudgments() {
  final amountOfProposals = proposals.length;
  final missingAmounts = List.filled(amountOfProposals, 0);
  final amountsOfParticipants = List.filled(amountOfProposals, 0);
  var maxAmountOfParticipants = 0;
  for (var i = 0; i < amountOfProposals; i++) {
    final proposalTally = proposals[i];
    final amountOfParticipants = proposalTally.countJudgments();
    amountsOfParticipants[i] = amountOfParticipants;
    maxAmountOfParticipants = max(
      amountOfParticipants,
      maxAmountOfParticipants,
    );
  }
  for (var i = 0; i < amountOfProposals; i++) {
    final missingAmount = maxAmountOfParticipants - amountsOfParticipants[i];
    assert(missingAmount >= 0);
    missingAmounts[i] = missingAmount;
  }

  return missingAmounts;
}