pub struct ORMap<K: Ord, V: Lattice> { /* private fields */ }Expand description
An observed-remove map (OR-Map) with put-wins semantics and recursive value merge.
Each key maps to an [Entry] containing a value V: Lattice and an insertion timestamp.
Removals record a tombstone timestamp. A key is considered present when its entry timestamp
is greater than or equal to its tombstone timestamp (put-wins: concurrent put and
remove resolve in favor of put).
When both replicas have a present entry for the same key, the values are merged using
the V::merge lattice operation, providing recursive conflict resolution.
The internal clock advances automatically on mutation and is bumped to
max(self, other) on merge.
Implementations§
Source§impl<K: Ord, V: Lattice> ORMap<K, V>
impl<K: Ord, V: Lattice> ORMap<K, V>
Sourcepub fn put(&mut self, key: K, value: V)
pub fn put(&mut self, key: K, value: V)
Put a key-value pair. Overwrites any existing value for the key.
Sourcepub fn remove(&mut self, key: &K)where
K: Clone,
pub fn remove(&mut self, key: &K)where
K: Clone,
Remove a key by recording a tombstone at the current clock.
Sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Returns a reference to the value for the key, if present.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the key is present.