/// Clear the contents of the comb vector and insert the next combination.
Clear the contents of the comb vector and insert the next combination.
Clear the contents of the comb vector and insert the next combination .
fn next_combination(&mut self, mut comb: &mut Vec<T>) -> bool {
        if !self.started {
            // first pass throught
            self.started = true;
            self.insert(&mut comb);
            true
        } else {
            let org_len = self.original.len();
            // check if we cant bump the back number
            if self.original[self.possition[self.len - 1]] == self.original[org_len - 1] {
                // locate the number closest behind that needs to be bumped
                for i in 2..=self.len {
                    if self.original[self.possition[self.len - i]] < self.original[org_len - i] {
                        //find the value of the
                        let lastpos = self.possition[self.len - i];
                        let val = &self.original[lastpos];
                        for j in lastpos + 1..org_len {
                            if *val < self.original[j] {
                                for k in 0..i {
                                    self.possition[self.len - i + k] = j + k;
                                }
                                self.insert(&mut comb);
                                return true;
                            }
                        }
                    }
                }
                false
            } else {
                let mut i = self.possition[self.len - 1];
                let current = &self.original[i];
                let mut next = current;
                while current == next {
                    i += 1;
                    next = &self.original[i];
                }
                self.possition[self.len - 1] = i;
                self.insert(&mut comb);
                true
            }
        }
    }
fn next_combination ( & mut self , mut comb : & mut Vec < T > ) -> bool { if ! self . started { // first pass throught self . started = true ; self . insert ( & mut comb ) ; true } else { let org_len = self . original . len ( ) ; // check if we cant bump the back number if self . original [ self . possition [ self . len - 1 ] ] == self . original [ org_len - 1 ] { // locate the number closest behind that needs to be bumped for i in 2 ..= self . len { if self . original [ self . possition [ self . len - i ] ] < self . original [ org_len - i ] { //find the value of the let lastpos = self . possition [ self . len - i ] ; let val = & self . original [ lastpos ] ; for j in lastpos + 1 .. org_len { if * val < self . original [ j ] { for k in 0 .. i { self . possition [ self . len - i + k ] = j + k ; } self . insert ( & mut comb ) ; return true ; } } } } false } else { let mut i = self . possition [ self . len - 1 ] ; let current = & self . original [ i ] ; let mut next = current ; while current == next { i += 1 ; next = & self . original [ i ] ; } self . possition [ self . len - 1 ] = i ; self . insert ( & mut comb ) ; true } } }
Clear the contents of the comb vector and insert the next combination.
Clear the contents of the comb vector and insert the next combination .
&mut self
comb
&mut Vec<T>