[][src]Struct permutator::XPermutationRefIter

pub struct XPermutationRefIter<'a, F, T> where
    F: FnMut(&[&T]) -> bool,
    T: 'a, 
{ /* fields omitted */ }

A lexicographic ordered permutation based on "Algoritm X" published by Donald E. Knuth. page 20.

If order is not important, consider using heap permutation struct instead. This struct is a bit slower (about 10%) than heap permutation in uncontroll test environment.

The algorithm work by simulate tree traversal where some branch can be skip altogether. This is archive by provided t function that take slice of partial result as parameter. If the partial result needed to be skip, return false. Otherwise, return true and the algorithm will call this function again when the branch is descended deeper. For example: First call to t may contain [1]. If t return true, it will be called again with [1, 2]. If it return true, and there's leaf node, cb will be called with [1, 2]. On the other hand, if t is called with [1, 3] and it return false, it won't call the callback. If t is called with [4] and it return false, it won't try to traverse deeper even if there're [4, 5], or [4, 6]. It will skip altogether and call t with [7]. The process goes on until every branch is traversed.

Methods

impl<'a, F, T> XPermutationRefIter<'a, F, T> where
    F: FnMut(&[&T]) -> bool,
    T: 'a, 
[src]

Important traits for XPermutationRefIter<'a, F, T>
pub unsafe fn new(
    data: &'a [T],
    result: *mut [&'a T],
    t: F
) -> XPermutationRefIter<'a, F, T>
[src]

Construct new XPermutationIterator object.

Parameters

  • data : &[T] - A data used for generate permutation.
  • result : Rc<RefCell<&mut [&T]>> - A result container. It'll be overwritten on each call to next
  • t : FnMut(&[&T]) - A function that if return true, will make algorithm continue traversing the tree. Otherwise, the entire branch will be skip.

Trait Implementations

impl<'a, F, T> ExactSizeIterator for XPermutationRefIter<'a, F, T> where
    F: FnMut(&[&T]) -> bool,
    T: 'a, 
[src]

impl<'a, F, T> Iterator for XPermutationRefIter<'a, F, T> where
    F: FnMut(&[&T]) -> bool,
    T: 'a, 
[src]

type Item = ()

The type of the elements being iterated over.

impl<'a, F, T> IteratorReset for XPermutationRefIter<'a, F, T> where
    F: FnMut(&[&T]) -> bool,
    T: 'a, 
[src]

Auto Trait Implementations

impl<'a, F, T> RefUnwindSafe for XPermutationRefIter<'a, F, T> where
    F: RefUnwindSafe,
    T: RefUnwindSafe

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

impl<'a, F, T> Sync for XPermutationRefIter<'a, F, T> where
    F: Sync,
    T: Sync

impl<'a, F, T> Unpin for XPermutationRefIter<'a, F, T> where
    F: Unpin

impl<'a, F, T> !UnwindSafe for XPermutationRefIter<'a, F, 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.