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
pub fn drain<R>(&mut self, range: R) -> Drain<'_, RankedCandidate<T>> where
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, RankedCandidate<T>> where
R: RangeBounds<usize>,
Clears the winners, returning all winner-rank pairs as an iterator.
Transform winners into a vector of winner-rank pairs.
Check if the given candidate exists in the set of ranked-winners.
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 the “default value” for a type. Read more
impl<'de, T: Clone + Eq + PartialEq> Deserialize<'de> for RankedWinners<T> where
T: Deserialize<'de>,
impl<'de, T: Clone + Eq + PartialEq> Deserialize<'de> for RankedWinners<T> where
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
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 !=
.
Auto Trait Implementations
impl<T> RefUnwindSafe for RankedWinners<T> where
T: RefUnwindSafe,
impl<T> Send for RankedWinners<T> where
T: Send,
impl<T> Sync for RankedWinners<T> where
T: Sync,
impl<T> Unpin for RankedWinners<T> where
T: Unpin,
impl<T> UnwindSafe for RankedWinners<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.