pub fn retain<Predicate>(&mut self, mut predicate: Predicate)
    where
        Predicate: FnMut(&mut EntryData) -> bool,
    {
        let mut next_index = self.head();

        while let Some(index) = next_index {
            let entry = &mut self.entries[index].occupied_mut();
            next_index = entry.next;

            if !predicate(&mut entry.value) {
                self.remove_entry(index);
            }
        }
    }
/// Removes all elements from the list not satisfying the given predicate.
///
/// Complexity: O(n)
///
/// # Examples
///
/// ```
/// use dlv_list::VecList;
///
/// let mut list = VecList::new();
/// list.push_back(0);
/// list.push_back(-1);
/// list.push_back(1);
/// list.push_back(-2);
/// list.retain(|&mut value| value >= 0);
///
/// let mut iter = list.iter();
/// assert_eq!(iter.next(), Some(&0));
/// assert_eq!(iter.next(), Some(&1));
/// assert_eq!(iter.next(), None);
/// ```
Removes all elements from the list not satisfying the given predicate.
Removes all elements from the list not satisfying the given predicate .
pub fn retain<Predicate>(&mut self, mut predicate: Predicate)
    where
        Predicate: FnMut(&mut EntryData) -> bool,
    {
        let mut next_index = self.head();
        while let Some(index) = next_index {
            let entry = &mut self.entries[index].occupied_mut();
            next_index = entry.next;
            if !predicate(&mut entry.value) {
                self.remove_entry(index);
            }
        }
    }
pub fn retain < Predicate > ( & mut self , mut predicate : Predicate ) where Predicate : FnMut ( & mut EntryData ) -> bool , { let mut next_index = self . head ( ) ; while let Some ( index ) = next_index { let entry = & mut self . entries [ index ] . occupied_mut ( ) ; next_index = entry . next ; if ! predicate ( & mut entry . value ) { self . remove_entry ( index ) ; } } }
Removes all elements from the list not satisfying the given predicate.
Removes all elements from the list not satisfying the given predicate .
&mut self
predicate
Predicate
&mut self
predicate
Predicate
examples
```
use dlv_list::VecList.




` ` ` use dlv_list :: VecList .