[−][src]Struct tallystick::RankedWinners
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.
Methods
impl<T: Clone + Eq> RankedWinners<T>
[src]
pub fn len(&self) -> usize
[src]
Get the number of winners.
pub fn is_empty(&self) -> bool
[src]
Check if it's empty
pub fn drain<R>(&mut self, range: R) -> Drain<(T, u32)> where
R: RangeBounds<usize>,
[src]
R: RangeBounds<usize>,
Clears the winners, returning all winner-rank pairs as an iterator.
pub fn into_vec(self) -> Vec<(T, u32)>
[src]
Transform winners into a vector of winner-rank pairs.
pub fn all(&self) -> Vec<T>
[src]
Get a list of all winners, without rank.
pub fn iter(&self) -> IterWinners<T>
[src]
Iterate over all winner->rank pairs.
pub fn contains(&self, candidate: &T) -> bool
[src]
Check if the given candidate exists in the set of ranked-winners.
pub fn rank(&self, candidate: &T) -> Option<u32>
[src]
Get the rank of a single winner.
pub fn into_unranked(self) -> Vec<T>
[src]
Get an unranked list of all winners, this consumes the winner list.
pub fn check_overflow(&self) -> bool
[src]
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.
pub fn overflow(&self) -> Option<Vec<T>>
[src]
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
impl<T: Debug + Clone> Debug for RankedWinners<T>
[src]
impl<T: Default + Clone> Default for RankedWinners<T>
[src]
fn default() -> RankedWinners<T>
[src]
impl<T: Eq + Clone> Eq for RankedWinners<T>
[src]
impl<T: Clone> From<(Vec<(T, u32)>, u32)> for RankedWinners<T>
[src]
impl<T: PartialEq + Clone> PartialEq<RankedWinners<T>> for RankedWinners<T>
[src]
fn eq(&self, other: &RankedWinners<T>) -> bool
[src]
fn ne(&self, other: &RankedWinners<T>) -> bool
[src]
impl<T: Clone> StructuralEq for RankedWinners<T>
[src]
impl<T: Clone> StructuralPartialEq for RankedWinners<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for RankedWinners<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for RankedWinners<T> where
T: Send,
T: Send,
impl<T> Sync for RankedWinners<T> where
T: Sync,
T: Sync,
impl<T> Unpin for RankedWinners<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for RankedWinners<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,