[][src]Enum tallystick::Quota

pub enum Quota<C> {
    Droop,
    Hagenbach,
    Hare,
    Imperiali,
    Static(C),
}

A quota defines how many votes are required to win an election in relation to the total number of votes cast. nightly

Variants

Droop

Droop quota. It is defined as:

floor((total-votes / (total-seats + 1)) + 1

In single-winner elections, it's often known as "fifty percent plus one". The Droop quota is always an integer, even when using fractional votes.

See wikipedia for more details.

Hagenbach

Hagenbach-Bischoff quota.

Also known as the "Newland-Britton quota" or the "exact Droop quota", it is defined as:

total-votes / (total-seats + 1)

It differs from the Droop quota in that the quota often contains a fraction. In single-winner elections, the first candidate to achieve more than 50% of the vote wins. This system is best used when fractional votes are being used, or in a transferable-vote system where votes are redistributed fractionally.

See wikipedia for more details.

Hare

Hare quota.

It is defined as:

total-votes / total-seats

In single-winner elections, it is equal to one hundred percent of the vote. It is generally not recommended and is included for completeness.

See wikipedia for more details.

Imperiali

Imperiali quota.

It is defined as:

total-votes / (total-seats + 2)

It is rarely used and not recommended.

See wikipedia for more details.

Static(C)

Static quota that does not vary with either the total votes nor the total seats.

Useful for oddball custom tallies with custom quotas.

Methods

impl<C: Numeric + Num + Clone> Quota<C>[src]

pub fn threshold(&self, total_votes: C, num_winners: C) -> C[src]

Compute the threshold needed to be elected for the given quota.

Note that total-votes should be the number of votes counted in the tally. It should not include invalid votes that were not added the tally. For weighted tallies, it should be the sum of all weights.

Panics

This method will panic if Quota::Hagenbach is used with an integer (non Real) count type.

Auto Trait Implementations

impl<C> RefUnwindSafe for Quota<C> where
    C: RefUnwindSafe

impl<C> Send for Quota<C> where
    C: Send

impl<C> Sync for Quota<C> where
    C: Sync

impl<C> Unpin for Quota<C> where
    C: Unpin

impl<C> UnwindSafe for Quota<C> where
    C: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.