Struct tallystick::RankedWinners[][src]

pub struct RankedWinners<T: Clone + Eq + PartialEq> {
    pub winners: Vec<RankedCandidate<T>>,
    pub num_winners: usize,
}
Expand description

RankedWinners is a ranked list of winning candidates, sorted according to rank. Ranks are in ascending order. A 0 ranked winner is more significant than a 3 ranked winner. Winners with the same rank are tied.

Fields

winners: Vec<RankedCandidate<T>>

Ranked winners

num_winners: usize

Number of winners, this number could be less than winners.len() if there are ties in the lowest ranked winners.

Implementations

Get the number of winners.

Check if it’s empty

Clears the winners, returning all winner-rank pairs as an iterator.

Transform winners into a vector of winner-rank pairs.

Get a list of all winners, without rank.

Iterate over all winner->rank pairs.

Check if the given candidate exists in the set of ranked-winners.

Get the rank of a single winner.

Get an unranked list of all winners, this consumes the winner list.

Check if the actual number of winners is more than the wanted number of winners. This can happen if there is a tie.

Not all ties result in an overflow. Only a tie of the least-significantly ranked winning candidates can result in an overflow. Consider an election that is trying to fill three seats. If only the top two candidates tie, then there is no overflow. However, if the 3rd place and 4th place candidates tie, then there will be an overflow with both candidates being equally ranked to fill the 3rd seat.

Get all tied least-significantly ranked winners that overflow the wanted number of winners.

If there is a tie in the least-significantly ranked winning candidates, then the actual number of winners may “overflow” the wanted number of winners, in which case this method will return a list of overlow candidates (or None if there is no overflow).

You should always check for an overflow so you can resolve this unfortunate situation.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.