pub struct MaxSet { /* private fields */ }
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MaxSet
impl<'de> Deserialize<'de> for MaxSet
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 MaxSet
impl EventSet for MaxSet
Source§fn next_event(&mut self) -> u64
fn next_event(&mut self) -> u64
Generates the next event.
§Examples
use threshold::*;
let mut maxset = MaxSet::new();
assert_eq!(maxset.next_event(), 1);
assert_eq!(maxset.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 maxset = MaxSet::new();
assert!(!maxset.is_event(9));
assert!(!maxset.is_event(10));
maxset.add_event(10);
assert!(maxset.is_event(9));
assert!(maxset.is_event(10));
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.
Returns true
if a new event was added.
In the case of MaxSet
we have that:
add_event_range(start, end) == add_event(end)
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 maxset = MaxSet::new();
let event = maxset.next_event();
assert!(maxset.is_event(event));
Source§fn events(&self) -> (u64, Vec<u64>)
fn events(&self) -> (u64, Vec<u64>)
Returns all events seen.
§Examples
use threshold::*;
let mut maxset = MaxSet::new();
maxset.add_event(2);
maxset.add_event(4);
assert_eq!(maxset.events(), (4, vec![]));
Source§fn frontier(&self) -> u64
fn frontier(&self) -> u64
Returns the frontier (the highest contiguous event seen).
For a MaxSet
, this is not necessarily the highest contiguous event,
but simply the highest event.
For exact EventSet
representations that will actually return the
highest contiguous event, see AboveExSet
and BelowExSet
.
§Examples
use threshold::*;
let mut maxset = MaxSet::new();
assert_eq!(maxset.frontier(), 0);
maxset.add_event(1);
assert_eq!(maxset.frontier(), 1);
maxset.add_event(3);
assert_eq!(maxset.frontier(), 3);
maxset.add_event(2);
assert_eq!(maxset.frontier(), 3);
maxset.add_event(4);
assert_eq!(maxset.frontier(), 4);
maxset.add_event(6);
assert_eq!(maxset.frontier(), 6);
Source§fn join(&mut self, other: &Self)
fn join(&mut self, other: &Self)
Merges other
MaxSet
into self
.
§Examples
use threshold::*;
let mut maxset = MaxSet::from_event(10);
assert!(!maxset.is_event(20));
maxset.join(&MaxSet::from_event(20));
assert!(maxset.is_event(20));
Source§fn meet(&mut self, other: &Self)
fn meet(&mut self, other: &Self)
Intersects other
MaxSet
with self
.
§Examples
use threshold::*;
let mut maxset = MaxSet::from_event(20);
assert!(maxset.is_event(20));
maxset.meet(&MaxSet::from_event(10));
assert!(!maxset.is_event(20));
Source§fn event_iter(self) -> Self::EventIter
fn event_iter(self) -> Self::EventIter
Returns a MaxSet
event iterator with all events from lowest to
highest.
§Examples
use threshold::*;
let mut maxset = MaxSet::new();
maxset.add_event(3);
let mut iter = maxset.event_iter();
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));
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
.impl Eq for MaxSet
impl StructuralPartialEq for MaxSet
Auto Trait Implementations§
impl Freeze for MaxSet
impl RefUnwindSafe for MaxSet
impl Send for MaxSet
impl Sync for MaxSet
impl Unpin for MaxSet
impl UnwindSafe for MaxSet
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