hdrhistogram/iterators/
all.rs
1use crate::core::counter::Counter;
2use crate::iterators::{HistogramIterator, PickMetadata, PickyIterator};
3use crate::Histogram;
4
5pub struct Iter {
7 visited: Option<usize>,
8}
9
10impl Iter {
11 pub fn new<T: Counter>(hist: &Histogram<T>) -> HistogramIterator<T, Iter> {
13 HistogramIterator::new(hist, Iter { visited: None })
14 }
15}
16
17impl<T: Counter> PickyIterator<T> for Iter {
18 fn pick(&mut self, index: usize, _: u64, _: T) -> Option<PickMetadata> {
19 if self.visited.map(|i| i != index).unwrap_or(true) {
20 self.visited = Some(index);
22 Some(PickMetadata::new(None, None))
23 } else {
24 None
25 }
26 }
27
28 fn more(&mut self, _: usize) -> bool {
29 true
30 }
31}