pub fn heap_step(&mut self, stack: &mut [usize]) -> bool {
        debug_assert!(stack.len() >= self.word.len());

        let mut pos = 0;

        while pos < self.word.len() {
            let s = stack[pos];

            if s < pos {
                if pos % 2 == 0 {
                    self.word.swap(0, pos);
                } else {
                    self.word.swap(s, pos);
                }

                stack[pos] += 1;

                return true
            } else {
                stack[pos] = 0;
                pos += 1;
            }
        }

        false
    }
/// Performs a single step of Heap's (minimal change) iteration.
///
/// Returns `true` after applying a single transposition, or
/// `false` if none of `stack` elements is less than its index
/// (end of iteration).  In order to traverse _S<sub>n</sub>_,
/// start from any _n_-element `Permutation`, initialize `stack`
/// with _n_ zeros and repeatedly call `heap_step()` until the
/// returned value is `false`.
Performs a single step of Heap's (minimal change) iteration.
Performs a single step of Heap ' s ( minimal change ) iteration .
pub fn heap_step(&mut self, stack: &mut [usize]) -> bool {
        debug_assert!(stack.len() >= self.word.len());
        let mut pos = 0;
        while pos < self.word.len() {
            let s = stack[pos];
            if s < pos {
                if pos % 2 == 0 {
                    self.word.swap(0, pos);
                } else {
                    self.word.swap(s, pos);
                }
                stack[pos] += 1;
                return true
            } else {
                stack[pos] = 0;
                pos += 1;
            }
        }
        false
    }
pub fn heap_step ( & mut self , stack : & mut [ usize ] ) -> bool { debug_assert ! ( stack len ( ) self word len ( ) ) ; let mut pos = 0 ; while pos < self . word . len ( ) { let s = stack [ pos ] ; if s < pos { if pos % 2 == 0 { self . word . swap ( 0 , pos ) ; } else { self . word . swap ( s , pos ) ; } stack [ pos ] += 1 ; return true } else { stack [ pos ] = 0 ; pos += 1 ; } } false }
Performs a single step of Heap's (minimal change) iteration.
Performs a single step of Heap ' s ( minimal change ) iteration .
&mut self
stack
&mut [usize]
&mut self
stack
&mut [usize]