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.
impl ElementSwaps
fn new(length: uint) -> ElementSwaps
Create an ElementSwaps
iterator for a sequence of length
elements
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.
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).