STAR++ v0.2.2
C++ implementation of STAR voting
|
The Election class represents a collection of candidates and ballots. More...
#include <star/election.h>
Classes | |
class | Ballot |
The Election::Ballot class represents a single ballot for a given election. More... | |
class | Builder |
The Election::Builder class is a utility through which elections can be prepared. More... | |
struct | Vote |
The Election::Voter struct represents a single vote for a candidate in an election. More... | |
struct | Voter |
The Election::Voter struct contains the details of a voter participating in an election. More... | |
Public Member Functions | |
Election () | |
const QList< Ballot > & | ballots () const |
QStringList | candidates () const |
bool | isValid () const |
QString | name () const |
const QList< Rank > & | scoreRankings () const |
int | seatCount () const |
int | totalScore (const QString &candidate) const |
One of the two quintessential classes of STAR++, the Election class acts as a literal election. An Election is created via Election::Builder and then "counted" with a Calculator, which provides a corresponding ElectionResults instance.
Star::Election::Election | ( | ) |
Creates an invalid Election.
const QList< Election::Ballot > & Star::Election::ballots | ( | ) | const |
Returns the list of ballots provided for the election.
QStringList Star::Election::candidates | ( | ) | const |
Returns the list of candidates in the election.
bool Star::Election::isValid | ( | ) | const |
Returns true
if the election is valid; otherwise, returns false.
In order for an election to be valid, it must:
QString Star::Election::name | ( | ) | const |
Returns the name of the election.
const QList< Rank > & Star::Election::scoreRankings | ( | ) | const |
Returns a list of all candidates in the election ranked by total score (descending).
int Star::Election::seatCount | ( | ) | const |
Returns the number of seats prescribed for the election.
int Star::Election::totalScore | ( | const QString & | candidate | ) | const |
Returns the total score for candidate candidate across all ballots.