Struct binomial_iter::BinomialIter
[−]
[src]
pub struct BinomialIter { // some fields omitted }
Provides methods to calculate the binomial coefficient for the next
higher/lower n
/k
.
Methods
impl BinomialIter
[src]
fn new(n: u32, k: u32) -> BinomialIter
Create a new BinomialIter
. This will calculate the binomial
coefficient once using the recursive definition.
Panics
If k > n
fn n(&self) -> u32
Access the current value of n
.
fn k(&self) -> u32
Access the current value of k
.
fn binom(&self) -> u32
Access the current value of n
choose k
.
fn inc_n(&mut self) -> Option<(u32, u32)>
Increase n
by one and update the internal state accordingly.
Returns None
when calculating n + 1
choose k
would overflow,
otherwise Some((n + 1, binom))
.
fn dec_n(&mut self) -> Option<(u32, u32)>
Decrease n
by one and update the internal state accordingly.
Returns None
when calculating n - 1
choose k
would overflow or
n - 1 < k
, otherwise Some((n - 1, binom))
.
fn inc_k(&mut self) -> Option<(u32, u32)>
Increase k
by one and update the internal state accordingly.
Returns None
when calculating n
choose k + 1
would overflow or
n < k + 1
, otherwise Some((k + 1, binom))
.
fn dec_k(&mut self) -> Option<(u32, u32)>
Decrease k
by one and update the internal state accordingly.
Returns None
when calculating n
choose k - 1
would overflow or
k - 1 < 0
, otherwise Some((k - 1, binom))
impl BinomialIter
[src]
fn iter_inc_n(self) -> IncNIter
Returns an iterator which wraps this BinomialIter
, returns the current
value of n
and binom
on the first call to next
and the result of
calling inc_n
on the underlying BinominalIter
for subsequent calls
to next.
impl BinomialIter
[src]
fn iter_dec_n(self) -> DecNIter
Returns an iterator which wraps this BinomialIter
, returns the current
value of n
and binom
on the first call to next
and the result of
calling dec_n
on the underlying BinominalIter
for subsequent calls
to next.
impl BinomialIter
[src]
fn iter_inc_k(self) -> IncKIter
Returns an iterator which wraps this BinomialIter
, returns the current
value of k
and binom
on the first call to next
and the result of
calling inc_k
on the underlying BinominalIter
for subsequent calls
to next.
impl BinomialIter
[src]
fn iter_dec_k(self) -> DecKIter
Returns an iterator which wraps this BinomialIter
, returns the current
value of k
and binom
on the first call to next
and the result of
calling dec_k
on the underlying BinominalIter
for subsequent calls
to next.
Trait Implementations
impl Eq for BinomialIter
[src]
impl PartialEq for BinomialIter
[src]
fn eq(&self, __arg_0: &BinomialIter) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BinomialIter) -> bool
This method tests for !=
.
impl Clone for BinomialIter
[src]
fn clone(&self) -> BinomialIter
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more