pub struct OrSet<T: Hash + Eq> {
pub elements: HashSet<(T, Timestamp)>,
pub tombstone: HashSet<(T, Timestamp)>,
}Expand description
Observed-Remove Set (Add-Wins)
Fields§
§elements: HashSet<(T, Timestamp)>§tombstone: HashSet<(T, Timestamp)>Implementations§
Source§impl<T: Hash + Eq + Clone> OrSet<T>
impl<T: Hash + Eq + Clone> OrSet<T>
Sourcepub fn add(&mut self, value: T, tag: Timestamp)
pub fn add(&mut self, value: T, tag: Timestamp)
Add an element to the set with a unique tag.
The tag (timestamp) must be unique across all operations to ensure correct causality tracking. In bones, this is guaranteed by the event hash or ITC stamp.
Sourcepub fn remove(&mut self, value: &T) -> Vec<Timestamp>
pub fn remove(&mut self, value: &T) -> Vec<Timestamp>
Remove an element from the set.
This tombstones all currently-observed tags for the given element. Any tags added concurrently (not yet observed) will survive, implementing add-wins semantics.
Returns the tags that were tombstoned (empty if element was not present).
Sourcepub fn remove_specific(&mut self, value: &T, tags: &[Timestamp])
pub fn remove_specific(&mut self, value: &T, tags: &[Timestamp])
Remove specific tags for an element.
Tombstones only the provided tags.
Sourcepub fn contains(&self, value: &T) -> bool
pub fn contains(&self, value: &T) -> bool
Check if an element is present in the set.
An element is present if it has at least one add-tag that is not covered by a corresponding tombstone.
Sourcepub fn values(&self) -> HashSet<&T>
pub fn values(&self) -> HashSet<&T>
Return all currently-present values in the set.
An element is present if it has at least one un-tombstoned add-tag.
Return all active (un-tombstoned) tags for a given value.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for OrSet<T>
impl<'de, T> 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>,
Source§impl<T: Eq + Hash + Clone> Merge for OrSet<T>
Merge implementation for OR-Set.
impl<T: Eq + Hash + Clone> Merge for OrSet<T>
Merge implementation for OR-Set.
The merge is a union of both the element sets and the tombstone sets. This satisfies semilattice laws because set union is commutative, associative, and idempotent.
After merge, an element is present iff it has at least one add-tag not covered by a tombstone entry.
impl<T: Eq + Hash + Eq> Eq for OrSet<T>
impl<T: Hash + Eq> 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>where
T: Unpin,
impl<T> UnsafeUnpin for OrSet<T>
impl<T> UnwindSafe for OrSet<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.