[−][src]Struct cvrdt_exposition::two_phase_set::TwoPhaseSet
A set that can add or delete values
Panics
Any attempt to del
an element that one did not previously add
will panic:
ⓘThis example panics
// this will panic use std::collections::HashSet; use cvrdt_exposition::{Grow, Shrink, TwoPhaseSet}; let mut x = TwoPhaseSet::new((HashSet::new(), HashSet::new())); x.del("this will panic");
Examples
Example usage, including demonstrating some properties:
use std::collections::HashSet; use cvrdt_exposition::{Grow, Shrink, TwoPhaseSet}; let mut x = TwoPhaseSet::new((HashSet::new(), HashSet::new())); for c in "abc".chars() { x.add(c); } x.del('c'); assert_eq!(x.query(&'a'), true); assert_eq!(x.query(&'z'), false); assert_eq!(x.query(&'c'), false); let y = TwoPhaseSet::new(("abcdef".chars().collect(), HashSet::new())); assert_eq!(x.merge(&y).payload(), y.merge(&x).payload()); let z = TwoPhaseSet::new(("8675309abcdefg".chars().collect(), "toremove".chars().collect())); assert_eq!(x.merge(&y.merge(&z)).payload(), x.merge(&y).merge(&z).payload());
Fields
added: HashSet<X>
The elements that have been added to this set
removed: HashSet<X>
The elements that have been removed from this set
Trait Implementations
impl<X: Clone + Eq + Hash> Clone for TwoPhaseSet<X>
[src]
fn clone(&self) -> TwoPhaseSet<X>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<X: Debug + Clone + Eq + Hash> Debug for TwoPhaseSet<X>
[src]
impl<X: Clone + Eq + Hash> Grow for TwoPhaseSet<X>
[src]
type Payload = (HashSet<X>, HashSet<X>)
The internal state of our CvRDT; sufficient to build a new copy via new
. Required to implement Eq
for testing and verification. Read more
type Update = X
Message to update our internal state
type Query = X
Message to query the Value
of our CvRDT
type Value = bool
The response to a Query
fn new(payload: Self::Payload) -> Self
[src]
fn payload(&self) -> Self::Payload
[src]
fn add(&mut self, update: Self::Update)
[src]
fn le(&self, other: &Self) -> bool
[src]
fn merge(&self, other: &Self) -> Self
[src]
fn query(&self, query: &Self::Query) -> Self::Value
[src]
impl<X: Clone + Eq + Hash> Shrink for TwoPhaseSet<X>
[src]
Auto Trait Implementations
impl<X> RefUnwindSafe for TwoPhaseSet<X> where
X: RefUnwindSafe,
X: RefUnwindSafe,
impl<X> Send for TwoPhaseSet<X> where
X: Send,
X: Send,
impl<X> Sync for TwoPhaseSet<X> where
X: Sync,
X: Sync,
impl<X> Unpin for TwoPhaseSet<X> where
X: Unpin,
X: Unpin,
impl<X> UnwindSafe for TwoPhaseSet<X> where
X: UnwindSafe,
X: UnwindSafe,
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> 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>,