Class SchulzeBallot<C>

java.lang.Object
eu.bandm.tools.util2.SchulzeBallot<C>
All Implemented Interfaces:
Supplier<SchulzeBallot.Result<C>>

public class SchulzeBallot<C> extends Object implements Supplier<SchulzeBallot.Result<C>>
Evaluator for elections with the Schulze method.
  • Constructor Details

    • SchulzeBallot

      public SchulzeBallot()
  • Method Details

    • isClosed

      public boolean isClosed()
      Checks whether the roster is closed, i.e., adding new candidates is forbidden.
    • setClosed

      public void setClosed(boolean closed)
      Sets whether the roster is closed, i.e., adding new candidates is forbidden.
    • addCandidate

      public boolean addCandidate(C candidate)
      Throws:
      IllegalStateException - if the roster is closed and the candidate has not yet been added.
    • addPreference

      public void addPreference(C better, C worse)
      Throws:
      IllegalStateException - if the roster is closed and either candidate has not yet been added.
    • addPreferences

      public void addPreferences(C better, C worse, int amount)
      Throws:
      IllegalStateException - if the roster is closed and either candidate has not yet been added.
    • addRanks

      public void addRanks(Map<C,Integer> ranks)
      Adds preferences according to a partial ranking list.
      • The lower the rank number, the higher the preference.
      • The number 1 indicates the first rank, i.e., the highest preference.
      • Candidates with equal rank numbers are equally preferred.
      • Only the order between rank numbers, not the magnitude of the difference, matters.
      • Candidates without a rank number are less preferred than all candidates with rank numbers.
      Throws:
      IllegalArgumentException - if any rank number is not positive
      IllegalStateException - if the roster is not closed.
    • get

      public SchulzeBallot.Result get()
      Specified by:
      get in interface Supplier<C>
    • main

      public static void main(String[] args)