Trait ConcurrentMap

Source
pub trait ConcurrentMap<K: ?Sized, V> {
    // Required methods
    fn lookup<'a>(&'a self, key: &K, guard: &'a Guard) -> Option<&'a V>;
    fn insert(&self, key: K, value: V, guard: &Guard) -> Result<(), V>;
    fn delete<'a>(&'a self, key: &K, guard: &'a Guard) -> Result<&'a V, ()>;
}
Expand description

Trait for a concurrent key-value map.

Required Methods§

Source

fn lookup<'a>(&'a self, key: &K, guard: &'a Guard) -> Option<&'a V>

Lookups the given key to get the reference to its value.

Source

fn insert(&self, key: K, value: V, guard: &Guard) -> Result<(), V>

Inserts a key-value pair.

Source

fn delete<'a>(&'a self, key: &K, guard: &'a Guard) -> Result<&'a V, ()>

Deletes the given key and returns a reference to its value.

Unlike stack or queue’s pop that can return Option<V>, since a deleted value may also be lookuped, we can only return a reference, not full ownership.

Implementors§