Struct sum_queue::QueueStats [−][src]
pub struct QueueStats<T: Ord + Add<Output = T>> { pub min: Option<T>, pub max: Option<T>, pub sum: Option<T>, pub len: usize, }
Stats of the queue.
It provides the following statistics: min and max value in the queue, the sum of all the values and the length of all elements hold in the queue.
The values are computed taking into account only the existent elements in the queue, and not past elements removed because expiration or because they were removed.
You can get the stats object calling to
the SumQueue::stats()
method of the queue:
use sum_queue::SumQueue; let mut queue = SumQueue::new(1000); queue.push(-1); queue.push(5); queue.push(2); let stats = queue.stats(); assert_eq!(stats.min, Some(-1)); assert_eq!(stats.max, Some(5)); assert_eq!(stats.sum, Some(6)); assert_eq!(stats.len, 3);
But you can also get the stats while pushing elements, which it’s more effecient than push and then get the stats:
use sum_queue::SumQueue; let mut queue = SumQueue::new(1000); queue.push(-1); queue.push(5); let stats = queue.push_and_stats(2); assert_eq!(stats.min, Some(-1)); assert_eq!(stats.max, Some(5)); assert_eq!(stats.sum, Some(6)); assert_eq!(stats.len, 3);
Fields
min: Option<T>
min value of the queue
max: Option<T>
max value of the queue
sum: Option<T>
sum of all the values in the queue
len: usize
size of the queue, same than SumQueue::len()
Auto Trait Implementations
impl<T> RefUnwindSafe for QueueStats<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for QueueStats<T> where
T: Send,
T: Send,
impl<T> Sync for QueueStats<T> where
T: Sync,
T: Sync,
impl<T> Unpin for QueueStats<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for QueueStats<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,