pub fn retain<F>(&mut self, mut f: F)
    where
        F: FnMut(&A::Item) -> bool,
    {
        let len = self.len();
        let mut del = 0;
        for i in 0..len {
            if !f(&self[i]) {
                del += 1;
            } else if del > 0 {
                self.swap(i - del, i);
            }
        }
        if del > 0 {
            for _ in (len - del)..self.len() {
                self.pop_back();
            }
        }
    }
/// Retains only the elements specified by the predicate.
///
/// In other words, remove all elements `e` such that `f(&e)` returns false.
/// This method operates in place and preserves the order of the retained
/// elements.
///
/// # Examples
///
/// ```
/// use arraydeque::ArrayDeque;
///
/// let mut buf: ArrayDeque<[_; 4]> = ArrayDeque::new();
///
/// buf.extend_back(0..4);
/// buf.retain(|&x| x % 2 == 0);
///
/// assert_eq!(buf, vec![0, 2].into());
/// ```
Retains only the elements specified by the predicate.
In other words, remove all elements `e` such that `f(&e)` returns false.
This method operates in place and preserves the order of the retained
elements.
Retains only the elements specified by the predicate . In other words remove all elements ` e ` such that ` f ( &e ) ` returns false . This method operates in place and preserves the order of the retained elements .
pub fn retain<F>(&mut self, mut f: F)
    where
        F: FnMut(&A::Item) -> bool,
    {
        let len = self.len();
        let mut del = 0;
        for i in 0..len {
            if !f(&self[i]) {
                del += 1;
            } else if del > 0 {
                self.swap(i - del, i);
            }
        }
        if del > 0 {
            for _ in (len - del)..self.len() {
                self.pop_back();
            }
        }
    }
pub fn retain < F > ( & mut self , mut f : F ) where F : FnMut ( & A :: Item ) -> bool , { let len = self . len ( ) ; let mut del = 0 ; for i in 0 .. len { if ! f ( & self [ i ] ) { del += 1 ; } else if del > 0 { self . swap ( i - del , i ) ; } } if del > 0 { for _ in ( len - del ) .. self . len ( ) { self . pop_back ( ) ; } } }
Retains only the elements specified by the predicate.
Retains only the elements specified by the predicate .
&mut self
f
F
examples
```
use arraydeque::ArrayDeque.

let mut buf: ArrayDeque<[_; 4]> = ArrayDeque::new().




` ` ` use arraydeque :: ArrayDeque . let mut buf : ArrayDeque< [ _ ; 4 ] > = ArrayDeque :: new () .