pub struct AboveRangeSet { /* private fields */ }Implementations§
Source§impl AboveRangeSet
impl AboveRangeSet
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 contiguous event, and a sequence of extra events.
§Examples
use threshold::*;
let above_range_set = AboveRangeSet::from(0, vec![2, 4, 5]);
assert!(!above_range_set.is_event(1));
assert!(above_range_set.is_event(2));
assert!(!above_range_set.is_event(3));
assert!(above_range_set.is_event(4));
assert!(above_range_set.is_event(5));
assert!(!above_range_set.is_event(6));Trait Implementations§
Source§impl Clone for AboveRangeSet
impl Clone for AboveRangeSet
Source§fn clone(&self) -> AboveRangeSet
fn clone(&self) -> AboveRangeSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AboveRangeSet
impl Debug for AboveRangeSet
Source§impl Default for AboveRangeSet
impl Default for AboveRangeSet
Source§fn default() -> AboveRangeSet
fn default() -> AboveRangeSet
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for AboveRangeSet
impl<'de> Deserialize<'de> for AboveRangeSet
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl EventSet for AboveRangeSet
impl EventSet for AboveRangeSet
Source§fn next_event(&mut self) -> u64
fn next_event(&mut self) -> u64
Generates the next event. There should be no extra ranges when calling this.
§Examples
use threshold::*;
let mut above_range_set = AboveRangeSet::new();
assert_eq!(above_range_set.next_event(), 1);
assert_eq!(above_range_set.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.
Returns true if it’s a new event.
§Examples
use threshold::*;
let mut above_range_set = AboveRangeSet::new();
above_range_set.add_event(1);
assert!(above_range_set.is_event(1));
assert!(!above_range_set.is_event(2));
above_range_set.add_event(3);
assert!(above_range_set.is_event(1));
assert!(!above_range_set.is_event(2));
assert!(above_range_set.is_event(3));
above_range_set.add_event(2);
assert!(above_range_set.is_event(1));
assert!(above_range_set.is_event(2));
assert!(above_range_set.is_event(3));Source§fn add_event_range(&mut self, start: u64, end: u64) -> bool
fn add_event_range(&mut self, start: u64, end: u64) -> bool
Adds a range of events to the set.
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 above_range_set = AboveRangeSet::new();
let event = above_range_set.next_event();
assert!(above_range_set.is_event(event));
above_range_set.add_event(3);
assert!(!above_range_set.is_event(2));
assert!(above_range_set.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 above_range_set = AboveRangeSet::new();
above_range_set.add_event(1);
assert_eq!(above_range_set.events(), (1, vec![]));
above_range_set.add_event(3);
assert_eq!(above_range_set.events(), (1, vec![3]));
above_range_set.add_event(2);
assert_eq!(above_range_set.events(), (3, vec![]));
above_range_set.add_event(4);
assert_eq!(above_range_set.events(), (4, vec![]));
above_range_set.add_event(6);
assert_eq!(above_range_set.events(), (4, vec![6]));Source§fn frontier(&self) -> u64
fn frontier(&self) -> u64
Returns the frontier (the highest contiguous event seen).
§Examples
use threshold::*;
let mut above_range_set = AboveRangeSet::new();
assert_eq!(above_range_set.frontier(), 0);
above_range_set.add_event(1);
assert_eq!(above_range_set.frontier(), 1);
above_range_set.add_event(3);
assert_eq!(above_range_set.frontier(), 1);
above_range_set.add_event(2);
assert_eq!(above_range_set.frontier(), 3);
above_range_set.add_event(4);
assert_eq!(above_range_set.frontier(), 4);
above_range_set.add_event(6);
assert_eq!(above_range_set.frontier(), 4);Source§fn join(&mut self, other: &Self)
fn join(&mut self, other: &Self)
Merges other AboveRangeSet into self.
§Examples
use threshold::*;
let mut above_range_set = AboveRangeSet::new();
above_range_set.add_event(1);
above_range_set.add_event(3);
above_range_set.add_event(4);
assert_eq!(above_range_set.events(), (1, vec![3, 4]));
above_range_set.join(&AboveRangeSet::from_event(3));
assert_eq!(above_range_set.events(), (1, vec![3, 4]));
above_range_set.join(&AboveRangeSet::from_event(5));
assert_eq!(above_range_set.events(), (1, vec![3, 4, 5]));
let mut other = AboveRangeSet::new();
other.add_event(2);
other.add_event(7);
above_range_set.join(&other);
assert_eq!(above_range_set.events(), (5, vec![7]));Source§fn event_iter(self) -> Self::EventIter
fn event_iter(self) -> Self::EventIter
Returns a AboveRangeSet event iterator with all events from lowest to
highest.
§Examples
use threshold::*;
let mut above_range_set = AboveRangeSet::new();
above_range_set.add_event(3);
above_range_set.add_event(5);
let mut iter = above_range_set.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>
Return a list of events that remain when
other is subtracted from
self.Source§fn from_event(event: u64) -> Self
fn from_event(event: u64) -> Self
Creates a new instance from
event.Source§fn from_event_range(start: u64, end: u64) -> Self
fn from_event_range(start: u64, end: u64) -> Self
Creates a new instance from a range of events.
Source§fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self
fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self
Creates a new instance from several
events.Source§impl PartialEq for AboveRangeSet
impl PartialEq for AboveRangeSet
Source§impl Serialize for AboveRangeSet
impl Serialize for AboveRangeSet
impl Eq for AboveRangeSet
impl StructuralPartialEq for AboveRangeSet
Auto Trait Implementations§
impl Freeze for AboveRangeSet
impl RefUnwindSafe for AboveRangeSet
impl Send for AboveRangeSet
impl Sync for AboveRangeSet
impl Unpin for AboveRangeSet
impl UnwindSafe for AboveRangeSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more