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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addCandidate
(C candidate) void
addPreference
(C better, C worse) void
addPreferences
(C better, C worse, int amount) void
Adds preferences according to a partial ranking list.get()
boolean
isClosed()
Checks whether the roster is closed, i.e., adding new candidates is forbidden.static void
void
setClosed
(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
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 positiveIllegalStateException
- if the roster is not closed.
-
get
-
main
-