Package eu.bandm.tools.util2
Class SchulzeBallot<C>
java.lang.Object
eu.bandm.tools.util2.SchulzeBallot<C>
- All Implemented Interfaces:
Supplier<SchulzeBallot.Result<C>>
Evaluator for elections with the Schulze method.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddCandidate(C candidate) voidaddPreference(C better, C worse) voidaddPreferences(C better, C worse, int amount) voidAdds preferences according to a partial ranking list.get()booleanisClosed()Checks whether the roster is closed, i.e., adding new candidates is forbidden.static voidvoidsetClosed(boolean closed) Sets whether the roster is closed, i.e., adding new candidates is forbidden.
-
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
- Throws:
IllegalStateException- if the roster is closed and the candidate has not yet been added.
-
addPreference
- Throws:
IllegalStateException- if the roster is closed and either candidate has not yet been added.
-
addPreferences
- Throws:
IllegalStateException- if the roster is closed and either candidate has not yet been added.
-
addRanks
Adds preferences according to a partial ranking list.- The lower the rank number, the higher the preference.
- The number
1indicates 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 positiveIllegalStateException- if the roster is not closed.
-
get
-
main
-