[−][src]Struct threshold::BelowExSet
Implementations
impl BelowExSet
[src]
pub fn from<I: IntoIterator<Item = u64>>(max: u64, iter: I) -> Self
[src]
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
impl Clone for BelowExSet
[src]
fn clone(&self) -> BelowExSet
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for BelowExSet
[src]
impl Default for BelowExSet
[src]
fn default() -> BelowExSet
[src]
impl<'de> Deserialize<'de> for BelowExSet
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for BelowExSet
[src]
impl EventSet for BelowExSet
[src]
type EventIter = EventIter
fn new() -> Self
[src]
Returns a new BelowExSet
instance.
fn next_event(&mut self) -> u64
[src]
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);
fn add_event(&mut self, event: u64) -> bool
[src]
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));
fn is_event(&self, event: u64) -> bool
[src]
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));
fn events(&self) -> (u64, Vec<u64>)
[src]
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]));
fn frontier(&self) -> u64
[src]
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);
fn join(&mut self, other: &Self)
[src]
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]));
fn meet(&mut self, _other: &Self)
[src]
fn event_iter(self) -> Self::EventIter
[src]
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);
fn from_event(event: u64) -> Self
[src]
fn from_event_range(start: u64, end: u64) -> Self
[src]
fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self
[src]
fn add_event_range(&mut self, start: u64, end: u64) -> bool
[src]
impl PartialEq<BelowExSet> for BelowExSet
[src]
fn eq(&self, other: &BelowExSet) -> bool
[src]
fn ne(&self, other: &BelowExSet) -> bool
[src]
impl Serialize for BelowExSet
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for BelowExSet
[src]
impl StructuralPartialEq for BelowExSet
[src]
Auto Trait Implementations
impl RefUnwindSafe for BelowExSet
impl Send for BelowExSet
impl Sync for BelowExSet
impl Unpin for BelowExSet
impl UnwindSafe for BelowExSet
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,