pub fn try_add(&mut self, value: f64, count: f64) -> Result<()> {
        ensure_argument!(
            value.is_finite(),
            "inserted value must be finite, but get {}",
            value
        );
        ensure_argument!(
            count.is_finite() && !count.is_sign_negative(),
            "inserted count must be finite and non-negative, but get {}",
            count
        );
        ensure_argument!(
            self.bucket_limit.len() == self.bucket.len(),
            "the lengths of bucket_limit and bucket fields must be equal"
        );

        let index = match self
            .bucket_limit
            .binary_search_by_key(&r64(value), |&limit| r64(limit))
        {
            Ok(index) => index,
            Err(index) => index,
        };

        if index < self.bucket_limit.len() {
            self.bucket[index] += count;
            self.num += 1.0;
            self.sum += value;
            self.sum_squares += value.powi(2);
            self.min = cmp::min(r64(self.min), r64(value)).raw();
            self.max = cmp::max(r64(self.max), r64(value)).raw();
        }

        Ok(())
    }
/// Add counts to the bucket containing the value.
///
/// `value` must be finite, and `count` must be finite and non-negative.
/// Otherwise it returns an error.
Add counts to the bucket containing the value.
`value` must be finite, and `count` must be finite and non-negative.
Otherwise it returns an error.
Add counts to the bucket containing the value . ` value ` must be finite and ` count ` must be finite and non - negative . Otherwise it returns an error .
pub fn try_add(&mut self, value: f64, count: f64) -> Result<()> {
        ensure_argument!(
            value.is_finite(),
            "inserted value must be finite, but get {}",
            value
        );
        ensure_argument!(
            count.is_finite() && !count.is_sign_negative(),
            "inserted count must be finite and non-negative, but get {}",
            count
        );
        ensure_argument!(
            self.bucket_limit.len() == self.bucket.len(),
            "the lengths of bucket_limit and bucket fields must be equal"
        );
        let index = match self
            .bucket_limit
            .binary_search_by_key(&r64(value), |&limit| r64(limit))
        {
            Ok(index) => index,
            Err(index) => index,
        };
        if index < self.bucket_limit.len() {
            self.bucket[index] += count;
            self.num += 1.0;
            self.sum += value;
            self.sum_squares += value.powi(2);
            self.min = cmp::min(r64(self.min), r64(value)).raw();
            self.max = cmp::max(r64(self.max), r64(value)).raw();
        }
        Ok(())
    }
pub fn try_add ( & mut self , value : f64 , count : f64 ) -> Result < ( ) > { ensure_argument ! ( value is_finite ( ) " " value ) ; ensure_argument ! ( count is_finite ( ) count is_sign_negative ( ) " " count ) ; ensure_argument ! ( self bucket_limit len ( ) self bucket len ( ) " " ) ; let index = match self . bucket_limit . binary_search_by_key ( & r64 ( value ) , | & limit | r64 ( limit ) ) { Ok ( index ) => index , Err ( index ) => index , } ; if index < self . bucket_limit . len ( ) { self . bucket [ index ] += count ; self . num += 1.0 ; self . sum += value ; self . sum_squares += value . powi ( 2 ) ; self . min = cmp :: min ( r64 ( self . min ) , r64 ( value ) ) . raw ( ) ; self . max = cmp :: max ( r64 ( self . max ) , r64 ( value ) ) . raw ( ) ; } Ok ( ( ) ) }
Add counts to the bucket containing the value.
Add counts to the bucket containing the value .
&mut self
value
f64
count
f64
&mut self
value
f64
count
f64