fn tighten_bounds_v(&mut self) -> bool {
        let height = self.v_keys.len();
        let mut progress = false;
        for i in 0..height {
            let len = self.v_keys[i].len();
            let mut prev_bound;
            let mut next_bound;
            for j in 0..len {
                if j < len - 1 {
                    next_bound = self.v_keys[i][j + 1].upper_bound;
                } else {
                    next_bound = self.v_keys[i][j].lower_bound;
                }

                if j > 0 {
                    prev_bound = self.v_keys[i][j - 1].lower_bound;
                } else {
                    prev_bound = self.v_keys[i][j].upper_bound;
                }

                let key = &mut self.v_keys[i][j];
                let min_def = cmp::min(key.lower_bound, prev_bound);
                let max_def = cmp::max(key.upper_bound, next_bound);
                if min_def >= max_def {
                    continue;
                }
                if min_def < max_def {
                    for n in min_def..max_def {
                        if matches!(self.grid[i][n].cell_state, Status::Marked) {
                            let mut upper = 0;
                            if n >= key.value {
                                upper = n - key.value;
                            }
                            let lower = n + key.value;
                            if key.upper_bound < upper {
                                key.upper_bound = upper;
                                progress = true;
                            }
                            if key.lower_bound > lower && lower >= key.value {
                                key.lower_bound = lower;
                                progress = true;
                            }
                        }
                    }
                }
            }
        }
        progress
    }
//Further reduce key bounds if it contains a marked cell that is exclusive to the given bound
Further reduce key bounds if it contains a marked cell that is exclusive to the given bound
Further reduce key bounds if it contains a marked cell that is exclusive to the given bound
fn tighten_bounds_v(&mut self) -> bool {
        let height = self.v_keys.len();
        let mut progress = false;
        for i in 0..height {
            let len = self.v_keys[i].len();
            let mut prev_bound;
            let mut next_bound;
            for j in 0..len {
                if j < len - 1 {
                    next_bound = self.v_keys[i][j + 1].upper_bound;
                } else {
                    next_bound = self.v_keys[i][j].lower_bound;
                }
                if j > 0 {
                    prev_bound = self.v_keys[i][j - 1].lower_bound;
                } else {
                    prev_bound = self.v_keys[i][j].upper_bound;
                }
                let key = &mut self.v_keys[i][j];
                let min_def = cmp::min(key.lower_bound, prev_bound);
                let max_def = cmp::max(key.upper_bound, next_bound);
                if min_def >= max_def {
                    continue;
                }
                if min_def < max_def {
                    for n in min_def..max_def {
                        if matches!(self.grid[i][n].cell_state, Status::Marked) {
                            let mut upper = 0;
                            if n >= key.value {
                                upper = n - key.value;
                            }
                            let lower = n + key.value;
                            if key.upper_bound < upper {
                                key.upper_bound = upper;
                                progress = true;
                            }
                            if key.lower_bound > lower && lower >= key.value {
                                key.lower_bound = lower;
                                progress = true;
                            }
                        }
                    }
                }
            }
        }
        progress
    }
fn tighten_bounds_v ( & mut self ) -> bool { let height = self . v_keys . len ( ) ; let mut progress = false ; for i in 0 .. height { let len = self . v_keys [ i ] . len ( ) ; let mut prev_bound ; let mut next_bound ; for j in 0 .. len { if j < len - 1 { next_bound = self . v_keys [ i ] [ j + 1 ] . upper_bound ; } else { next_bound = self . v_keys [ i ] [ j ] . lower_bound ; } if j > 0 { prev_bound = self . v_keys [ i ] [ j - 1 ] . lower_bound ; } else { prev_bound = self . v_keys [ i ] [ j ] . upper_bound ; } let key = & mut self . v_keys [ i ] [ j ] ; let min_def = cmp :: min ( key . lower_bound , prev_bound ) ; let max_def = cmp :: max ( key . upper_bound , next_bound ) ; if min_def >= max_def { continue ; } if min_def < max_def { for n in min_def .. max_def { if matches ! ( self grid [ i ] [ n ] cell_state Status Marked ) { let mut upper = 0 ; if n >= key . value { upper = n - key . value ; } let lower = n + key . value ; if key . upper_bound < upper { key . upper_bound = upper ; progress = true ; } if key . lower_bound > lower && lower >= key . value { key . lower_bound = lower ; progress = true ; } } } } } } progress }
Further reduce key bounds if it contains a marked cell that is exclusive to the given bound
Further reduce key bounds if it contains a marked cell that is exclusive to the given bound
&mut self
&mut self