pub fn maybe_insert(&mut self, id: usize, x: &[f64]) -> Result<usize, StrError> {
        if let Some(id) = self.find(x)? {
            return Ok(id);
        }
        self.insert(id, x)?;
        Ok(id)
    }
/// Inserts a new item if the coordinates are not found
///
/// # Input
///
/// * `id` -- identification number for the new item
/// * `x` -- coordinates (ndim) of the item
///
/// # Output
///
/// * Returns the id of the item; either found or given as input.
/// * Thus, if the output and input ids are different, it means that
///   the item exists already and the output id is the existing id.
///
/// # Note
///
/// This function is a combination of `find` and `insert`
Inserts a new item if the coordinates are not found
Inserts a new item if the coordinates are not found
pub fn maybe_insert(&mut self, id: usize, x: &[f64]) -> Result<usize, StrError> {
        if let Some(id) = self.find(x)? {
            return Ok(id);
        }
        self.insert(id, x)?;
        Ok(id)
    }
pub fn maybe_insert ( & mut self , id : usize , x : & [ f64 ] ) -> Result < usize , StrError > { if let Some ( id ) = self . find ( x ) ? { return Ok ( id ) ; } self . insert ( id , x ) ? ; Ok ( id ) }
Inserts a new item if the coordinates are not found
Inserts a new item if the coordinates are not found
&mut self
id
usize
x
&[f64]
&mut self
id
usize
x
&[f64]
input
`id` -- identification number for the new item
`x` -- coordinates (ndim) of the item
` id ` -- identification number for the new item ` x ` -- coordinates ( ndim ) of the item
output
Returns the id of the item; either found or given as input.
Thus, if the output and input ids are different, it means that
the item exists already and the output id is the existing id.
Returns the id of the item ; either found or given as input . Thus if the output and input ids are different it means that the item exists already and the output id is the existing id .
note
This function is a combination of `find` and `insert`
This function is a combination of ` find ` and ` insert `