[][src]Struct cvrdt_exposition::two_phase_set::TwoPhaseSet

pub struct TwoPhaseSet<X: Clone + Eq + Hash> {
    pub added: HashSet<X>,
    pub removed: HashSet<X>,
}

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]

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

impl<X: Clone + Eq + Hash> Shrink for TwoPhaseSet<X>[src]

Auto Trait Implementations

impl<X> RefUnwindSafe for TwoPhaseSet<X> where
    X: RefUnwindSafe

impl<X> Send for TwoPhaseSet<X> where
    X: Send

impl<X> Sync for TwoPhaseSet<X> where
    X: Sync

impl<X> Unpin for TwoPhaseSet<X> where
    X: Unpin

impl<X> UnwindSafe for TwoPhaseSet<X> where
    X: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.