pub fn retain<F>(&mut self, mut condition: F)
    where
        F: FnMut(usize, usize, &T) -> bool,
    {
        let (mut k, mut major) = (0, 0);
        while k < self.indices.len() {
            while self.offsets[major + 1] <= k {
                major += 1;
            }
            let condition = match self.variant {
                Variant::Column => condition(self.indices[k], major, &self.values[k]),
                Variant::Row => condition(major, self.indices[k], &self.values[k]),
            };
            if condition {
                k += 1;
                continue;
            }
            self.nonzeros -= 1;
            self.values.remove(k);
            self.indices.remove(k);
            for offset in &mut self.offsets[(major + 1)..] {
                *offset -= 1;
            }
        }
    }
/// Retain the elements that satisfy a condition and discard the rest.
Retain the elements that satisfy a condition and discard the rest.
Retain the elements that satisfy a condition and discard the rest .
pub fn retain<F>(&mut self, mut condition: F)
    where
        F: FnMut(usize, usize, &T) -> bool,
    {
        let (mut k, mut major) = (0, 0);
        while k < self.indices.len() {
            while self.offsets[major + 1] <= k {
                major += 1;
            }
            let condition = match self.variant {
                Variant::Column => condition(self.indices[k], major, &self.values[k]),
                Variant::Row => condition(major, self.indices[k], &self.values[k]),
            };
            if condition {
                k += 1;
                continue;
            }
            self.nonzeros -= 1;
            self.values.remove(k);
            self.indices.remove(k);
            for offset in &mut self.offsets[(major + 1)..] {
                *offset -= 1;
            }
        }
    }
pub fn retain < F > ( & mut self , mut condition : F ) where F : FnMut ( usize , usize , & T ) -> bool , { let ( mut k , mut major ) = ( 0 , 0 ) ; while k < self . indices . len ( ) { while self . offsets [ major + 1 ] <= k { major += 1 ; } let condition = match self . variant { Variant :: Column => condition ( self . indices [ k ] , major , & self . values [ k ] ) , Variant :: Row => condition ( major , self . indices [ k ] , & self . values [ k ] ) , } ; if condition { k += 1 ; continue ; } self . nonzeros -= 1 ; self . values . remove ( k ) ; self . indices . remove ( k ) ; for offset in & mut self . offsets [ ( major + 1 ) .. ] { * offset -= 1 ; } } }
Retain the elements that satisfy a condition and discard the rest.
Retain the elements that satisfy a condition and discard the rest .
&mut self
condition
F
&mut self
condition
F