org.bolson.vote
Class NamedVRR

java.lang.Object
  extended by org.bolson.vote.NameVotingSystem
      extended by org.bolson.vote.NamedVRR

public class NamedVRR
extends NameVotingSystem

Virtual Round Robin election (Condorcet).


Nested Class Summary
protected static class NamedVRR.Count
           
 
Nested classes/interfaces inherited from class org.bolson.vote.NameVotingSystem
NameVotingSystem.NameVote, NameVotingSystem.ReverseComparator
 
Constructor Summary
NamedVRR()
           
 
Method Summary
protected  NamedVRR.Count getCount(java.lang.String name)
           
protected  NamedVRR.Count[] getIndexedCounts(boolean ldebug)
           
protected static int[] getTallyArray(NamedVRR.Count[] they)
          build a tally array like Condorcet class uses, easier to use that code with
 NameVotingSystem.NameVote[] getWinners()
          find Condorcet winner with CSSD cycle resolution
 NameVotingSystem.NameVote[] getWinnersCSSD(NamedVRR.Count[] they, int[] tally)
           
 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.
protected static NameVotingSystem.NameVote[] makeWinners(NamedVRR.Count[] they, int[] defeatCount)
           
 java.lang.String name()
           
 void voteRating(NameVotingSystem.NameVote[] vote)
          counts the names voted.
 
Methods inherited from class org.bolson.vote.NameVotingSystem
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
 

Constructor Detail

NamedVRR

public NamedVRR()
Method Detail

init

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.

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

voteRating

public void voteRating(NameVotingSystem.NameVote[] vote)
counts the names voted. Keeps only a summation of the votes, not individual vote data.

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

makeWinners

protected static NameVotingSystem.NameVote[] makeWinners(NamedVRR.Count[] they,
                                                         int[] defeatCount)

getWinners

public NameVotingSystem.NameVote[] getWinners()
find Condorcet winner with CSSD cycle resolution

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

getIndexedCounts

protected NamedVRR.Count[] getIndexedCounts(boolean ldebug)

htmlSummary

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
Parameters:
sb - a valid StringBuffer to which HTML summary will be appended.
Returns:
same StringBuffer passed in, with HTML summary of voting system state appended.

name

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

getCount

protected NamedVRR.Count getCount(java.lang.String name)

getTallyArray

protected static int[] getTallyArray(NamedVRR.Count[] they)
build a tally array like Condorcet class uses, easier to use that code with


getWinnersCSSD

public NameVotingSystem.NameVote[] getWinnersCSSD(NamedVRR.Count[] they,
                                                  int[] tally)