diff options
author | Daniel Schadt <kingdread@gmx.de> | 2018-06-13 13:17:28 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2018-06-13 13:17:28 +0200 |
commit | 2fe671951369b8f049e8acf02e9e9750c96b4dcd (patch) | |
tree | 49e9c0cc4bcbf6d76183555ac95bc3d9504c7a05 /src/statistics | |
parent | fe16699205b6b40aed8cafbe95820835a7052908 (diff) | |
download | evtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.tar.gz evtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.tar.bz2 evtclib-2fe671951369b8f049e8acf02e9e9750c96b4dcd.zip |
clean up a bit
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/damage.rs | 2 | ||||
-rw-r--r-- | src/statistics/math.rs | 7 | ||||
-rw-r--r-- | src/statistics/trackers.rs | 17 |
3 files changed, 7 insertions, 19 deletions
diff --git a/src/statistics/damage.rs b/src/statistics/damage.rs index fdf723f..0fcbf9b 100644 --- a/src/statistics/damage.rs +++ b/src/statistics/damage.rs @@ -36,7 +36,7 @@ impl Monoid for Damage { } /// Provides access to the damage log. -#[derive(Clone)] +#[derive(Clone, Default)] pub struct DamageLog { inner: RecordFunc<u64, Meta, Damage>, } diff --git a/src/statistics/math.rs b/src/statistics/math.rs index 3760ca3..6e7e666 100644 --- a/src/statistics/math.rs +++ b/src/statistics/math.rs @@ -45,7 +45,7 @@ struct Record<X, T, D> { /// * `T` tag for each data point. Can be arbitrary. /// * `D` actual data. Must be [`Monoid`](trait.Monoid.html), so that it can be /// summed up. -#[derive(Clone)] +#[derive(Clone, Default)] pub struct RecordFunc<X, T, D> { data: Vec<Record<X, T, D>>, } @@ -84,6 +84,11 @@ where self.data.len() } + /// Check whether there are no records. + pub fn is_emtpy(&self) -> bool { + self.data.is_empty() + } + /// Get the absolute value at the specific point. #[inline] pub fn get(&self, x: &X) -> D { diff --git a/src/statistics/trackers.rs b/src/statistics/trackers.rs index ce87f3d..11e51f2 100644 --- a/src/statistics/trackers.rs +++ b/src/statistics/trackers.rs @@ -18,26 +18,12 @@ //! trackers on the same log. use std::collections::HashMap; use std::error::Error; -use std::hash::Hash; use super::super::{Event, EventKind, Log}; use super::boon::BoonQueue; use super::damage::{DamageLog, DamageType}; use super::gamedata::{self, Mechanic, Trigger}; -// A support macro to introduce a new block. -// -// Doesn't really require a macro, but it's nicer to look at -// with! { foo = bar } -// rather than -// { let foo = bar; ... } -macro_rules! with { - ($name:ident = $expr:expr => $bl:block) => {{ - let $name = $expr; - $bl - }}; -} - /// A tracker. /// /// A tracker should be responsible for tracking a single statistic. Each @@ -322,9 +308,6 @@ impl Tracker for BoonTracker { type Error = !; fn feed(&mut self, event: &Event) -> Result<(), Self::Error> { - if event.kind.destination_agent_addr() != Some(self.agent_addr) { - return Ok(()); - } let delta_t = event.time - self.last_time; if self.next_update != 0 && delta_t > self.next_update { |