Algorithm-Voting
view release on metacpan or search on metacpan
lib/Algorithm/Voting/Plurality.pm view on Meta::CPAN
use base 'Class::Accessor::Fast';
use List::Util 'sum';
use Params::Validate qw/ validate validate_pos ARRAYREF /;
__PACKAGE__->mk_accessors(qw/ tally /);
=pod
=head1 NAME
Algorithm::Voting::Plurality - use "Plurality" to decide the sole winner
=head1 SYNOPSIS
# construct a "ballot box"
use Algorithm::Voting::Ballot;
use Algorithm::Voting::Plurality;
my $box = Algorithm::Voting::Plurality->new();
# add ballots to the box
$box->add( Algorithm::Voting::Ballot->new('Ralph') );
lib/Algorithm/Voting/Plurality.pm view on Meta::CPAN
candidate greater than that received by any opponent but less than a majority
of the vote."
=back
=head1 METHODS
=head2 Algorithm::Voting::Plurality->new(%args)
Constructs a "ballot box" object that will use the Plurality criterion to
decide the winner. Optionally, specify a list of candidates; any ballot added
to the box that does not indicate one of the listed candidates throws an
exception.
Example:
# construct a ballot box that accepts only three candidates
my @c = qw( John Barack Ralph );
my $box = Algorithm::Voting::Plurality->new(candidates => \@c);
=cut
( run in 1.634 second using v1.01-cache-2.11-cpan-4505f990765 )