Takes a single argument of a hashref containing Choices as Keys and Votes as Values. Returns an Object. This method is also aliased as new.
Takes an ordered list and returns a RankCount Object where the RawCount values are zero minus the position: Item 3 in the list will have -3 votes while Item 1 will have -1.
my $ordered_rank_count = Vote::Count::RankCount->newFromList( @ordered_list );
The following Methods are available from RankCount Objects.
Returns the original HashRef used for Object Creation.
Returns a HashRef with the Choices as Keys and the position of the choice, the value for the Leader would be 1 and the Third Place Choice would be 3. If choices are tied they will share the same value for their position.
Returns a HashRef where the keys are numbers and the values an ArrayRef of the Choices in that position. The ArrayRefs are sorted alphanumerically.
Returns an ArrayRef of the Choices in the Top or Bottom Positions.
Returns the array that was to create the RankCount object if it was created from a List. Returns an exception if the object was created from a HashRef, because RankCount does not deal with ties. Returning a list with ties resolved by randomness or a sort would not be correct.
Returns the number of votes in the RawCount. This is not the same as the votes in the BallotSet from which that was derived. For TopCount it is the number of non-exhausted ballots in the round that generated RawCount, for Approval and Borda it is probably not useful.
Returns a HashRef with the keys tie, tied, winner where winner is the winner, tie is true or false and tied is an array ref of the choices in the tie.
Generates a MarkDown formatted table.
| Rank | Choice | Votes |
| 1 | VANILLA | 7 |
| 2 | MINTCHIP | 5 |
Ranktable for use with weighted votes. Displays both the Vote Value and the Vote Total (rounded to two places). Requires Vote Value as an argument.
say $WeightedElection->TopCount->RankTableWeighted( 100 );
| Rank | Choice | Votes | VoteValue |
| 1 | VANILLA | 7.00 | 700 |
| 2 | MINTCHIP | 5.00 | 500 |
John Karr (BRAINBUZ) firstname.lastname@example.org
Copyright 2019-2021 by John Karr (BRAINBUZ) email@example.com.
This module is released under the GNU Public License Version 3. See license file for details. For more information on this license visit http://fsf.org.
This software is provided as is, per the terms of the GNU Public License. Professional support and customisation services are available from the author.
To install Vote::Count, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.