Class NamedSTV

  extended by
      extended by

public class NamedSTV
extends NameVotingSystem

Sum up all effective first place votes. Elect top choice above quota. Deweight voters to quota/vote. Need deweight per voter per choice. Truncated ballots should, if possible, fully deweight on any choices that do get elected. Let voters who cast fuller ballots transfer more to lower ranked choices.

See Also:,

Nested Class Summary
protected static class NamedSTV.TallyState
protected static class NamedSTV.TallyStateComparator
protected static class NamedSTV.WeightedVote
Nested classes/interfaces inherited from class
NameVotingSystem.NameVote, NameVotingSystem.ReverseComparator
Field Summary
protected static NamedSTV.TallyStateComparator theTSC
Constructor Summary
Method Summary
 NameVotingSystem.NameVote[] getWinners()
 java.lang.StringBuffer htmlSummary(java.lang.StringBuffer sb)
          Get HTML summary of voting system state.
 int init(java.lang.String[] argv)
          Set options for voting system.
static void main(java.lang.String[] argv)
 java.lang.String name()
static double quota(int style, double votes, int seats)
 void voteRating(NameVotingSystem.NameVote[] vote)
          Vote a set of ratings.
Methods inherited from class
defaultMain, denibble, depercentHexify, fromUrlEncoded, getDebug, getImplNames, getIpmlForName, htmlExplain, htmlExplain, htmlSummary, nameEqStrToVoteArray, nameEqStrToVoteArray, percentHexify, readVotes, registerImpl, resultsHTMLDisplay, sort, urlEncode, voteNameEqStr, voteOrderSpec, voteRating, voteSpecToNameVoteArray, winnerSummaryHTMLTable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected static NamedSTV.TallyStateComparator theTSC
Constructor Detail


public NamedSTV()
Method Detail


public int init(java.lang.String[] argv)
Description copied from class: NameVotingSystem
Set options for voting system. Default implementation sets debug to true if it sees "debug". Skip pass null entries, which may have been yanked by a subclass. Unless there's an error, last line should be "return super.init( argv );" Multi-seat capable implementations should accept an option pair ("seats", <int>) to set the number of seats.

init in class NameVotingSystem
argv - array of options, just like main()
0 on success


public void voteRating(NameVotingSystem.NameVote[] vote)
Description copied from class: NameVotingSystem
Vote a set of ratings. Keys of the map should be strings (choice names) and values should be of a numeric type. This is slightly faster than the version that takes a map because no conversion is done.

Specified by:
voteRating in class NameVotingSystem
vote - a set of (name,rating) pairs
See Also:


public NameVotingSystem.NameVote[] getWinners()
Specified by:
getWinners in class NameVotingSystem
A sorted array of (name,rating) pairs. Ties can be determined by rating.


public java.lang.StringBuffer htmlSummary(java.lang.StringBuffer sb)
Description copied from class: NameVotingSystem
Get HTML summary of voting system state.

Specified by:
htmlSummary in class NameVotingSystem
sb - a valid StringBuffer to which HTML summary will be appended.
same StringBuffer passed in, with HTML summary of voting system state appended.


public java.lang.String name()
Specified by:
name in class NameVotingSystem
name of this voting system (may be modified by settings from init)


public static double quota(int style,
                           double votes,
                           int seats)


public static void main(java.lang.String[] argv)