pub fn retain<F>(&mut self, mut f: F)
    where
        F: FnMut(usize, &mut T) -> bool,
    {
        use std::sync::atomic::{AtomicUsize, Ordering};
        // wrap the enclosure to deal with keys
        let offset = AtomicUsize::new(0);
        let mut wrapper = |key: usize, val: &mut T| -> bool { f(key + offset.load(Ordering::SeqCst), val) };
        for slab in self.slabs.iter_mut() {
            slab.retain(&mut wrapper);
            let capacity = if offset.load(Ordering::SeqCst) == 0 {
                self.primary_capacity
            } else {
                self.secondary_capacity
            };
            offset.fetch_add(capacity, Ordering::SeqCst);
        }
    }
/// Retain only the elements specified by the predicate.
///
/// In other words, remove all elements `e` such that `f(usize, &mut e)`
/// returns false. This method operates in place and preserves the key
/// associated with the retained values.
///
/// # Examples
///
/// ```
/// # use super_slab::*;
/// let mut slab = SuperSlab::with_capacity(2);
///
/// let k1 = slab.insert(0);
/// let k2 = slab.insert(1);
/// let k3 = slab.insert(2);
///
/// slab.retain(|key, val| key == k1 || *val == 1);
///
/// assert!(slab.contains(k1));
/// assert!(slab.contains(k2));
/// assert!(!slab.contains(k3));
///
/// assert_eq!(2, slab.len());
/// ```
Retain only the elements specified by the predicate.
In other words, remove all elements `e` such that `f(usize, &mut e)`
returns false. This method operates in place and preserves the key
associated with the retained values.
Retain only the elements specified by the predicate . In other words remove all elements ` e ` such that ` f ( usize &mut e ) ` returns false . This method operates in place and preserves the key associated with the retained values .
pub fn retain<F>(&mut self, mut f: F)
    where
        F: FnMut(usize, &mut T) -> bool,
    {
        use std::sync::atomic::{AtomicUsize, Ordering};
        // wrap the enclosure to deal with keys
        let offset = AtomicUsize::new(0);
        let mut wrapper = |key: usize, val: &mut T| -> bool { f(key + offset.load(Ordering::SeqCst), val) };
        for slab in self.slabs.iter_mut() {
            slab.retain(&mut wrapper);
            let capacity = if offset.load(Ordering::SeqCst) == 0 {
                self.primary_capacity
            } else {
                self.secondary_capacity
            };
            offset.fetch_add(capacity, Ordering::SeqCst);
        }
    }
pub fn retain < F > ( & mut self , mut f : F ) where F : FnMut ( usize , & mut T ) -> bool , { use std :: sync :: atomic :: { AtomicUsize , Ordering } ; // wrap the enclosure to deal with keys let offset = AtomicUsize :: new ( 0 ) ; let mut wrapper = | key : usize , val : & mut T | -> bool { f ( key + offset . load ( Ordering :: SeqCst ) , val ) } ; for slab in self . slabs . iter_mut ( ) { slab . retain ( & mut wrapper ) ; let capacity = if offset . load ( Ordering :: SeqCst ) == 0 { self . primary_capacity } else { self . secondary_capacity } ; offset . fetch_add ( capacity , Ordering :: SeqCst ) ; } }
Retain only the elements specified by the predicate.
Retain only the elements specified by the predicate .
&mut self
f
F
&mut self
f
F
examples
None
use super_slab::*;
let mut slab = SuperSlab::with_capacity(2).

let k1 = slab.insert(0);
let k2 = slab.insert(1);
let k3 = slab.insert(2).



assert!(slab.contains(k1));
assert!(slab.contains(k2));
assert!(!slab.contains(k3)).


let mut slab = SuperSlab :: with_capacity ( 2 ) . let k1 = slab . insert ( 0 ) ; let k2 = slab . insert ( 1 ) ; let k3 = slab . insert ( 2 ) . assert! ( slab . contains ( k1 )) ; assert! ( slab . contains ( k2 )) ; assert! ( !slab . contains ( k3 )) .