pub fn search(&self, x: f32, y: f32) -> Vec<(T, f32)> {
        let i = (x * self.inv_r).floor() as i32;
        let j = (y * self.inv_r).floor() as i32;

        let mut num_points = 0usize;
        for k in 0..25 {
            if let Some(vals) = self.hm.get(&[i + self.dx[k], j + self.dy[k]]) {
                num_points += vals.len();
            }
        }

        let mut ret = Vec::with_capacity(num_points);
        let mut dist: f32;
        for k in 0..25 {
            if let Some(vals) = self.hm.get(&[i + self.dx[k], j + self.dy[k]]) {
                for val in vals {
                    // calculate the squared distance to (x,y)
                    dist = (x - val.x) * (x - val.x) + (y - val.y) * (y - val.y);
                    if dist <= self.r_sqr {
                        if self.is_distance_squared {
                            ret.push((val.value, dist));
                        } else {
                            ret.push((val.value, dist.sqrt()));
                        }
                    }
                }
            }
        }

        ret
    }
/// Performs a fixed-radius search operation on point (x, y), returning a vector of data (type T), distance tuples.
Performs a fixed-radius search operation on point (x, y), returning a vector of data (type T), distance tuples.
Performs a fixed - radius search operation on point ( x y ) returning a vector of data ( type T ) distance tuples .
pub fn search(&self, x: f32, y: f32) -> Vec<(T, f32)> {
        let i = (x * self.inv_r).floor() as i32;
        let j = (y * self.inv_r).floor() as i32;
        let mut num_points = 0usize;
        for k in 0..25 {
            if let Some(vals) = self.hm.get(&[i + self.dx[k], j + self.dy[k]]) {
                num_points += vals.len();
            }
        }
        let mut ret = Vec::with_capacity(num_points);
        let mut dist: f32;
        for k in 0..25 {
            if let Some(vals) = self.hm.get(&[i + self.dx[k], j + self.dy[k]]) {
                for val in vals {
                    // calculate the squared distance to (x,y)
                    dist = (x - val.x) * (x - val.x) + (y - val.y) * (y - val.y);
                    if dist <= self.r_sqr {
                        if self.is_distance_squared {
                            ret.push((val.value, dist));
                        } else {
                            ret.push((val.value, dist.sqrt()));
                        }
                    }
                }
            }
        }
        ret
    }
pub fn search ( & self , x : f32 , y : f32 ) -> Vec < ( T , f32 ) > { let i = ( x * self . inv_r ) . floor ( ) as i32 ; let j = ( y * self . inv_r ) . floor ( ) as i32 ; let mut num_points = 0usize ; for k in 0 .. 25 { if let Some ( vals ) = self . hm . get ( & [ i + self . dx [ k ] , j + self . dy [ k ] ] ) { num_points += vals . len ( ) ; } } let mut ret = Vec :: with_capacity ( num_points ) ; let mut dist : f32 ; for k in 0 .. 25 { if let Some ( vals ) = self . hm . get ( & [ i + self . dx [ k ] , j + self . dy [ k ] ] ) { for val in vals { // calculate the squared distance to (x,y) dist = ( x - val . x ) * ( x - val . x ) + ( y - val . y ) * ( y - val . y ) ; if dist <= self . r_sqr { if self . is_distance_squared { ret . push ( ( val . value , dist ) ) ; } else { ret . push ( ( val . value , dist . sqrt ( ) ) ) ; } } } } } ret }
Performs a fixed-radius search operation on point (x, y), returning a vector of data (type T), distance tuples.
Performs a fixed - radius search operation on point ( x y ) returning a vector of data ( type T ) distance tuples .
&self
x
f32
y
f32
&self
x
f32
y
f32