Struct wybr::tally::vote_tree::VoteTree

source ·
pub struct VoteTree { /* private fields */ }

Implementations§

source§

impl VoteTree

source

pub fn new(candidates: u32) -> VoteTree

source

pub fn get_candidates(&self) -> u32

source

pub fn ballot_count(&self) -> u64

source

pub fn stream_ballots<F: FnMut(u64, &[u32])>(&self, reader: &mut F)

source

pub fn assign_votes(&self, eliminated: &HashSet<u32>) -> (u64, HashMap<u32, u64>)

source

pub fn transfer_votes_fp(
    &self,
    weights: &HashMap<u32, u64>,
    base: u64,
    transfer: Transfer
) -> (u64, HashMap<u32, u64>)

source

pub fn count_ranks(&self, skipped: &HashSet<u32>) -> HashMap<(u32, u32), u64>

Trait Implementations§

source§

impl<'a> FromIterator<&'a (u64, Vec<u32, Global>)> for VoteTree

Iterator collector for fast&dirty creation of VoteTrees in tests and examples

source§

fn from_iter<I: IntoIterator<Item = &'a (u64, Vec<u32>)>>(i: I) -> Self

Creates a value from an iterator. Read more
source§

impl Tally for VoteTree

source§

fn get_meta(&self) -> &Metadata

Returns a copy of metadata
source§

fn get_candidates(&self) -> u32

Returns the number of candidates
source§

fn get_seats(&self) -> u32

Return a number of seats
source§

fn name_candidate(&self, id: u32) -> Option<&String>

Get the name of a candidate from metadata
source§

fn map_withdrawn<F: FnMut(u32)>(&self, f: F)

Map over IDs of withdrawn candidates
source§

fn from_blt_file(name: &str) -> Result<Self, VoteReadError>where
    Result<Self, VoteReadError>: FromIterator<VoteToken>,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.