STAR++ v0.2.2
C++ implementation of STAR voting
Loading...
Searching...
No Matches
Star::ElectionResult Class Reference

The ElectionResult class holds the outcome of an election. More...

#include <star/electionresult.h>

Public Member Functions

 ElectionResult ()
 
 ElectionResult (const Election *election, const QList< Seat > &seats)
 
const Electionelection () const
 
qsizetype filledSeatCount () const
 
bool isComplete () const
 
bool isNull () const
 
bool operator!= (const ElectionResult &other) const
 
bool operator== (const ElectionResult &other) const
 
const SeatseatAt (qsizetype i) const
 
qsizetype seatCount () const
 
QList< Seatseats () const
 
qsizetype unfilledSeatCount () const
 
QSet< QString > unresolvedCandidates () const
 
Seat unresolvedSeat () const
 
QStringList winners () const
 

Detailed Description

Election results consist primarily of a list of seats filled according to the makeup of an Election.

An election result for a given Election can be generated through the use of Calculator.

See also
ExpectedElectionResult, and QualifierResult.

Constructor & Destructor Documentation

◆ ElectionResult() [1/2]

Star::ElectionResult::ElectionResult ( )

Constructs a null election result.

See also
isNull().

◆ ElectionResult() [2/2]

Star::ElectionResult::ElectionResult ( const Election election,
const QList< Seat > &  seats 
)

Constructs a election result that corresponds to the election election and consists of the evaluated seats seats.

Member Function Documentation

◆ election()

const Election * Star::ElectionResult::election ( ) const

Returns the election that was evaluated.

◆ filledSeatCount()

qsizetype Star::ElectionResult::filledSeatCount ( ) const

Returns the number of seats that were able to successfully be filled.

See also
isComplete() and unfilledSeatCount().

◆ isComplete()

bool Star::ElectionResult::isComplete ( ) const

Returns true if all the seats of the election were able to be filled; otherwise, returns false.

See also
isNull() and Calculator::Option::AllowTrueTies.

◆ isNull()

bool Star::ElectionResult::isNull ( ) const

Returns true if the election result is null; otherwise, returns false.

See also
isComplete().

◆ operator!=()

bool Star::ElectionResult::operator!= ( const ElectionResult other) const

Returns true if this election result is not the same as other; otherwise, returns false.

See also
operator==().

◆ operator==()

bool Star::ElectionResult::operator== ( const ElectionResult other) const

Returns true if this election result is the same as other; otherwise, returns false.

See also
operator!=().

◆ seatAt()

const Seat & Star::ElectionResult::seatAt ( qsizetype  i) const

Returns the seat at position i.

◆ seatCount()

qsizetype Star::ElectionResult::seatCount ( ) const

Returns the number of seats that were evaluated.

This will always be equal to the seat count of the election that corresponds with this result, unless Calculator::Option::AllowTrueTies was set in the Calculator that generated it and an unresolvable tie occurred.

See also
isComplete(), filledSeatCount() and unfilledSeatCount().

◆ seats()

QList< Seat > Star::ElectionResult::seats ( ) const

Returns the list of seats evaluated for the election.

◆ unfilledSeatCount()

qsizetype Star::ElectionResult::unfilledSeatCount ( ) const

Returns the number of seats that were were left unfilled.

See also
isComplete() and filledSeatCount().

◆ unresolvedCandidates()

QSet< QString > Star::ElectionResult::unresolvedCandidates ( ) const

Returns the set of candidates that caused the election to be ended prematurely, if it is incomplete; otherwise, returns an empty set.

See also
isComplete() and Calculator::Option::AllowTrueTies.

◆ unresolvedSeat()

Seat Star::ElectionResult::unresolvedSeat ( ) const

Returns the seat in the results that was left unfilled, if the election is incomplete; otherwise, returns a null seat.

If the election is incomplete, this is equivalent to:

const Seat & seatAt(qsizetype i) const
Definition electionresult.cpp:63
qsizetype seatCount() const
Definition electionresult.cpp:130
See also
isComplete() and unresolvedCandidates().

◆ winners()

QStringList Star::ElectionResult::winners ( ) const

Returns a list of the candidates that won each seat.


The documentation for this class was generated from the following files: