pub struct ORSet<T: Ord> { /* private fields */ }Expand description
An observed-remove set (OR-Set) with add-wins semantics.
Each element is tracked with a timestamp. Removals record a tombstone timestamp. An element is considered present when its entry timestamp is greater than or equal to its tombstone timestamp (add-wins: concurrent add and remove resolve in favor of add).
The internal clock advances automatically on mutation and is bumped to
max(self, other) on merge.
Implementations§
Source§impl<T: Ord> ORSet<T>
impl<T: Ord> ORSet<T>
Sourcepub fn insert(&mut self, value: T)
pub fn insert(&mut self, value: T)
Insert an element. If previously removed, the add-wins semantics re-add it.
Sourcepub fn remove(&mut self, value: &T)where
T: Clone,
pub fn remove(&mut self, value: &T)where
T: Clone,
Remove an element by recording a tombstone at the current clock.
Sourcepub fn contains(&self, value: &T) -> bool
pub fn contains(&self, value: &T) -> bool
Returns true if the element is present (entry timestamp >= tombstone timestamp).
Trait Implementations§
Source§impl<'de, T: Ord + DeserializeOwned> Deserialize<'de> for ORSet<T>
impl<'de, T: Ord + DeserializeOwned> Deserialize<'de> for ORSet<T>
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
impl<T: Eq + Ord> Eq for ORSet<T>
impl<T: Ord> StructuralPartialEq for ORSet<T>
Auto Trait Implementations§
impl<T> Freeze for ORSet<T>
impl<T> RefUnwindSafe for ORSet<T>where
T: RefUnwindSafe,
impl<T> Send for ORSet<T>where
T: Send,
impl<T> Sync for ORSet<T>where
T: Sync,
impl<T> Unpin for ORSet<T>
impl<T> UnwindSafe for ORSet<T>where
T: RefUnwindSafe,
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