pub fn insert(&mut self, id: usize, x: &[f64]) -> Result<(), StrError> {
        // check
        if x.len() != self.ndim {
            return Err("x.len() must equal ndim");
        }

        // add point to container
        let index = match self.container_index(x) {
            Some(i) => i,
            None => return Err("cannot insert point outside the grid"),
        };
        self.update_or_insert(index, id, x);

        // add point to containers touched by halo corners
        self.set_halo(x);
        let mut tmp = vec![0.0; self.ndim];
        for c in 0..self.ncorner {
            tmp.copy_from_slice(&self.halo[c][0..self.ndim]);
            if let Some(index_corner) = self.container_index(&tmp) {
                if index_corner != index {
                    self.update_or_insert(index_corner, id, x); // make sure to use original `x`
                }
            }
        }
        Ok(())
    }
/// Inserts a new item to the right container in the grid
///
/// # Input
///
/// * `id` -- identification number for the item
/// * `x` -- coordinates (ndim) of the item
Inserts a new item to the right container in the grid
Inserts a new item to the right container in the grid
pub fn insert(&mut self, id: usize, x: &[f64]) -> Result<(), StrError> {
        // check
        if x.len() != self.ndim {
            return Err("x.len() must equal ndim");
        }
        // add point to container
        let index = match self.container_index(x) {
            Some(i) => i,
            None => return Err("cannot insert point outside the grid"),
        };
        self.update_or_insert(index, id, x);
        // add point to containers touched by halo corners
        self.set_halo(x);
        let mut tmp = vec![0.0; self.ndim];
        for c in 0..self.ncorner {
            tmp.copy_from_slice(&self.halo[c][0..self.ndim]);
            if let Some(index_corner) = self.container_index(&tmp) {
                if index_corner != index {
                    self.update_or_insert(index_corner, id, x); // make sure to use original `x`
                }
            }
        }
        Ok(())
    }
pub fn insert ( & mut self , id : usize , x : & [ f64 ] ) -> Result < ( ) , StrError > { // check if x . len ( ) != self . ndim { return Err ( " " ) ; } // add point to container let index = match self . container_index ( x ) { Some ( i ) => i , None => return Err ( " " ) , } ; self . update_or_insert ( index , id , x ) ; // add point to containers touched by halo corners self . set_halo ( x ) ; let mut tmp = vec ! [ 0.0 self ndim ] ; for c in 0 .. self . ncorner { tmp . copy_from_slice ( & self . halo [ c ] [ 0 .. self . ndim ] ) ; if let Some ( index_corner ) = self . container_index ( & tmp ) { if index_corner != index { self . update_or_insert ( index_corner , id , x ) ; // make sure to use original `x` } } } Ok ( ( ) ) }
Inserts a new item to the right container in the grid
Inserts a new item to the right container in the grid
&mut self
id
usize
x
&[f64]
&mut self
id
usize
x
&[f64]
input
`id` -- identification number for the item
`x` -- coordinates (ndim) of the item
` id ` -- identification number for the item ` x ` -- coordinates ( ndim ) of the item