pub fn as_cycles(&self) -> Cycles {
        let mut factors = BTreeSet::new();
        let size = self.word.len();
        let mut visited = vec![false; size];

        for pos in 0..size {
            if !visited[pos] {
                let mut image = self.word[pos];

                if image > pos {
                    let mut cycle = vec![pos];
                    let mut ndx = 0;
                    let mut max_ndx = 0;

                    visited[image] = true;

                    loop {
                        cycle.push(image);

                        ndx += 1;
                        if image > cycle[max_ndx] {
                            max_ndx = ndx;
                        }

                        image = self.word[image];

                        match image.cmp(&pos) {
                            Ordering::Greater => visited[image] = true,
                            Ordering::Equal => break,
                            Ordering::Less => {}
                        }
                    }

                    if max_ndx > 0 {
                        cycle.rotate_left(max_ndx);
                    }

                    factors.insert(cycle);
                }
            }
        }

        Cycles { factors: factors.into_iter().collect(), size: self.word.len() }
    }
/// Decompose this permutation into cycles.
///
/// The cycles are stored according to the standard representation
/// (they are canonically ordered).
Decompose this permutation into cycles.
The cycles are stored according to the standard representation
(they are canonically ordered).
Decompose this permutation into cycles . The cycles are stored according to the standard representation ( they are canonically ordered ) .
pub fn as_cycles(&self) -> Cycles {
        let mut factors = BTreeSet::new();
        let size = self.word.len();
        let mut visited = vec![false; size];
        for pos in 0..size {
            if !visited[pos] {
                let mut image = self.word[pos];
                if image > pos {
                    let mut cycle = vec![pos];
                    let mut ndx = 0;
                    let mut max_ndx = 0;
                    visited[image] = true;
                    loop {
                        cycle.push(image);
                        ndx += 1;
                        if image > cycle[max_ndx] {
                            max_ndx = ndx;
                        }
                        image = self.word[image];
                        match image.cmp(&pos) {
                            Ordering::Greater => visited[image] = true,
                            Ordering::Equal => break,
                            Ordering::Less => {}
                        }
                    }
                    if max_ndx > 0 {
                        cycle.rotate_left(max_ndx);
                    }
                    factors.insert(cycle);
                }
            }
        }
        Cycles { factors: factors.into_iter().collect(), size: self.word.len() }
    }
pub fn as_cycles ( & self ) -> Cycles { let mut factors = BTreeSet :: new ( ) ; let size = self . word . len ( ) ; let mut visited = vec ! [ false size ] ; for pos in 0 .. size { if ! visited [ pos ] { let mut image = self . word [ pos ] ; if image > pos { let mut cycle = vec ! [ pos ] ; let mut ndx = 0 ; let mut max_ndx = 0 ; visited [ image ] = true ; loop { cycle . push ( image ) ; ndx += 1 ; if image > cycle [ max_ndx ] { max_ndx = ndx ; } image = self . word [ image ] ; match image . cmp ( & pos ) { Ordering :: Greater => visited [ image ] = true , Ordering :: Equal => break , Ordering :: Less => { } } } if max_ndx > 0 { cycle . rotate_left ( max_ndx ) ; } factors . insert ( cycle ) ; } } } Cycles { factors : factors . into_iter ( ) . collect ( ) , size : self . word . len ( ) } }
Decompose this permutation into cycles.
Decompose this permutation into cycles .
&self
&self