(&mut self)
| 825 | /// Removes and returns the last value of the sliding window. |
| 826 | #[inline] |
| 827 | pub fn pop(&mut self) -> Option<T> { |
| 828 | if self.pop_stack.is_empty() { |
| 829 | match self.push_stack.pop() { |
| 830 | Some((val, _)) => { |
| 831 | let mut last = (val.clone(), val); |
| 832 | self.pop_stack.push(last.clone()); |
| 833 | while let Some((val, _)) = self.push_stack.pop() { |
| 834 | let min = if last.1 < val { |
| 835 | last.1.clone() |
| 836 | } else { |
| 837 | val.clone() |
| 838 | }; |
| 839 | last = (val.clone(), min); |
| 840 | self.pop_stack.push(last.clone()); |
| 841 | } |
| 842 | } |
| 843 | None => return None, |
| 844 | } |
| 845 | } |
| 846 | self.pop_stack.pop().map(|(val, _)| val) |
| 847 | } |
| 848 | |
| 849 | /// Returns the number of elements stored in the sliding window. |
| 850 | #[inline] |
no test coverage detected