pub fn basin_size(&self, index: (isize, isize)) -> u32 {
        if !self.is_low_point(index) {
            return 0;
        }
        let (a, b) = index;
        let mut size = 1;
        let mut visited = HashSet::new();
        let curr_val = self[index];
        visited.insert(index);
        let mut to_visit = VecDeque::from(vec![
            (curr_val, (a, b - 1)),
            (curr_val, (a, b + 1)),
            (curr_val, (a - 1, b)),
            (curr_val, (a + 1, b)),
        ]);
        while !to_visit.is_empty() {
            let current = to_visit.pop_front().unwrap();
            let (v, curr_pos) = current;
            let (a, b) = curr_pos;
            let curr_val = self[curr_pos];

            if visited.contains(&curr_pos) || v >= curr_val || curr_val >= b'9' {
                continue;
            };
            visited.insert(curr_pos);
            size += 1;
            to_visit.push_back((curr_val, (a, b - 1)));
            to_visit.push_back((curr_val, (a, b + 1)));
            to_visit.push_back((curr_val, (a - 1, b)));
            to_visit.push_back((curr_val, (a + 1, b)));
        }
        size
    }
/// Returns 0 if not a low point, size of the basin otherwise
Returns 0 if not a low point, size of the basin otherwise
Returns 0 if not a low point size of the basin otherwise
pub fn basin_size(&self, index: (isize, isize)) -> u32 {
        if !self.is_low_point(index) {
            return 0;
        }
        let (a, b) = index;
        let mut size = 1;
        let mut visited = HashSet::new();
        let curr_val = self[index];
        visited.insert(index);
        let mut to_visit = VecDeque::from(vec![
            (curr_val, (a, b - 1)),
            (curr_val, (a, b + 1)),
            (curr_val, (a - 1, b)),
            (curr_val, (a + 1, b)),
        ]);
        while !to_visit.is_empty() {
            let current = to_visit.pop_front().unwrap();
            let (v, curr_pos) = current;
            let (a, b) = curr_pos;
            let curr_val = self[curr_pos];
            if visited.contains(&curr_pos) || v >= curr_val || curr_val >= b'9' {
                continue;
            };
            visited.insert(curr_pos);
            size += 1;
            to_visit.push_back((curr_val, (a, b - 1)));
            to_visit.push_back((curr_val, (a, b + 1)));
            to_visit.push_back((curr_val, (a - 1, b)));
            to_visit.push_back((curr_val, (a + 1, b)));
        }
        size
    }
pub fn basin_size ( & self , index : ( isize , isize ) ) -> u32 { if ! self . is_low_point ( index ) { return 0 ; } let ( a , b ) = index ; let mut size = 1 ; let mut visited = HashSet :: new ( ) ; let curr_val = self [ index ] ; visited . insert ( index ) ; let mut to_visit = VecDeque :: from ( vec ! [ ( curr_val ( a b 1 ) ) ( curr_val ( a b 1 ) ) ( curr_val ( a 1 b ) ) ( curr_val ( a 1 b ) ) ] ) ; while ! to_visit . is_empty ( ) { let current = to_visit . pop_front ( ) . unwrap ( ) ; let ( v , curr_pos ) = current ; let ( a , b ) = curr_pos ; let curr_val = self [ curr_pos ] ; if visited . contains ( & curr_pos ) || v >= curr_val || curr_val >= b'9' { continue ; } ; visited . insert ( curr_pos ) ; size += 1 ; to_visit . push_back ( ( curr_val , ( a , b - 1 ) ) ) ; to_visit . push_back ( ( curr_val , ( a , b + 1 ) ) ) ; to_visit . push_back ( ( curr_val , ( a - 1 , b ) ) ) ; to_visit . push_back ( ( curr_val , ( a + 1 , b ) ) ) ; } size }
Returns 0 if not a low point, size of the basin otherwise
Returns 0 if not a low point size of the basin otherwise
&self
index
(isize, isize)