[][src]Struct permutator::LargeCombinationIterator

pub struct LargeCombinationIterator<'a, T> where
    T: 'a, 
{ /* fields omitted */ }

Create a combination iterator. The result is lexicographic ordered if input is lexicorgraphic ordered. The returned combination will be a reference into given data. Each combination return from iterator will be a new Vec. It's safe to hold onto a combination or collect it.

Examples

Given slice of [1, 2, 3, 4, 5]. It will produce following combinations: [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4], [1, 2, 5], [1, 3, 5], [2, 3, 5], [1, 4, 5], [2, 4, 5], [3, 4, 5] Here's an example of code printing above combination.

   use permutator::LargeCombinationIterator;
   use std::time::{Instant};
   let lc = LargeCombinationIterator::new(&[1, 2, 3, 4, 5], 3);
   let mut counter = 0;
   let timer = Instant::now();

   for combination in lc {
       println!("{}:{:?}", counter, combination);
       counter += 1;
   }

   println!("Total {} combinations in {:?}", counter, timer.elapsed());

Panic

It panic if r == 0 or r > data.len()

Methods

impl<'a, T> LargeCombinationIterator<'a, T>[src]

Important traits for LargeCombinationIterator<'a, T>
pub fn new(data: &[T], r: usize) -> LargeCombinationIterator<T>[src]

pub fn iter(&mut self) -> &mut Self[src]

Trait Implementations

impl<'a, T> ExactSizeIterator for LargeCombinationIterator<'a, T>[src]

impl<'a, T> Iterator for LargeCombinationIterator<'a, T>[src]

type Item = Vec<&'a T>

The type of the elements being iterated over.

impl<'a, T> IteratorReset for LargeCombinationIterator<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for LargeCombinationIterator<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for LargeCombinationIterator<'a, T> where
    T: Sync

impl<'a, T> Sync for LargeCombinationIterator<'a, T> where
    T: Sync

impl<'a, T> Unpin for LargeCombinationIterator<'a, T>

impl<'a, T> UnwindSafe for LargeCombinationIterator<'a, T> where
    T: RefUnwindSafe

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, 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.