[][src]Struct icub3d_combinatorics::Combination

pub struct Combination { /* fields omitted */ }

A representation of a combination.

Example

let mut cc = Vec::new();
for c in Combination::new(3, 2) {
    cc.push(c);
}

assert_eq!(
    cc,
    vec![
        vec![0, 1],
        vec![1, 2],
        vec![0, 2]
    ]
);

Index Based

The iterator returns zero-based values of the positions in the combination. This makes it more generally useful for anything that is indexable.

Consider combinations of a set of letters:

let letters = vec!['a', 'b', 'c'];
let mut cc = Vec::new();
for c in Combination::new(3, 2) {
    cc.push(vec![letters[c[0]], letters[c[1]]]);
}

assert_eq!(
    cc,
    vec![
        vec!['a', 'b'],
        vec!['b', 'c'],
        vec!['a', 'c']
    ]
);

Methods

impl Combination[src]

pub fn new(n: usize, k: usize) -> Combination[src]

Create a new combination iterator for an n-size array where k elements are taken from it each iteration.

Trait Implementations

impl Clone for Combination[src]

impl Debug for Combination[src]

impl Iterator for Combination[src]

type Item = Vec<usize>

The type of the elements being iterated over.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.