pub struct BelowExSet { /* private fields */ }Implementations§
Source§impl BelowExSet
impl BelowExSet
Sourcepub fn from<I: IntoIterator<Item = u64>>(max: u64, iter: I) -> Self
pub fn from<I: IntoIterator<Item = u64>>(max: u64, iter: I) -> Self
Creates a new instance from the highest event, and a sequence of exceptions.
§Examples
use threshold::*;
let below_exset = BelowExSet::from(5, vec![1, 3]);
assert!(!below_exset.is_event(1));
assert!(below_exset.is_event(2));
assert!(!below_exset.is_event(3));
assert!(below_exset.is_event(4));
assert!(below_exset.is_event(5));
assert!(!below_exset.is_event(6));Trait Implementations§
Source§impl Clone for BelowExSet
impl Clone for BelowExSet
Source§fn clone(&self) -> BelowExSet
fn clone(&self) -> BelowExSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BelowExSet
impl Debug for BelowExSet
Source§impl Default for BelowExSet
impl Default for BelowExSet
Source§fn default() -> BelowExSet
fn default() -> BelowExSet
Source§impl<'de> Deserialize<'de> for BelowExSet
impl<'de> Deserialize<'de> for BelowExSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl EventSet for BelowExSet
impl EventSet for BelowExSet
Source§fn next_event(&mut self) -> u64
fn next_event(&mut self) -> u64
Generates the next event. There should be no exceptions when calling this.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
assert_eq!(below_exset.next_event(), 1);
assert_eq!(below_exset.next_event(), 2);Source§fn add_event(&mut self, event: u64) -> bool
fn add_event(&mut self, event: u64) -> bool
Adds an event to the set.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
below_exset.add_event(1);
assert!(below_exset.is_event(1));
assert!(!below_exset.is_event(2));
below_exset.add_event(3);
assert!(below_exset.is_event(1));
assert!(!below_exset.is_event(2));
assert!(below_exset.is_event(3));
below_exset.add_event(2);
assert!(below_exset.is_event(1));
assert!(below_exset.is_event(2));
assert!(below_exset.is_event(3));Source§fn is_event(&self, event: u64) -> bool
fn is_event(&self, event: u64) -> bool
Checks if an event is part of the set.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
let event = below_exset.next_event();
assert!(below_exset.is_event(event));
below_exset.add_event(3);
assert!(!below_exset.is_event(2));
assert!(below_exset.is_event(3));Source§fn events(&self) -> (u64, Vec<u64>)
fn events(&self) -> (u64, Vec<u64>)
Returns all events seen as a tuple. The first component is the highest event seen, while the second is a vector with the exceptions (in no specific order).
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
below_exset.add_event(1);
assert_eq!(below_exset.events(), (1, vec![]));
below_exset.add_event(3);
assert_eq!(below_exset.events(), (3, vec![2]));
below_exset.add_event(2);
assert_eq!(below_exset.events(), (3, vec![]));
below_exset.add_event(4);
assert_eq!(below_exset.events(), (4, vec![]));
below_exset.add_event(6);
assert_eq!(below_exset.events(), (6, vec![5]));Source§fn frontier(&self) -> u64
fn frontier(&self) -> u64
Returns the frontier (the highest contiguous event seen).
Note: this method’s implementation will sort all exceptions on each
call, and with that, the performance will not be great. If this
becomes a problem, we could cache the frontier (as in AboveExSet)
so that it doesn’t have to be computed here on each call.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
assert_eq!(below_exset.frontier(), 0);
below_exset.add_event(1);
assert_eq!(below_exset.frontier(), 1);
below_exset.add_event(3);
assert_eq!(below_exset.frontier(), 1);
below_exset.add_event(2);
assert_eq!(below_exset.frontier(), 3);
below_exset.add_event(4);
assert_eq!(below_exset.frontier(), 4);
below_exset.add_event(6);
assert_eq!(below_exset.frontier(), 4);Source§fn join(&mut self, other: &Self)
fn join(&mut self, other: &Self)
Merges other BelowExSet into self.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
below_exset.add_event(1);
below_exset.add_event(3);
below_exset.add_event(4);
assert_eq!(below_exset.events(), (4, vec![2]));
below_exset.join(&BelowExSet::from_event(3));
assert_eq!(below_exset.events(), (4, vec![2]));
below_exset.join(&BelowExSet::from_event(5));
assert_eq!(below_exset.events(), (5, vec![2]));
let mut other = BelowExSet::new();
other.add_event(2);
other.add_event(7);
below_exset.join(&other);
assert_eq!(below_exset.events(), (7, vec![6]));Source§fn event_iter(self) -> Self::EventIter
fn event_iter(self) -> Self::EventIter
Returns a BelowExSet event iterator with all events from lowest to
highest.
§Examples
use threshold::*;
let mut below_exset = BelowExSet::new();
below_exset.add_event(3);
below_exset.add_event(5);
let mut iter = below_exset.event_iter();
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), Some(5));
assert_eq!(iter.next(), None);type EventIter = EventIter
Source§fn subtracted(&self, _other: &Self) -> Vec<u64>
fn subtracted(&self, _other: &Self) -> Vec<u64>
other is subtracted from
self.Source§fn from_event(event: u64) -> Self
fn from_event(event: u64) -> Self
event.Source§fn from_event_range(start: u64, end: u64) -> Self
fn from_event_range(start: u64, end: u64) -> Self
Source§fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self
fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self
events.