Struct collections::slice::ElementSwapsExperimental [-]  [+] [src]

pub struct ElementSwaps {
    // some fields omitted
}

An iterator that yields the element swaps needed to produce a sequence of all possible permutations for an indexed sequence of elements. Each permutation is only a single swap apart.

The Steinhaus-Johnson-Trotter algorithm is used.

Generates even and odd permutations alternately.

The last generated swap is always (0, 1), and it returns the sequence to its initial order.

Methods

impl ElementSwaps

fn new(length: uint) -> ElementSwaps

Creates an ElementSwaps iterator for a sequence of length elements.

Trait Implementations

impl Iterator<(uint, uint)> for ElementSwaps

fn next(&mut self) -> Option<(uint, uint)>

fn size_hint(&self) -> (uint, Option<uint>)

Derived Implementations

impl Clone for ElementSwaps

fn clone(&self) -> ElementSwaps

fn clone_from(&mut self, source: &Self)