[][src]Struct permutator::HeapPermutationIterator

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

Heap's permutation in iterator style implementation.

Examples

Iterator style usage example:

   use permutator::HeapPermutationIterator;
   use std::time::{Instant};
   let data = &mut [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
   println!("0:{:?}", data);
   let mut permutator = HeapPermutationIterator::new(data);
   let timer = Instant::now();
   let mut counter = 1;

   for permutated in permutator {
       // println!("{}:{:?}", counter, permutated);
       counter += 1;
   }
 
   // or use iterator related functional approach like line below.
   // permutator.into_iter().for_each(|permutated| {counter += 1;});

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

See

Methods

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

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

Construct a new permutation iterator. Note: the provided parameter will get mutated in placed at first call to next.

pub fn into_iter(self) -> Self[src]

Consume itself immediately return it. It mimic how IntoIterator trait perform except that this struct itself implement Iterator trait.

Trait Implementations

impl<'a, T> ExactSizeIterator for HeapPermutationIterator<'a, T> where
    T: Clone
[src]

impl<'a, T> Iterator for HeapPermutationIterator<'a, T> where
    T: Clone
[src]

type Item = Vec<T>

The type of the elements being iterated over.

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

fn reset(&mut self)[src]

Reset this permutator so calling next will continue permutation on current permuted data. It will not reset permuted data.

Auto Trait Implementations

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

impl<'a, T> Send for HeapPermutationIterator<'a, T> where
    T: Send

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

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

impl<'a, T> !UnwindSafe for HeapPermutationIterator<'a, T>

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.