[][src]Struct number_encoding::combinadics::Iter

pub struct Iter { /* fields omitted */ }

Iterates over all k-combinations.

The k-combinations are iterated in value order:

let mut iter = Iter::new(k);
for i in 0 .. combination(n, k) {
    assert_eq!(encode(iter.get()), i);
    iter.advance();
}

Examples

To iterate over all k-combinations in a set of n elements:

let mut iter = Iter::new(k);
for _ in 0 .. combination(n, k) {
    process(iter.get());
    iter.advance();
}

Methods

impl Iter[src]

pub fn new(k: usize) -> Iter[src]

Constructs an iterator.

pub fn new_from(xs: Vec<usize>) -> Iter[src]

Constructs an iterator starting from a given k-combination.

Panics

Panics in debug mode if xs is not increasing.

pub fn get(&self) -> &[usize][src]

Returns the current combination.

pub fn advance(&mut self)[src]

Advances to the next combination.

Auto Trait Implementations

impl Send for Iter

impl Sync for Iter

impl Unpin for Iter

impl UnwindSafe for Iter

impl RefUnwindSafe for Iter

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]