Struct std::vec::ElementSwaps

pub struct ElementSwaps {
    priv sdir: ~[SizeDirection],
    priv emit_reset: bool,
}

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

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

Create an ElementSwaps iterator for a sequence of length elements

Trait Implementations

impl Iterator<(uint, uint)> for ElementSwaps

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

Advance the iterator and return the next value. Return None when the end is reached.